您好,登錄后才能下訂單哦!
環(huán)境如下圖所示:
IP:192.168.0.111 controller
IP:192.168.0.112 compute
IP:192.168.0.113 object1
IP:192.168.0.117 object2
IP:192.168.0.118 cinder
1.在控制節(jié)點上安裝 swift服務
[root@controller ~]# source admin-openrc
創(chuàng)建swift用戶
[root@controller ~]# openstack user create --domain default --password-prompt swift
[root@controller ~]# openstack role add --project service --user swift admin
創(chuàng)建swift服務
[root@controller ~]# openstack service create --name swift --description "OpenStack Object Storage" object-store
創(chuàng)建對象存儲服務API端點:
[root@controller ~]# openstack endpoint create --region RegionOne \
object-store public http://controller:8080/v1/AUTH_%\(tenant_id\)s
[root@controller ~]# openstack endpoint create --region RegionOne \
object-store internal http://controller:8080/v1/AUTH_%\(tenant_id\)s
[root@controller ~]# openstack endpoint create --region RegionOne \
object-store admin http://controller:8080/v1
安裝服務包
[root@controller ~]# yum install openstack-swift-proxy python-swiftclient python-keystoneclient python-keystonemiddleware memcached
拷貝proxy-server.conf配置文件到/etc/swift/目錄下面
[root@controller swift]# vim /etc/swift/proxy-server.conf
[DEFAULT]
bind_port = 8080
swift_dir = /etc/swift
user = swift
[pipeline:main] (刪除tempurl和tempauth,添加authtoken和keystoneauth模塊)
pipeline = catch_errors gatekeeper healthcheck proxy-logging cache container_sync bulk ratelimit authtoken keystoneauth copy container-quotas account-quotas slo dlo versioned_writes proxy-logging proxy-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://controller:5000
auth_url = http://controller:35357
memcached_servers = controller:11211
auth_type = password
project_domain_id = default
user_domain_id = default
project_name = service
username = swift
password = devops
delay_auth_decision = True
[filter:cache]
use = egg:swift#memcache
memcache_servers = controller:11211
2.安裝和配置存儲節(jié)點分別為object1和object2在兩個節(jié)點上分別進行一下操作,并且在存儲節(jié)點上分別各有兩塊硬盤,分別為sdb和sdc
安裝xfsprogs rsync服務
[root@object1 ~]# ifconfig | head -2
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.0.113 netmask 255.255.255.0 broadcast 192.168.0.255
[root@object1 ~]# yum -y install xfsprogs rsync
格式化sdb和sdc設備
[root@object1 ~]# mkfs.xfs /dev/sdb
[root@object1 ~]# mkfs.xfs /dev/sdc
創(chuàng)建安裝點目錄結(jié)構(gòu)
[root@object1 ~]# mkdir -p /srv/node/sdb
[root@object1 ~]# mkdir -p /srv/node/sdc
編輯/etc/fstab文件并添加一下內(nèi)容
[root@object1 ~]# cat /etc/fstab | tail -2
/dev/sdb /srv/node/sdb xfs noatime,nodiratime,nobarrier,logbufs=8 0 2
/dev/sdc /srv/node/sdc xfs noatime,nodiratime,nobarrier,logbufs=8 0 2
掛載設備
[root@object1 ~]# mount /srv/node/sdb/
[root@object1 ~]# mount /srv/node/sdc
[root@object1 ~]# vim /etc/rsyncd.conf
uid = swift
gid = swift
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
address = 192.168.0.113
[account]
max connections = 2
path = /srv/node/
read only = False
lock file = /var/lock/account.lock
[container]
max connections = 2
path = /srv/node/
read only = False
lock file = /var/lock/container.lock
[object]
max connections = 2
path = /srv/node/
read only = False
lock file = /var/lock/object.lock
啟動rsyncd服務
[root@object1 ~]# systemctl enable rsyncd.service
[root@object1 ~]# systemctl start rsyncd.service
[root@object1 ~]# systemctl status rsyncd.service
安裝和配置組件
[root@object1 ~]# yum install openstack-swift-account openstack-swift-container openstack-swift-object
[root@object1 ~]# curl -o /etc/swift/account-server.conf https://git.openstack.org/cgit/openstack/swift/plain/etc/account-server.conf-sample?h=stable/newton
[root@object1 ~]# curl -o /etc/swift/container-server.conf https://git.openstack.org/cgit/openstack/swift/plain/etc/container-server.conf-sample?h=stable/newton
[root@object1 ~]# curl -o /etc/swift/object-server.conf https://git.openstack.org/cgit/openstack/swift/plain/etc/object-server.conf-sample?h=stable/newton
[root@object1 ~]# vim /etc/swift/account-server.conf
[DEFAULT]
bind_ip =192.168.0.113
bind_port = 6202
user = swift
swift_dir = /etc/swift
devices = /srv/node
mount_check = true
[pipeline:main]
pipeline = healthcheck recon account-server
[filter:recon]
use = egg:swift#recon
recon_cache_path = /var/cache/swift
[root@object1 ~]# vim /etc/swift/container-server.conf
[DEFAULT]
bind_ip = 192.168.0.113
bind_port = 6201
user = swift
swift_dir = /etc/swift
devices = /srv/node
mount_check = true
[pipeline:main]
pipeline = healthcheck recon container-server
[filter:recon]
use = egg:swift#recon
recon_cache_path = /var/cache/swift
[root@object1 ~]# vim /etc/swift/object-server.conf
[DEFAULT]
bind_ip = 192.168.0.113
bind_port = 6200
user = swift
swift_dir = /etc/swift
devices = /srv/node
mount_check = true
[pipeline:main]
pipeline = healthcheck recon object-server
[filter:recon]
use = egg:swift#recon
recon_cache_path = /var/cache/swift
recon_lockpath = /var/lock
[root@object1 ~]# chown -R swift:swift /srv/node
[root@object1 ~]# chown -R root:swift /var/cache/swift/
[root@object1 ~]# chmod -R 755 /var/cache/swift/
同理在object2上同上操作,配置文件中修改IP地址的IP就可以。
[root@object2 ~]# systemctl enable rsyncd.service
[root@object2 ~]# systemctl start rsyncd.service
[root@object2 ~]# systemctl status rsyncd.service
3.創(chuàng)建和分發(fā)初始環(huán)在控制節(jié)點上執(zhí)行一下步驟
創(chuàng)建賬號
切換到/etc/swift目錄下面
[root@controller ~]# cd /etc/swift/
[root@controller swift]# swift-ring-builder account.builder create 10 3 1
添加存儲節(jié)點
[root@controller swift]# swift-ring-builder account.builder add --region 1 --zone 1 --ip 192.168.0.113 --port 6202 --device sdb --weight 100
Device d0r1z1-192.168.0.113:6202R192.168.0.113:6202/sdb"" with 100.0 weight got id 0
You have mail in /var/spool/mail/root
[root@controller swift]# swift-ring-builder account.builder add --region 1 --zone 1 --ip 192.168.0.113 --port 6202 --device sdc --weight 100
Device d1r1z1-192.168.0.113:6202R192.168.0.113:6202/sdc"" with 100.0 weight got id 1
[root@controller swift]# swift-ring-builder account.builder add --region 1 --zone 2 --ip 192.168.0.117 --port 6202 --device sdb --weight 100
Device d2r1z2-192.168.0.117:6202R192.168.0.117:6202/sdb"" with 100.0 weight got id 2
[root@controller swift]# swift-ring-builder account.builder add --region 1 --zone 2 --ip 192.168.0.117 --port 6202 --device sdc --weight 100
Device d3r1z2-192.168.0.117:6202R192.168.0.117:6202/sdc_"" with 100.0 weight got id 3
[root@controller swift]# swift-ring-builder account.builder
account.builder, build version 4
1024 partitions, 3.000000 replicas, 1 regions, 2 zones, 4 devices, 100.00 balance, 0.00 dispersion
The minimum number of hours before a partition can be reassigned is 1 (0:00:00 remaining)
The overload factor is 0.00% (0.000000)
Ring file account.ring.gz not found, probably it hasn't been written yet
Devices: id region zone ip address:port replication ip:port name weight partitions balance flags meta
0 1 1 192.168.0.113:6202 192.168.0.113:6202 sdb 100.00 0 -100.00
1 1 1 192.168.0.113:6202 192.168.0.113:6202 sdc 100.00 0 -100.00
2 1 2 192.168.0.117:6202 192.168.0.117:6202 sdb 100.00 0 -100.00
3 1 2 192.168.0.117:6202 192.168.0.117:6202 sdc 100.00 0 -100.00
[root@controller swift]# swift-ring-builder account.builder rebalance
Reassigned 3072 (300.00%) partitions. Balance is now 0.00. Dispersion is now 0.00
[root@controller swift]# swift-ring-builder container.builder create 10 3 1
[root@controller swift]# swift-ring-builder container.builder add --region 1 --zone 1 --ip 192.168.0.113 --port 6201 --device sdb --weight 100
Device d0r1z1-192.168.0.113:6201R192.168.0.113:6201/sdb"" with 100.0 weight got id 0
[root@controller swift]# swift-ring-builder container.builder add --region 1 --zone 1 --ip 192.168.0.113 --port 6201 --device sdc --weight 100
Device d1r1z1-192.168.0.113:6201R192.168.0.113:6201/sdc"" with 100.0 weight got id 1
[root@controller swift]# swift-ring-builder container.builder add --region 1 --zone 2 --ip 192.168.0.117 --port 6201 --device sdb --weight 100
Device d2r1z2-192.168.0.117:6201R192.168.0.117:6201/sdb"" with 100.0 weight got id 2
[root@controller swift]# swift-ring-builder container.builder add --region 1 --zone 2 --ip 192.168.0.117 --port 6201 --device sdc --weight 100
Device d3r1z2-192.168.0.117:6201R192.168.0.117:6201/sdc"" with 100.0 weight got id 3
[root@controller swift]# swift-ring-builder container.builder
container.builder, build version 4
1024 partitions, 3.000000 replicas, 1 regions, 2 zones, 4 devices, 100.00 balance, 0.00 dispersion
The minimum number of hours before a partition can be reassigned is 1 (0:00:00 remaining)
The overload factor is 0.00% (0.000000)
Ring file container.ring.gz not found, probably it hasn't been written yet
Devices: id region zone ip address:port replication ip:port name weight partitions balance flags meta
0 1 1 192.168.0.113:6201 192.168.0.113:6201 sdb 100.00 0 -100.00
1 1 1 192.168.0.113:6201 192.168.0.113:6201 sdc 100.00 0 -100.00
2 1 2 192.168.0.117:6201 192.168.0.117:6201 sdb 100.00 0 -100.00
3 1 2 192.168.0.117:6201 192.168.0.117:6201 sdc 100.00 0 -100.00
[root@controller swift]# swift-ring-builder container.builder rebalance
Reassigned 3072 (300.00%) partitions. Balance is now 0.00. Dispersion is now 0.00
[root@controller swift]# swift-ring-builder object.builder create 10 3 1
[root@controller swift]# swift-ring-builder object.builder add --region 1 --zone 1 --ip 192.168.0.113 --port 6200 --device sdb --weight 100
Device d0r1z1-192.168.0.113:6200R192.168.0.113:6200/sdb"" with 100.0 weight got id 0
[root@controller swift]# swift-ring-builder object.builder add --region 1 --zone 1 --ip 192.168.0.113 --port 6200 --device sdc --weight 100
Device d1r1z1-192.168.0.113:6200R192.168.0.113:6200/sdc"" with 100.0 weight got id 1
[root@controller swift]# swift-ring-builder object.builder add --region 1 --zone 2 --ip 192.168.0.117 --port 6200 --device sdb --weight 100
Device d2r1z2-192.168.0.117:6200R192.168.0.117:6200/sdb"" with 100.0 weight got id 2
[root@controller swift]# swift-ring-builder object.builder add --region 1 --zone 2 --ip 192.168.0.117 --port 6200 --device sdc --weight 100
Device d3r1z2-192.168.0.117:6200R192.168.0.117:6200/sdc"" with 100.0 weight got id 3
[root@controller swift]# swift-ring-builder object.builder
object.builder, build version 4
1024 partitions, 3.000000 replicas, 1 regions, 2 zones, 4 devices, 100.00 balance, 0.00 dispersion
The minimum number of hours before a partition can be reassigned is 1 (0:00:00 remaining)
The overload factor is 0.00% (0.000000)
Ring file object.ring.gz not found, probably it hasn't been written yet
Devices: id region zone ip address:port replication ip:port name weight partitions balance flags meta
0 1 1 192.168.0.113:6200 192.168.0.113:6200 sdb 100.00 0 -100.00
1 1 1 192.168.0.113:6200 192.168.0.113:6200 sdc 100.00 0 -100.00
2 1 2 192.168.0.117:6200 192.168.0.117:6200 sdb 100.00 0 -100.00
3 1 2 192.168.0.117:6200 192.168.0.117:6200 sdc 100.00 0 -100.00
[root@controller swift]# swift-ring-builder object.builder rebalance
Reassigned 3072 (300.00%) partitions. Balance is now 0.00. Dispersion is now 0.00
下載controller 中/etc/swift目錄下account.ring.gz container.ring.gz object.ring.gz放到各個存儲節(jié)點上/etc/swift/目錄下面
4.在controller控制節(jié)點上下載和配置swift.conf配置文件
[root@controller swift]# curl -o /etc/swift/swift.conf https://git.openstack.org/cgit/openstack/swift/plain/etc/swift.conf-sample?h=stable/newton
[root@controller swift]# vim /etc/swift/swift.conf
[swift-hash]
swift_hash_path_suffix = openstack
swift_hash_path_prefix = openstack
[storage-policy:0]
name = Policy-0
default = yes
下載swift.conf配置文件到各個存儲節(jié)點上
過程省略。。。。。。。。。。。。。。。。。。。
[root@controller swift]# chown -R root:swift /etc/swift/
[root@controller swift]# systemctl enable openstack-swift-proxy.service memcached.service
[root@controller swift]# systemctl start openstack-swift-proxy.service memcached.service
[root@controller swift]# systemctl status openstack-swift-proxy.service memcached.service
5.在存儲節(jié)點上啟動swift服務
[root@object1 swift]# systemctl enable openstack-swift-account.service openstack-swift-account-auditor.service openstack-swift-account-reaper.service openstack-swift-account-replicator.service
[root@object1 swift]# systemctl start openstack-swift-account.service openstack-swift-account-auditor.service openstack-swift-account-reaper.service openstack-swift-account-replicator.service
[root@object1 swift]# systemctl status openstack-swift-account.service openstack-swift-account-auditor.service openstack-swift-account-reaper.service openstack-swift-account-replicator.service
[root@object1 swift]# systemctl enable openstack-swift-container.service openstack-swift-container-auditor.service openstack-swift-container-replicator.service openstack-swift-container-updater.service
[root@object1 swift]# systemctl start openstack-swift-container.service openstack-swift-container-auditor.service openstack-swift-container-replicator.service openstack-swift-container-updater.service
[root@object1 swift]# systemctl status openstack-swift-container.service openstack-swift-container-auditor.service openstack-swift-container-replicator.service openstack-swift-container-updater.service
[root@object1 swift]# systemctl enable openstack-swift-object.service openstack-swift-object-auditor.service openstack-swift-object-replicator.service openstack-swift-object-updater.service
[root@object1 swift]# systemctl start openstack-swift-object.service openstack-swift-object-auditor.service openstack-swift-object-replicator.service openstack-swift-object-updater.service
[root@object1 swift]# systemctl status openstack-swift-object.service openstack-swift-object-auditor.service openstack-swift-object-replicator.service openstack-swift-object-updater.service
5.驗證
在controller主節(jié)點上操作
[root@controller ~]# cat demo-openrc
export OS_USER_DOMAIN_ID=default
export OS_PROJECT_DOMAIN_ID=default
export OS_USERNAME=demo
export OS_PROJECT_NAME=demo
export OS_PASSWORD=devops
export OS_IDENTITY_API_VERSION=3
export OS_IMAGE_API_VERSION=2
export OS_AUTH_URL=http://controller:5000/v3
[root@controller ~]# source /root/demo-openrc
顯示服務狀態(tài)
[root@controller ~]# swift stat
創(chuàng)建container1容器
[root@controller ~]# openstack container create container1
將測試文件上傳到container1容器:
[root@controller ~]# openstack object create container1 admin-openrc
[root@controller ~]# openstack objecct list container1
[root@controller ~]# openstack object save container1 admin-openrc
所有的配置文件在百度云盤中:
鏈接:https://pan.baidu.com/s/1CnmKkFMTemv199ctgb5Oig
提取碼:27om
復制這段內(nèi)容后打開百度網(wǎng)盤手機App,操作更方便哦
免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。