# . /root/admin-openrc # openstack user create --domain default --password 000000 swift # openstack role add --project service --user swift admin #openstack service create --name swift --description "OpenStack Object Storage" object-store
# openstack endpoint create --region RegionOne object-store public http://controller:8080/v1/AUTH_%\(tenant_id\)s # openstack endpoint create --region RegionOne object-store internal http://controller:8080/v1/AUTH_%\(tenant_id\)s # openstack endpoint create --region RegionOne object-store admin http://controller:8080/v1
[root@controller ~]# yum -y install openstack-swift-proxy python-swiftclient python-keystoneclient python-keystonemiddleware memcachednode
刪除原有內容
,直接添加以下內容# vi /etc/swift/proxy-server.conf [DEFAULT] bind_port = 8080 swift_dir = /etc/swift user = swift [pipeline:main] pipeline = catch_errors gatekeeper healthcheck proxy-logging cache container_sync bulk ratelimit authtoken keystoneauth container-quotas account-quotas slo dlo versioned_writes proxy-logging proxy-server [app:proxy-server] use = egg:swift#proxy account_autocreate = True [filter:tempauth] use = egg:swift#tempauth user_admin_admin = admin .admin .reseller_admin user_test_tester = testing .admin user_test2_tester2 = testing2 .admin user_test_tester3 = testing3 user_test5_tester5 = testing5 service [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_name = default user_domain_name = default project_name = service username = swift password = 000000 delay_auth_decision = True [filter:keystoneauth] use = egg:swift#keystoneauth operator_roles = admin,user [filter:healthcheck] use = egg:swift#healthcheck [filter:cache] memcache_servers = controller:11211 use = egg:swift#memcache [filter:ratelimit] use = egg:swift#ratelimit [filter:domain_remap] use = egg:swift#domain_remap [filter:catch_errors] use = egg:swift#catch_errors [filter:cname_lookup] use = egg:swift#cname_lookup [filter:staticweb] use = egg:swift#staticweb [filter:tempurl] use = egg:swift#tempurl [filter:formpost] use = egg:swift#formpost [filter:name_check] use = egg:swift#name_check [filter:list-endpoints] use = egg:swift#list_endpoints [filter:proxy-logging] use = egg:swift#proxy_logging [filter:bulk] use = egg:swift#bulk [filter:slo] use = egg:swift#slo [filter:dlo] use = egg:swift#dlo [filter:container-quotas] use = egg:swift#container_quotas [filter:account-quotas] use = egg:swift#account_quotas [filter:gatekeeper] use = egg:swift#gatekeeper [filter:container_sync] use = egg:swift#container_sync [filter:xprofile] use = egg:swift#xprofile [filter:versioned_writes] use = egg:swift#versioned_writes
刪除原有內容
,添加以下內容# vi /etc/swift/swift.conf [swift-hash] swift_hash_path_suffix = changeme swift_hash_path_prefix = changeme [storage-policy:0] name = Policy-0 default = yes aliases = yellow, orange [swift-constraints]
添加權限 # chown -R root:swift /etc/swift
[root@compute ~]# yum -y install xfsprogs rsync openstack-swift-account openstack-swift-container openstack-swift-object
/dev/sdb
和/dev/sdc
設備搭建Swift存儲節點須要一塊空盤,此處咱們查看添加的空盤python
# lsblk
建立分區web
# fdisk /dev/sdc
# mkfs.xfs /dev/sdc1
[root@compute ~]# mkdir -p /swift/node
/etc/fstab
文件並添加如下內容# vi /etc/fstab /dev/sdc1 /swift/node xfs noatime,nodiratime,nobarrier,logbufs=8 0 0
[root@compute ~]# mount /dev/sdc1 /swift/node/
/etc/rsyncd.conf
文件並添加如下內容[root@compute ~]#vi /etc/rsyncd.conf pid file = /var/run/rsyncd.pid log file = /var/log/rsyncd.log uid = swift gid = swift address = 127.0.0.1 [account] path = /swift/node read only = false write only = no list = yes incoming chmod = 0644 outgoing chmod = 0644 max connections = 25 lock file = /var/lock/account.lock [container] path = /swift/node read only = false write only = no list = yes incoming chmod = 0644 outgoing chmod = 0644 max connections = 25 lock file = /var/lock/container.lock [object] path = /swift/node read only = false write only = no list = yes incoming chmod = 0644 outgoing chmod = 0644 max connections = 25 lock file = /var/lock/object.lock [swift_server] path = /etc/swift read only = true write only = no list = yes incoming chmod = 0644 outgoing chmod = 0644 max connections = 5 lock file = /var/lock/swift_server.lock
# systemctl start rsyncd.service # systemctl enable rsyncd.service
#vi /etc/swift/account-server.conf [DEFAULT] bind_port = 6002 user = swift swift_dir = /etc/swift devices = /swift/node mount_check = false [pipeline:main] pipeline = healthcheck recon account-server [app:account-server] use = egg:swift#account [filter:healthcheck] use = egg:swift#healthcheck [filter:recon] use = egg:swift#recon recon_cache_path = /var/cache/swift [account-replicator] [account-auditor] [account-reaper] [filter:xprofile] use = egg:swift#xprofile
/etc/swift/container-server.conf
文件,刪除原有內容,直接添加如下內容:# vi /etc/swift/container-server.conf [DEFAULT] bind_port = 6001 user = swift swift_dir = /etc/swift devices = /swift/node mount_check = false [pipeline:main] pipeline = healthcheck recon container-server [app:container-server] use = egg:swift#container [filter:healthcheck] use = egg:swift#healthcheck [filter:recon] use = egg:swift#recon recon_cache_path = /var/cache/swift [container-replicator] [container-updater] [container-auditor] [container-sync] [filter:xprofile] use = egg:swift#xprofile
/etc/swift/object-server.conf
文件,刪除原有內容,直接添加如下內容:# vi /etc/swift/object-server.conf [DEFAULT] bind_port = 6000 user = swift swift_dir = /etc/swift devices = /swift/node mount_check = false [pipeline:main] pipeline = healthcheck recon object-server [app:object-server] use = egg:swift#object [filter:healthcheck] use = egg:swift#healthcheck [filter:recon] use = egg:swift#recon recon_cache_path = /var/cache/swift recon_lock_path = /var/lock [object-replicator] [object-reconstructor] [object-updater] [object-auditor] [filter:xprofile] use = egg:swift#xprofile
# vi /etc/swift/swift.conf [swift-hash] swift_hash_path_suffix = changeme swift_hash_path_prefix = changeme [storage-policy:0] name = Policy-0 default = yes aliases = yellow, orange [swift-constraints]
# chown -R swift:swift /swift/node
# mkdir -p /var/cache/swift # chown -R root:swift /var/cache/swift # chmod -R 775 /var/cache/swift # chown -R root:swift /etc/swift
1.切換到 ``/etc/swift``目錄。建立基本 account.builder 文件: # cd /etc/swift # swift-ring-builder account.builder create 18 1 1 2.添加每一個節點到 ring 中: # swift-ring-builder account.builder add --region 1 --zone 1 --ip 192.168.100.20 --port 6002 --device sdc1 --weight 100 3.驗證ring內容 # swift-ring-builder account.builder 4.平衡ring # swift-ring-builder account.builder rebalance
1.切換到 ``/etc/swift``目錄。建立基本``container.builder``文件: # cd /etc/swift # swift-ring-builder container.builder create 10 1 1 2.添加每一個節點到 ring 中: # swift-ring-builder container.builder add --region 1 --zone 1 --ip 192.168.100.20 --port 6001 --device sdc1 --weight 100 3.驗證 ring 的內容: # swift-ring-builder container.builder 4.平衡 ring: # swift-ring-builder container.builder rebalance
1.切換到 ``/etc/swift``目錄。建立基本``object.builder``文件: # swift-ring-builder object.builder create 10 1 1 2.添加每一個節點到 ring 中: # swift-ring-builder object.builder add --region 1 --zone 1 --ip 192.168.100.20 --port 6000 --device sdc1 --weight 100 3.驗證 ring 的內容: # swift-ring-builder object.builder 4.平衡 ring: # swift-ring-builder object.builder rebalance
複製``account.ring.gz``,container.ring.gz``和``object.ring.gz 文件到每一個存儲節點和其餘運行了代理服務的額外節點的 /etc/swift 目錄。 [root@compute ~]# scp controller:/etc/swift/*.ring.gz /etc/swift/
Controller
上,啓動對象存儲代理服務及其依賴服務,並將它們配置爲隨系統啓動:# systemctl start openstack-swift-proxy.service memcached.service # systemctl enable openstack-swift-proxy.service memcached.service
Compute
上,啓動對象存儲服務,並將其設置爲隨系統啓動# systemctl start openstack-swift-account.service openstack-swift-account-auditor.service openstack-swift-account-reaper.service openstack-swift-account-replicator.service # systemctl enable openstack-swift-account.service openstack-swift-account-auditor.service openstack-swift-account-reaper.service openstack-swift-account-replicator.service # systemctl start openstack-swift-container.service openstack-swift-container-auditor.service openstack-swift-container-replicator.service openstack-swift-container-updater.service # systemctl enable openstack-swift-container.service openstack-swift-container-auditor.service openstack-swift-container-replicator.service openstack-swift-container-updater.service # systemctl start openstack-swift-object.service openstack-swift-object-auditor.service openstack-swift-object-replicator.service openstack-swift-object-updater.service # systemctl enable openstack-swift-object.service openstack-swift-object-auditor.service openstack-swift-object-replicator.service openstack-swift-object-updater.service
# . /root/demo-openrc
# swift stat
# openstack container create container1
container1
容器# openstack object create container1 /root/demo-openrc
container1
容器裏的全部文件# openstack object list container1
container1
容器裏下載一個測試文件# openstack object save container1 /root/demo-openrc