当前位置: 代码迷 >> 综合 >> OpenStack Swift服务安装脚本
  详细解决方案

OpenStack Swift服务安装脚本

热度:0   发布时间:2023-12-09 03:46:46.0

Controller

#!/bin/shinstall_swift(){
    set -o errexitset -x	readonly passwd=openstackreadonly controller_ip=172.16.199.11readonly compute_ip=172.16.199.31	#服务证书和端点source ./admin-openrc#创建swift useropenstack user create --domain default --password $passwd swift#siwft用户添加admin角色openstack role add --project service --user swift admin#创建swift服务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\)sopenstack 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#安装swift(echo 'y')|apt-get install swift swift-proxy python-swiftclient python-keystonemiddleware python-memcache#创建swift配置目录mkdir /etc/swiftmv proxy-server.conf /etc/swift#/etc/swift/swift.confecho "[swift-hash]swift_hash_path_suffix = swift_shared_pathswift_hash_path_prefix = swift_shared_path" >> /etc/swift/swift.confsed -i 's/^[\t]*//g' /etc/swift/swift.confchown -R swift. /etc/swift#create ringsswift-ring-builder /etc/swift/account.builder create 12 2 1 swift-ring-builder /etc/swift/container.builder create 12 2 1 swift-ring-builder /etc/swift/object.builder create 12 2 1#添加存储节点swift-ring-builder /etc/swift/account.builder add r0z0-$controller_ip:6002/device0 100swift-ring-builder /etc/swift/container.builder add r0z0-$controller_ip:6001/device0 100 swift-ring-builder /etc/swift/object.builder add r0z0-$controller_ip:6000/device0 100swift-ring-builder /etc/swift/account.builder add r1z1-$compute_ip:6002/device1 100 swift-ring-builder /etc/swift/container.builder add r1z1-$compute_ip:6001/device1 100 swift-ring-builder /etc/swift/object.builder add r1z1-$compute_ip:6000/device1 100#平衡存储swift-ring-builder /etc/swift/account.builder rebalanceswift-ring-builder /etc/swift/container.builder rebalance swift-ring-builder /etc/swift/object.builder rebalance#更改权限chown swift. /etc/swift/*.gz#重启swift-proxysystemctl restart swift-proxy#控制节点安装swift#安装组件(echo 'y')|apt-get install swift swift-account swift-container swift-object xfsprogs#Using a loopback device for storage#创建文件truncate -s 1GB /srv/swift-disk#格式化文件mkfs.xfs /srv/swift-disk#创建device0目录mkdir -p /srv/node/device0#挂载/srv/swift-disk到device0mount -o noatime,nodiratime,nobarrier /srv/swift-disk /srv/node/device0#修改权限chown -R swift. /srv/node#设置开机挂载sed -i '$a\ /srv/swift-disk /srv/node/device0 xfs noatime,nodiratime,nobarrier 0 0' /etc/fstab#修改权限chown swift. /etc/swift/*.gz#/etc/swift/account-server.confsed -i "2s/^bind_ip\s.*/bind_ip = 0.0.0.0/" /etc/swift/account-server.confhead -n 2 /etc/swift/account-server.conf | tail -n 1sed -i "3s/^bind_port\s.*/bind_port = 6002/" /etc/swift/account-server.confhead -n 3 /etc/swift/account-server.conf | tail -n 1 #/etc/swift/container-server.confsed -i "2s/^bind_ip\s.*/bind_ip = 0.0.0.0/" /etc/swift/container-server.confhead -n 2 /etc/swift/container-server.conf | tail -n 1            sed -i "3s/^bind_port\s.*/bind_port = 6001/" /etc/swift/container-server.confhead -n 3 /etc/swift/container-server.conf | tail -n 1#/etc/swift/object-server.confsed -i "2s/^bind_ip\s.*/bind_ip = 0.0.0.0/" /etc/swift/object-server.confhead -n 2 /etc/swift/object-server.conf | tail -n 1            sed -i "3s/^bind_port\s.*/bind_port = 6000/" /etc/swift/object-server.confhead -n 3 /etc/swift/object-server.conf | tail -n 1#/etc/rsyncd.confmv rsyncd.conf /etcsed -i "7s/^address\s.*/address = $controller_ip/" /etc/rsyncd.confhead -n 7 /etc/rsyncd.conf | tail -n 1	#/etc/default/rsync sed -i "8s/^RSYNC_ENABLE\s.*/RSYNC_ENABLE=true/" /etc/default/rsynchead -n 8 /etc/default/rsync | tail -n 1#重启rsync并设置开机启动 systemctl restart rsyncsystemctl enable rsyncfor ringtype in account container object; do systemctl start swift-$ringtypesystemctl enable swift-$ringtypefor service in replicator updater auditor; doif [ $ringtype != 'account' ] || [ $service != 'updater' ]; thensystemctl start swift-$ringtype-$servicesystemctl enable swift-$ringtype-$servicefidonedone	
}install_swift

proxy-server.conf

# create new
[DEFAULT]
bind_ip = 0.0.0.0
bind_port = 8080
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
allow_account_management = true
account_autocreate = true# Keystone auth info
[filter:authtoken]
paste.filter_factory = keystonemiddleware.auth_token:filter_factory
www_authenticate_uri = http://controller:5000
auth_url = http://controller:5000
memcached_servers = controller:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = swift
password = openstack
delay_auth_decision = true[filter:keystoneauth]
use = egg:swift#keystoneauth
operator_roles = admin,user[filter:healthcheck]
use = egg:swift#healthcheck[filter:cache]
use = egg:swift#memcache
memcache_servers = controller:11211[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

rsyncd.conf

# create new
pid file = /var/run/rsyncd.pid
log file = /var/log/rsyncd.log
uid = swift
gid = swift
# IP address of this Node
address = 10.0.0.71[account]
path            = /srv/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            = /srv/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            = /srv/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

Compute

#!/bin/shinstall_swift(){
    set -o errexitset -xreadonly controller_ip=172.16.199.11readonly compute_ip=172.16.199.31readonly controller_username=ubuntureadonly controller_passwd=ubuntuecho "----------安装和配置存储节点-------------"#安装组件(echo 'y')|apt-get install swift swift-account swift-container swift-object xfsprogs#Using a loopback device for storage#创建文件truncate -s 1GB /srv/swift-disk#格式化文件mkfs.xfs /srv/swift-disk#创建device1目录mkdir -p /srv/node/device1#挂载/srv/swift-disk到device1mount -o noatime,nodiratime,nobarrier /srv/swift-disk /srv/node/device1#修改权限chown -R swift. /srv/node#设置开机挂载sed -i '$a\ /srv/swift-disk /srv/node/device1 xfs noatime,nodiratime,nobarrier 0 0' /etc/fstab#从控制节点(swift-proxy)拷贝文件到计算节点scp $controller_username@$controller_ip:/etc/swift/*.gz /etc/swift/#修改权限chown swift. /etc/swift/*.gz#/etc/swift/swift.confecho "[swift-hash]swift_hash_path_suffix = swift_shared_pathswift_hash_path_prefix = swift_shared_path" >> /etc/swift/swift.confsed -i 's/^[\t]*//g' /etc/swift/swift.conf		#/etc/swift/account-server.confsed -i "2s/^bind_ip\s.*/bind_ip = 0.0.0.0/" /etc/swift/account-server.confhead -n 2 /etc/swift/account-server.conf | tail -n 1sed -i "3s/^bind_port\s.*/bind_port = 6002/" /etc/swift/account-server.confhead -n 3 /etc/swift/account-server.conf | tail -n 1 #/etc/swift/container-server.confsed -i "2s/^bind_ip\s.*/bind_ip = 0.0.0.0/" /etc/swift/container-server.confhead -n 2 /etc/swift/container-server.conf | tail -n 1            sed -i "3s/^bind_port\s.*/bind_port = 6001/" /etc/swift/container-server.confhead -n 3 /etc/swift/container-server.conf | tail -n 1#/etc/swift/object-server.confsed -i "2s/^bind_ip\s.*/bind_ip = 0.0.0.0/" /etc/swift/object-server.confhead -n 2 /etc/swift/object-server.conf | tail -n 1            sed -i "3s/^bind_port\s.*/bind_port = 6000/" /etc/swift/object-server.confhead -n 3 /etc/swift/object-server.conf | tail -n 1#/etc/rsyncd.confmv rsyncd.conf /etcsed -i "7s/^address\s.*/address = $compute_ip/" /etc/rsyncd.confhead -n 7 /etc/rsyncd.conf | tail -n 1	#/etc/default/rsync sed -i "8s/^RSYNC_ENABLE\s.*/RSYNC_ENABLE=true/" /etc/default/rsynchead -n 8 /etc/default/rsync | tail -n 1#重启rsync并设置开机启动 systemctl restart rsyncsystemctl enable rsyncfor ringtype in account container object; do systemctl start swift-$ringtypesystemctl enable swift-$ringtypefor service in replicator updater auditor; doif [ $ringtype != 'account' ] || [ $service != 'updater' ]; thensystemctl start swift-$ringtype-$servicesystemctl enable swift-$ringtype-$servicefidonedone
}install_swift

rsyncd.conf

# create new
pid file = /var/run/rsyncd.pid
log file = /var/log/rsyncd.log
uid = swift
gid = swift
# IP address of this Node
address = 10.0.0.71[account]
path            = /srv/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            = /srv/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            = /srv/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

参考

Object Storage Install Guide