记录,方便查阅。
只做部分解释
keystone user-create --name swift --pass swift keystone user-role-add --user swift --tenant service --role admin keystone service-create --name swift --type object-store --description "OpenStack Object Storage" keystone endpoint-create \ --service-id $(keystone service-list | awk '/ object-store / {print $2}') \ --publicurl 'http://controller:8080/v1/AUTH_%(tenant_id)s' \ --internalurl 'http://controller:8080/v1/AUTH_%(tenant_id)s' \ --adminurl http://controller:8080 \ --region regionOne
yum install openstack-swift-proxy python-swiftclient python-keystone-auth-token python-keystonemiddleware memcached -y
从github获取配置文件
curl -o /etc/swift/proxy-server.conf https://raw.githubusercontent.com/openstack/swift/stable/juno/etc/proxy-server.conf-sample
/etc/swift/proxy-server.conf
[DEFAULT] bind_port = 8080 user = swift swift_dir = /etc/swift
[pipeline:main] pipeline = authtoken cache healthcheck keystoneauth proxy-logging proxy-server
[app:proxy-server] allow_account_management = true account_autocreate = true
[filter:keystoneauth] use = egg:swift#keystoneauth operator_roles = admin,_member_ #用户管理,以及使用的用户
[filter:authtoken] paste.filter_factory = keystonemiddleware.auth_token:filter_factory auth_uri = http://controller:5000/v2.0 identity_uri = http://controller:35357 admin_tenant_name = service admin_user = swift admin_password = swift delay_auth_decision = true
[filter:cache] memcache_servers = 127.0.0.1:11211
包含2块块设备,添加2块硬盘,sdb、sdc
fdisk 分区sdb1、sdc1
yum install xfsprogs rsync
mkfs.xfs /dev/sdb1 #文件系统推荐xfs mkfs.xfs /dev/sdc1 mkdir -p /srv/node/sdb1 #创建挂载点 mkdir -p /srv/node/sdc1
/etc/fstab 启动自动挂载点
/dev/sdb1 /srv/node/sdb1 xfs noatime,nodiratime,nobarrier,logbufs=8 0 2 /dev/sdc1 /srv/node/sdc1 xfs noatime,nodiratime,nobarrier,logbufs=8 0 2
mount -a #读取配置文件并挂载 mount /srv/node/sdb1 mount /srv/node/sdc1
/etc/rsyncd.conf 同步服务
uid = swift gid = swift log file = /var/log/rsyncd.log pid file = /var/run/rsyncd.pid address = 192.168.23.12 [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
yum install openstack-swift-account openstack-swift-container openstack-swift-object -y
获取account、container、object配置文件:
curl -o /etc/swift/account-server.conf https://raw.githubusercontent.com/openstack/swift/stable/juno/etc/account-server.conf-sample curl -o /etc/swift/container-server.conf https://raw.githubusercontent.com/openstack/swift/stable/juno/etc/container-server.conf-sample curl -o /etc/swift/object-server.conf https://raw.githubusercontent.com/openstack/swift/stable/juno/etc/object-server.conf-sample
/etc/swift/account-server.conf
[DEFAULT] ... bind_ip = 192.168.23.11 bind_port = 6002 user = swift swift_dir = /etc/swift devices = /srv/node [pipeline:main] pipeline = healthcheck recon account-server
[filter:recon] recon_cache_path = /var/cache/swift
/etc/swift/container-server.conf
[DEFAULT] bind_ip = 192.168.23.11 bind_port = 6001 user = swift swift_dir = /etc/swift devices = /srv/node
[pipeline:main] pipeline = healthcheck recon container-server
[filter:recon] recon_cache_path = /var/cache/swift
/etc/swift/object-server.conf
[DEFAULT] bind_ip = 192.168.23.11 bind_port = 6001 user = swift swift_dir = /etc/swift devices = /srv/node
[pipeline:main] pipeline = healthcheck recon container-server
[filter:recon] recon_cache_path = /var/cache/swift
文件夹权限:
chown -R swift:swift /srv/node mkdir -p /var/cache/swift chown -R swift:swift /var/cache/swift
cd /etc/swift 创建环
swift-ring-builder account.builder create 10 3 1 swift-ring-builder account.builder add r1z1-192.168.23.12:6002/sdb1 100 #添加存储区 swift-ring-builder account.builder add r1z1-192.168.23.12:6002/sdc1 100 swift-ring-builder account.builder #查看环 swift-ring-builder account.builder rebalance #负载均衡环 swift-ring-builder container.builder create 10 3 1 swift-ring-builder container.builder add r1z1-192.168.23.12:6001/sdb1 100 swift-ring-builder container.builder add r1z1-192.168.23.12:6001/sdc1 100 swift-ring-builder container.builder swift-ring-builder container.builder rebalance swift-ring-builder object.builder create 10 3 1 swift-ring-builder object.builder add r1z1-192.168.23.12:6000/sdb1 100 swift-ring-builder object.builder add r1z1-192.168.23.12:6000/sdc1 100 swift-ring-builder object.builder swift-ring-builder object.builder rebalance
Copy the account.ring.gz, container.ring.gz, and object.ring.gz files to the /etc/swift directory on each storage node and any additional nodes running the proxy service.
scp -r account.ring.gz container.ring.gz object.ring.gz root@192.168.23.12:/etc/swift/
curl -o /etc/swift/swift.conf https://raw.githubusercontent.com/openstack/swift/stable/juno/etc/swift.conf-sample #swift.conf
[swift-hash] swift_hash_path_suffix = yippee #HASH前缀
swift_hash_path_prefix = yippee #HASH后缀
[storage-policy:0] name = Policy-0 default = yes
Copy the swift.conf file to the /etc/swift directory on each storage node and any additional nodes running the proxy service.
scp -r swift.conf object.ring.gz root@192.168.23.12:/etc/swift/
文件夹权限:
chown -R swift:swift /etc/swift
On the controller node and any other nodes running the proxy service
systemctl enable openstack-swift-proxy.service memcached.service
systemctl start openstack-swift-proxy.service memcached.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-account.service openstack-swift-account-auditor.service openstack-swift-account-reaper.service openstack-swift-account-replicator.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-container.service openstack-swift-container-auditor.service openstack-swift-container-replicator.service openstack-swift-container-updater.service systemctl enable openstack-swift-object.service openstack-swift-object-auditor.service openstack-swift-object-replicator.service openstack-swift-object-updater.service systemctl start openstack-swift-object.service openstack-swift-object-auditor.service openstack-swift-object-replicator.service openstack-swift-object-updater.service
重启时出现无法创建容器问题以及容器不见了的问题,三个服务未启动,端口被占用;
swift-init all start netstat –tnlp kill -9 xxx #删除对应pid swift init all restart
至此,swift安装完成。