九、安装对象存储服务(swift),不使用控制節點數據庫服務,而於各存儲節點使用分布式sqlite數據庫。
9.1对象存储服务包括的组件
Proxy servers (swift-proxy-server)代理服務,接收API或HTTP請求,執行上傳文件、修改源數據、WEB瀏覽時列表文件和創建容器等操作。通常使用CACHE技術(memcache)提高性能
Account servers (swift-account-server)賬戶服務,管理對象存儲中的賬戶定義。
Container servers (swift-container-server)容器服務,在對象存儲中管理容器或文件夾映……
Object servers (swift-object-server)對象服務,在存儲節點管理實際的對象,比如文件。
VarIoUs periodic processes執行各種週期性任務,比如複製服務確保群集中數據一致性和可用性。其他包括審計、更新、以及資源回收等。
WSGI middleware處理認證,通常使用OPENSTACK Identity
swift client為用戶提供命令行接口使用REST API
swift-init初始化和構建RING文件腳本
swift-recon一個命令行工具,用於檢索群集的各種度量和測試信息。
swift-ring-builder存儲RING構建和再平衡工具
9.2控制节点安裝配置代理服務(proxy service),用於處理用戶、容器以及對象操作請求,可以部署多個節點提高性能和冗余。可以不基於OPENSTACK其他組件安裝,自身可提供認證機制。
9.2.1創建用戶以及API訪問點
[root@comtroller1~]#.admin-openrc.sh [root@comtroller1~]#openstackusercreate--domaindefault--password-promptswift UserPassword: RepeatUserPassword: +-----------+----------------------------------+ |Field|Value| +-----------+----------------------------------+ |domain_id|default| |enabled|True| |id|9f9d73e380ac4db0af601604ee45ea02| |name|swift| +-----------+----------------------------------+ [root@comtroller1~]#openstackroleadd--projectservice--userswiftadmin [root@comtroller1~]#openstackservicecreate--nameswift--description"OpenStackObjectStorage"object-store +-------------+----------------------------------+ |Field|Value| +-------------+----------------------------------+ |description|OpenStackObjectStorage| |enabled|True| |id|6cbf871fbf5f4cb192a1e1337e59e5ed| |name|swift| |type|object-store| +-------------+----------------------------------+ [root@comtroller1~]#openstackendpointcreate--regionRegionOneobject-storepublichttp://controller1:8080/v1/AUTH_%\(tenant_id\)s +--------------+-----------------------------------------------+ |Field|Value| +--------------+-----------------------------------------------+ |enabled|True| |id|9850ec8e31b7434090cca0d881355b46| |interface|public| |region|RegionOne| |region_id|RegionOne| |service_id|6cbf871fbf5f4cb192a1e1337e59e5ed| |service_name|swift| |service_type|object-store| |url|http://controller1:8080/v1/AUTH_%(tenant_id)s| +--------------+-----------------------------------------------+ [root@comtroller1~]#openstackendpointcreate--regionRegionOneobject-storeinternalhttp://controller1:8080/v1/AUTH_%\(tenant_id\)s +--------------+-----------------------------------------------+ |Field|Value| +--------------+-----------------------------------------------+ |enabled|True| |id|11a006619fc24414accc7117a4daabc9| |interface|internal| |region|RegionOne| |region_id|RegionOne| |service_id|6cbf871fbf5f4cb192a1e1337e59e5ed| |service_name|swift| |service_type|object-store| |url|http://controller1:8080/v1/AUTH_%(tenant_id)s| +--------------+-----------------------------------------------+ [root@comtroller1~]#openstackendpointcreate--regionRegionOneobject-storeadminhttp://controller1:8080/v1 +--------------+----------------------------------+ |Field|Value| +--------------+----------------------------------+ |enabled|True| |id|4d52cf1cf9ab4eab8e14c5db7a564960| |interface|admin| |region|RegionOne| |region_id|RegionOne| |service_id|6cbf871fbf5f4cb192a1e1337e59e5ed| |service_name|swift| |service_type|object-store| |url|http://controller1:8080/v1| +--------------+----------------------------------+
9.2.2安裝配置組件
[root@comtroller1~]#yuminstallopenstack-swift-proxypython-swiftclientpython-keystoneclientpython-keystonemiddlewarememcached-y [root@comtroller1~]#curl-o/etc/swift/proxy-server.confhttps://git.openstack.org/cgit/openstack/swift/plain/etc/proxy-server.conf-sample?h=stable/liberty %Total%Received%XferdAverageSpeedTimeTimeTimeCurrent DloadUploadTotalSpentLeftSpeed 1002965510029655001419400:00:020:00:02--:--:--14188 [root@comtroller1~]#vi/etc/swift/proxy-server.conf [DEFAULT] bind_port=8080 user=swift swift_dir=/etc/swift [pipeline:main] pipeline=catch_errorsgatekeeperhealthcheckproxy-loggingcachecontainer_syncbulkratelimitauthtokenkeystoneauthcontainer-quotasaccount-quotasslodloversioned_writesproxy-loggingproxy-server [app:proxy-server] use=egg:swift#proxy account_autocreate=true [filter:keystoneauth]此项也需要取消注释 use=egg:swift#keystoneauth operator_roles=admin,user [filter:authtoken]移除或註釋此配置組下其他項目 paste.filter_factory=keystonemiddleware.auth_token:filter_factory auth_uri=http://controller1:5000 auth_url=http://controller1:35357 auth_plugin=password project_domain_id=default user_domain_id=default project_name=service username=swift password=swift delay_auth_decision=true [filter:cache] use=egg:swift#memcache memcache_servers=127.0.0.1:11211
9.3安裝配置存儲節點
9.3.1準備存儲節點:支持所有具備extended attributes (xattr)文件系統,推薦使用XFS文件系統。###在兩節點均執行如下準備操作。
[root@object1~]#yuminstallxfsprogsrsync-y [root@object1~]#ls/dev/sd* /dev/sda/dev/sda1/dev/sda2/dev/sdb/dev/sdc [root@object1~]#mkfs.xfs/dev/sdb Meta-data=/dev/sdbisize=256agcount=4,agsize=8388608blks =sectsz=512attr=2,projid32bit=1 =crc=0finobt=0 data=bsize=4096blocks=33554432,imaxpct=25 =sunit=0swidth=0blks naming=version2bsize=4096ascii-ci=0ftype=0 log=internallogbsize=4096blocks=16384,version=2 =sectsz=512sunit=0blks,lazy-count=1 realtime=noneextsz=4096blocks=0,rtextents=0 [root@object1~]#mkfs.xfs/dev/sdc Meta-data=/dev/sdcisize=256agcount=4,rtextents=0 [root@object1~]#mkdir-p/srv/node/sdb [root@object1~]#mkdir-p/srv/node/sdc [root@object1~]#vi/etc/fstab /dev/sdb/srv/node/sdbxfsnoatime,nodiratime,nobarrier,logbufs=802 /dev/sdc/srv/node/sdcxfsnoatime,logbufs=802 [root@object1~]#mount/srv/node/sdb [root@object1~]#mount/srv/node/sdc [root@object1~]#vi/etc/rsyncd.conf uid=swift gid=swift logfile=/var/log/rsyncd.log pidfile=/var/run/rsyncd.pid address=10.0.0.51###對應存儲節點IP地址 [account] maxconnections=2 path=/srv/node/ readonly=false lockfile=/var/lock/account.lock [container] maxconnections=2 path=/srv/node/ readonly=false lockfile=/var/lock/container.lock [object] maxconnections=2 path=/srv/node/ readonly=false lockfile=/var/lock/object.lock [root@object1~]#systemctlenablersyncd.service Createdsymlinkfrom/etc/systemd/system/multi-user.target.wants/rsyncd.serviceto/usr/lib/systemd/system/rsyncd.service. [root@object1~]#systemctlstartrsyncd.service [root@object1~]#systemctlstatusrsyncd.service
9.3.2安裝配置組件
[root@object1~]#yuminstallopenstack-swift-accountopenstack-swift-containeropenstack-swift-object-y [root@object1~]#curl-o/etc/swift/account-server.confhttps://git.openstack.org/cgit/openstack/swift/plain/etc/account-server.conf-sample?h=stable/liberty %Total%Received%XferdAverageSpeedTimeTimeTimeCurrent DloadUploadTotalSpentLeftSpeed 1006147100614700434400:00:010:00:01--:--:--4347 [root@object1~]#curl-o/etc/swift/container-server.confhttps://git.openstack.org/cgit/openstack/swift/plain/etc/container-server.conf-sample?h=stable/liberty %Total%Received%XferdAverageSpeedTimeTimeTimeCurrent DloadUploadTotalSpentLeftSpeed 100697610069760051600:00:130:00:13--:--:--2087 [root@object1~]# [root@object1~]#curl-o/etc/swift/object-server.confhttps://git.openstack.org/cgit/openstack/swift/plain/etc/object-server.conf-sample?h=stable/liberty %Total%Received%XferdAverageSpeedTimeTimeTimeCurrent DloadUploadTotalSpentLeftSpeed 100118191001181900923400:00:010:00:01--:--:--9240 [root@object1~]#vi/etc/swift/account-server.conf [DEFAULT] bind_ip=10.0.0.51 bind_port=6002 user=swift swift_dir=/etc/swift devices=/srv/node mount_check=true [pipeline:main] pipeline=healthcheckreconaccount-server [filter:recon] use=egg:swift#recon recon_cache_path=/var/cache/swift [root@object1~]#vi/etc/swift/container-server.conf [DEFAULT] bind_ip=10.0.0.51 bind_port=6001 user=swift swift_dir=/etc/swift devices=/srv/node mount_check=true [pipeline:main] pipeline=healthcheckreconcontainer-server [filter:recon] use=egg:swift#recon recon_cache_path=/var/cache/swift [root@object1~]#vi/etc/swift/object-server.conf [DEFAULT] bind_ip=10.0.0.51 bind_port=6000 user=swift swift_dir=/etc/swift devices=/srv/node mount_check=true [pipeline:main] pipeline=healthcheckreconobject-server [filter:recon] use=egg:swift#recon recon_cache_path=/var/cache/swift recon_lock_path=/var/lock [root@object1~]#chown-Rswift:swift/srv/node [root@object1~]#mkdir-p/var/cache/swift [root@object1~]#chown-Rroot:swift/var/cache/swift
9.4創建和分發initial rings(在控制節點執行,安裝有proxy service)
9.4.1創建賬戶RING
[root@comtroller1~]#cd/etc/swift/##切換目錄 [root@comtroller1swift]#swift-ring-builderaccount.buildercreate1031###沒有輸出 [root@comtroller1swift]#swift-ring-builderaccount.builderadd--region1--zone1--ip10.0.0.51--port6002--devicesdb--weight100###將各個存儲節點硬盤添加到RING Deviced0r1z1-10.0.0.51:6002R10.0.0.51:6002/sdb_""with100.0weightgotid0 [root@comtroller1swift]#swift-ring-builderaccount.builderadd--region1--zone2--ip10.0.0.51--port6002--devicesdc--weight100 Deviced1r1z2-10.0.0.51:6002R10.0.0.51:6002/sdc_""with100.0weightgotid1 [root@comtroller1swift]#swift-ring-builderaccount.builderadd--region1--zone3--ip10.0.0.52--port6002--devicesdb--weight100 Deviced2r1z3-10.0.0.52:6002R10.0.0.52:6002/sdb_""with100.0weightgotid2 [root@comtroller1swift]#swift-ring-builderaccount.builderadd--region1--zone4--ip10.0.0.52--port6002--devicesdc--weight100 Deviced3r1z4-10.0.0.52:6002R10.0.0.52:6002/sdc_""with100.0weightgotid3 [root@comtroller1swift]#swift-ring-builderaccount.builder##驗證RING配置 account.builder,buildversion4 1024partitions,3.000000replicas,1regions,4zones,4devices,100.00balance,0.00dispersion Theminimumnumberofhoursbeforeapartitioncanbereassignedis1 Theoverloadfactoris0.00%(0.000000) Devices:idregionzoneipaddressportreplicationipreplicationportnameweightpartitionsbalanceMeta 01110.0.0.51600210.0.0.516002sdb100.000-100.00 11210.0.0.51600210.0.0.516002sdc100.000-100.00 21310.0.0.52600210.0.0.526002sdb100.000-100.00 31410.0.0.52600210.0.0.526002sdc100.000-100.00 [root@comtroller1swift]#swift-ring-builderaccount.builderrebalance##再平衡RING Reassigned1024(100.00%)partitions.Balanceisnow0.00.Dispersionisnow0.00
9.4.2創建容器RING
[root@comtroller1~]#cd/etc/swift/ [root@comtroller1swift]#swift-ring-buildercontainer.buildercreate1031 [root@comtroller1swift]#swift-ring-buildercontainer.builderadd--region1--zone1--ip10.0.0.51--port6001--devicesdb--weight100 Deviced0r1z1-10.0.0.51:6001R10.0.0.51:6001/sdb_""with100.0weightgotid0 [root@comtroller1swift]#swift-ring-buildercontainer.builderadd--region1--zone2--ip10.0.0.51--port6001--devicesdc--weight100 Deviced1r1z2-10.0.0.51:6001R10.0.0.51:6001/sdc_""with100.0weightgotid1 [root@comtroller1swift]#swift-ring-buildercontainer.builderadd--region1--zone3--ip10.0.0.52--port6001--devicesdb--weight100 Deviced2r1z3-10.0.0.52:6001R10.0.0.52:6001/sdb_""with100.0weightgotid2 [root@comtroller1swift]#swift-ring-buildercontainer.builderadd--region1--zone4--ip10.0.0.52--port6001--devicesdc--weight100 Deviced3r1z4-10.0.0.52:6001R10.0.0.52:6001/sdc_""with100.0weightgotid3 [root@comtroller1swift]#swift-ring-buildercontainer.builder container.builder,0.00dispersion Theminimumnumberofhoursbeforeapartitioncanbereassignedis1 Theoverloadfactoris0.00%(0.000000) Devices:idregionzoneipaddressportreplicationipreplicationportnameweightpartitionsbalanceMeta 01110.0.0.51600110.0.0.516001sdb100.000-100.00 11210.0.0.51600110.0.0.516001sdc100.000-100.00 21310.0.0.52600110.0.0.526001sdb100.000-100.00 31410.0.0.52600110.0.0.526001sdc100.000-100.00 [root@comtroller1swift]#swift-ring-buildercontainer.builderrebalance Reassigned1024(100.00%)partitions.Balanceisnow0.00.Dispersionisnow0.00
9.4.3創建對象RING
[root@comtroller1~]#cd/etc/swift/ [root@comtroller1swift]#swift-ring-builderobject.buildercreate1031 [root@comtroller1swift]#swift-ring-builderobject.builderadd--region1--zone1--ip10.0.0.51--port6000--devicesdb--weight100 Deviced0r1z1-10.0.0.51:6000R10.0.0.51:6000/sdb_""with100.0weightgotid0 [root@comtroller1swift]#swift-ring-builderobject.builderadd--region1--zone2--ip10.0.0.51--port6000--devicesdc--weight100 Deviced1r1z2-10.0.0.51:6000R10.0.0.51:6000/sdc_""with100.0weightgotid1 [root@comtroller1swift]#swift-ring-builderobject.builderadd--region1--zone3--ip10.0.0.52--port6000--devicesdb--weight100 Deviced2r1z3-10.0.0.52:6000R10.0.0.52:6000/sdb_""with100.0weightgotid2 [root@comtroller1swift]#swift-ring-builderobject.builderadd--region1--zone4--ip10.0.0.52--port6000--devicesdc--weight100 Deviced3r1z4-10.0.0.52:6000R10.0.0.52:6000/sdc_""with100.0weightgotid3 [root@comtroller1swift]#swift-ring-builderobject.builder object.builder,0.00dispersion Theminimumnumberofhoursbeforeapartitioncanbereassignedis1 Theoverloadfactoris0.00%(0.000000) Devices:idregionzoneipaddressportreplicationipreplicationportnameweightpartitionsbalanceMeta 01110.0.0.51600010.0.0.516000sdb100.000-100.00 11210.0.0.51600010.0.0.516000sdc100.000-100.00 21310.0.0.52600010.0.0.526000sdb100.000-100.00 31410.0.0.52600010.0.0.526000sdc100.000-100.00 [root@comtroller1swift]#swift-ring-builderobject.builderrebalance Reassigned1024(100.00%)partitions.Balanceisnow0.00.Dispersionisnow0.00
9.4.4分發RING配置文件:拷貝account.ring.gz,container.ring.gz,and object.ring.gz到每個存儲節點或運行proxy service節點的/etc/swift/目錄下
[root@comtroller1swift]#ll*.ring.gz -rw-r--r--1rootroot1445Aug411:28account.ring.gz -rw-r--r--1rootroot1443Aug411:34container.ring.gz -rw-r--r--1rootroot1438Aug411:37object.ring.gz [root@comtroller1swift]#scp*.ring.gzroot@10.0.0.51:/etc/swift/ Theauthenticityofhost'10.0.0.51(10.0.0.51)'can'tbeestablished. ECDSAkeyfingerprintisce:93:44:a9:4d:03:93:c7:df:bf:6a:c0:a4:7e:13:8a. Areyousureyouwanttocontinueconnecting(yes/no)?yes Warning:Permanentlyadded'10.0.0.51'(ECDSA)tothelistofknownhosts. root@10.0.0.51'spassword: account.ring.gz100%14451.4KB/s00:00 container.ring.gz100%14431.4KB/s00:00 object.ring.gz100%14381.4KB/s00:00 [root@comtroller1swift]#scp*.ring.gzroot@10.0.0.52:/etc/swift/ Theauthenticityofhost'10.0.0.52(10.0.0.52)'can'tbeestablished. ECDSAkeyfingerprintis12:a5:46:52:af:56:1c:1a:f1:f7:ae:04:ee:f4:4c:05. Areyousureyouwanttocontinueconnecting(yes/no)?yes Warning:Permanentlyadded'10.0.0.52'(ECDSA)tothelistofknownhosts. root@10.0.0.52'spassword: account.ring.gz100%14451.4KB/s00:00 container.ring.gz100%14431.4KB/s00:00 object.ring.gz100%14381.4KB/s00:00
9.5結束安裝並啟動服務
9.5.1取得配置文件
[root@comtroller1~]#curl-o/etc/swift/swift.confhttps://git.openstack.org/cgit/openstack/swift/plain/etc/swift.conf-sample?h=stable/liberty
9.5.2配置HASH_PATH_SUFFIX和HASH_PATH_PREFIX
[root@comtroller1~]#vi/etc/swift/swift.conf swift_hash_path_suffix=openstack swift_hash_path_prefix=openstack
9.5.2配置默认存储策略
[storage-policy:0] name=Policy-0 default=yes
9.5.3将配置文件拷贝到各个存储节点
[root@comtroller1~]#scp/etc/swift/swift.confroot@10.0.0.51:/etc/swift/ root@10.0.0.51'spassword: swift.conf100%72027.0KB/s00:00 [root@comtroller1~]#scp/etc/swift/swift.confroot@10.0.0.52:/etc/swift/ root@10.0.0.52'spassword: swift.conf
[root@comtroller1~]#chown-Rroot:swift/etc/swift [root@object1~]#chown-Rroot:swift/etc/swift [root@object2~]#chown-Rroot:swift/etc/swift
9.5.5启动控制节点的SWIFT代理服务
[root@comtroller1~]#systemctlenableopenstack-swift-proxy.servicememcached.service Createdsymlinkfrom/etc/systemd/system/multi-user.target.wants/openstack-swift-proxy.serviceto/usr/lib/systemd/system/openstack-swift-proxy.service. [root@comtroller1~]#systemctlstartopenstack-swift-proxy.servicememcached.service
9.5.6启动各存储节点服务
[root@object1~]#systemctlenableopenstack-swift-account.serviceopenstack-swift-account-auditor.serviceopenstack-swift-account-reaper.serviceopenstack-swift-account-replicator.service [root@object1~]#systemctlstartopenstack-swift-account.serviceopenstack-swift-account-auditor.serviceopenstack-swift-account-reaper.serviceopenstack-swift-account-replicator.service [root@object1~]#systemctlenableopenstack-swift-container.serviceopenstack-swift-container-auditor.serviceopenstack-swift-container-replicator.serviceopenstack-swift-container-updater.service [root@object1~]#systemctlstartopenstack-swift-container.serviceopenstack-swift-container-auditor.serviceopenstack-swift-container-replicator.serviceopenstack-swift-container-updater.service [root@object1~]#systemctlenableopenstack-swift-object.serviceopenstack-swift-object-auditor.serviceopenstack-swift-object-replicator.serviceopenstack-swift-object-updater.service [root@object1~]#systemctlstartopenstack-swift-object.serviceopenstack-swift-object-auditor.serviceopenstack-swift-object-replicator.serviceopenstack-swift-object-updater.service [root@object2~]#systemctlenableopenstack-swift-account.serviceopenstack-swift-account-auditor.serviceopenstack-swift-account-reaper.serviceopenstack-swift-account-replicator.service [root@object2~]#systemctlstartopenstack-swift-account.serviceopenstack-swift-account-auditor.serviceopenstack-swift-account-reaper.serviceopenstack-swift-account-replicator.service [root@object2~]#systemctlenableopenstack-swift-container.serviceopenstack-swift-container-auditor.serviceopenstack-swift-container-replicator.serviceopenstack-swift-container-updater.service [root@object2~]#systemctlstartopenstack-swift-container.serviceopenstack-swift-container-auditor.serviceopenstack-swift-container-replicator.serviceopenstack-swift-container-updater.service [root@object2~]#systemctlenableopenstack-swift-object.serviceopenstack-swift-object-auditor.serviceopenstack-swift-object-replicator.serviceopenstack-swift-object-updater.service [root@object2~]#systemctlstartopenstack-swift-object.serviceopenstack-swift-object-auditor.serviceopenstack-swift-object-replicator.serviceopenstack-swift-object-updater.service
9.6驗證
[root@comtroller1~]#echo"exportOS_AUTH_VERSION=3"|tee-aadmin-openrc.shdemo-openrc.sh [root@comtroller1~]#echo"exportOS_REGION_NAME=RegionOne"|tee-aadmin-openrc.shdemo-openrc.sh###解决错误/usr/lib/python2.7/site-packages/keystoneclient/service_catalog.py:196:UserWarning:Providingattrwithoutfilter_valuetoget_urls()isdeprecatedasofthe1.7.0releaseandmayberemovedinthe2.0.0release.Eitherbothshouldbeprovidedorneithershouldbeprovided. [root@comtroller1~]#.demo-openrc.sh [root@comtroller1~]#swiftstat##查看swift状态 Account:AUTH_db6bcde12cc947119ecab8c211fa4f35 Containers:1 Objects:1 Bytes:13287936 Containersinpolicy"policy-0":1 Objectsinpolicy"policy-0":1 Bytesinpolicy"policy-0":13287936 X-Account-Project-Domain-Id:default X-Timestamp:1470286741.05862 X-Trans-Id:txa608922c24224805bfd25-0057a2e160 Content-Type:text/plain;charset=utf-8 Accept-Ranges:bytes [root@comtroller1~]#swiftlist##查看swift中的容器 container1 [root@comtroller1~]#swiftlistcontainer1##查看swift容器中的对象 cirros-0.3.4-x86_64-disk.img [root@comtroller1~]#swiftdeletecontainer1cirros-0.3.4-x86_64-disk.img##删除容器中对象 cirros-0.3.4-x86_64-disk.img [root@comtroller1~]#swiftlistcontainer1 [root@comtroller1~]#swiftuploadcontainer1cirros-0.3.4-x86_64-disk.img##上传对象到容器 cirros-0.3.4-x86_64-disk.img [root@comtroller1~]#ls admin-openrc.shanaconda-ks.cfgcirros-0.3.4-x86_64-disk.imgdemo-openrc.sh--os-project-domain-id--os-project-nametoken [root@comtroller1~]#rmcirros-0.3.4-x86_64-disk.img rm:removeregularfile‘cirros-0.3.4-x86_64-disk.img’?y [root@comtroller1~]#swiftdownloadcontainer1cirros-0.3.4-x86_64-disk.img##从容器中下载对象 cirros-0.3.4-x86_64-disk.img[auth0.637s,headers0.682s,total1.000s,36.568MB/s] [root@comtroller1~]#ls admin-openrc.shanaconda-ks.cfgcirros-0.3.4-x86_64-disk.imgdemo-openrc.sh--os-project-domain-id--os-project-nametoken [root@comtroller1~]#swiftposttest_container##建立容器 [root@comtroller1~]#swiftlist container1 test_container [root@comtroller1~]#swiftdeletetest_container##删除容器 test_container [root@comtroller1~]#swiftlist container1原文链接:https://www.f2er.com/swift/323250.html