前置条件
- 核心组件已部署完成
- 计算节点有一块 未使用的整盘 作为对象存储,本文使用
/dev/sdc - Swift 存储节点管理网 IP:
11.0.1.40(计算节点)
Swift 采用 三步部署:计算节点初始化磁盘 → 控制节点创建 Ring 并启动 Proxy → 计算节点同步 Ring 并启动存储服务。
步骤一:计算节点初始化存储(compute)
1. 安装软件包
yum install -y xfsprogs rsync openstack-swift-account openstack-swift-container openstack-swift-object2. 格式化并挂载磁盘
mkfs.xfs -i size=1024 -f /dev/sdcmkdir -p /swift/node/sdcecho "/dev/sdc /swift/node/sdc xfs defaults,noatime,nodiratime 0 0" >> /etc/fstabmount /dev/sdc /swift/node/sdc3. 配置 rsync
写入 /etc/rsyncd.conf:
pid file = /var/run/rsyncd.pidlog file = /var/log/rsyncd.loguid = swiftgid = swiftaddress = 127.0.0.1[account]path = /swift/noderead only = falsewrite only = nolist = yesincoming chmod = 0644outgoing chmod = 0644max connections = 25lock file = /var/lock/account.lock[container]path = /swift/noderead only = falsewrite only = nolist = yesincoming chmod = 0644outgoing chmod = 0644max connections = 25lock file = /var/lock/container.lock[object]path = /swift/noderead only = falsewrite only = nolist = yesincoming chmod = 0644outgoing chmod = 0644max connections = 25lock file = /var/lock/object.lock[swift_server]path = /etc/swiftread only = truewrite only = nolist = yesincoming chmod = 0644outgoing chmod = 0644max connections = 5lock file = /var/lock/swift_server.locksystemctl enable rsyncdsystemctl restart rsyncd4. 配置存储服务
/etc/swift/account-server.conf:
[DEFAULT]bind_port = 6202user = swiftswift_dir = /etc/swiftdevices = /swift/nodemount_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#reconrecon_cache_path = /var/cache/swift/etc/swift/container-server.conf:
[DEFAULT]bind_port = 6201user = swiftswift_dir = /etc/swiftdevices = /swift/nodemount_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#reconrecon_cache_path = /var/cache/swift/etc/swift/object-server.conf:
[DEFAULT]bind_port = 6200user = swiftswift_dir = /etc/swiftdevices = /swift/nodemount_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#reconrecon_cache_path = /var/cache/swiftrecon_lock_path = /var/lock/etc/swift/swift.conf:
[swift-hash]swift_hash_path_suffix = changemeswift_hash_path_prefix = changeme[storage-policy:0]name = Policy-0default = yesaliases = yellow, orange[swift-constraints]chown -R swift:swift /swift/nodemkdir -p /var/cache/swiftchown -R root:swift /var/cache/swiftchmod -R 775 /var/cache/swiftchown -R root:swift /etc/swift
systemctl enable openstack-swift-account openstack-swift-account-auditor openstack-swift-account-reaper openstack-swift-account-replicatorsystemctl enable openstack-swift-container openstack-swift-container-auditor openstack-swift-container-replicator openstack-swift-container-updatersystemctl enable openstack-swift-object openstack-swift-object-auditor openstack-swift-object-replicator openstack-swift-object-updater此步暂不启动 Swift 存储服务,须等控制节点创建 Ring 后同步。
步骤二:控制节点 Proxy 与 Ring(controller)
source /etc/keystone/admin-openrc.shyum install -y openstack-swift-proxy python-swiftclient python-keystoneclient python-keystonemiddleware memcached1. 注册 Keystone
openstack user create --domain default --password 000000 swiftopenstack role add --project service --user swift adminopenstack service create --name swift --description "OpenStack Object Storage" object-storeopenstack endpoint create --region RegionOne object-store public http://controller:8080/v1/AUTH_%\(project_id\)sopenstack endpoint create --region RegionOne object-store internal http://controller:8080/v1/AUTH_%\(project_id\)sopenstack endpoint create --region RegionOne object-store admin http://controller:8080/v12. 配置 /etc/swift/proxy-server.conf
关键段落(完整文件见部署包):
[DEFAULT]bind_port = 8080user = swiftswift_dir = /etc/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[filter:authtoken]paste.filter_factory = keystonemiddleware.auth_token:filter_factorywww_authenticate_uri = http://controller:5000auth_url = http://controller:5000memcached_servers = controller:11211auth_type = passwordproject_domain_name = defaultuser_domain_name = defaultproject_name = serviceusername = swiftpassword = 000000delay_auth_decision = True[filter:keystoneauth]use = egg:swift#keystoneauthoperator_roles = admin,user[filter:cache]use = egg:swift#memcachememcache_servers = controller:112113. 创建 Ring
cd /etc/swift
swift-ring-builder account.builder create 18 1 1swift-ring-builder account.builder add --region 1 --zone 1 --ip 11.0.1.40 --port 6202 --device sdc --weight 100swift-ring-builder account.builder rebalance
swift-ring-builder container.builder create 10 1 1swift-ring-builder container.builder add --region 1 --zone 1 --ip 11.0.1.40 --port 6201 --device sdc --weight 100swift-ring-builder container.builder rebalance
swift-ring-builder object.builder create 10 1 1swift-ring-builder object.builder add --region 1 --zone 1 --ip 11.0.1.40 --port 6200 --device sdc --weight 100swift-ring-builder object.builder rebalance4. 配置 /etc/swift/swift.conf 并启动 Proxy
chown -R root:swift /etc/swiftsystemctl enable openstack-swift-proxy memcachedsystemctl restart openstack-swift-proxy memcached步骤三:计算节点同步 Ring 并启动(compute)
scp controller:/etc/swift/*.ring.gz /etc/swift/chown root:swift /etc/swift/*.ring.gz
systemctl restart openstack-swift-account openstack-swift-account-auditor openstack-swift-account-reaper openstack-swift-account-replicatorsystemctl restart openstack-swift-container openstack-swift-container-auditor openstack-swift-container-replicator openstack-swift-container-updatersystemctl restart openstack-swift-object openstack-swift-object-auditor openstack-swift-object-replicator openstack-swift-object-updater验收
# 计算节点lsblk /dev/sdcsystemctl is-active openstack-swift-account openstack-swift-container openstack-swift-object
# 控制节点ls /etc/swift/*.ring.gzsource /etc/keystone/admin-openrc.shopenstack service list | grep swiftswift stat