openstack Ocata版swift
环境:
192.168.130.254(ntp,mariadb,rabbitmq,memcache)
192.168.130.101(controller)
192.168.130.201(compute)
192.168.130.111(object storage)
192.168.130.112(object storage)
192.168.130.111(block storage)
说明: 本实验,controller作为swift proxy节点
一.controller
source admin-openrc
openstack user create --domain default --password SWIFT_PASS
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://192.168.130.101:8080/v1/AUTH_%(project_id)s
openstack endpoint create --region RegionOne object-store
internal http://192.168.130.101:8080/v1/AUTH_%(project_id)s
openstack endpoint create --region RegionOne object-store
admin http://192.168.130.101:8080/v1
yum -y install openstack-swift-proxy python-swiftclient
python-keystoneclient python-keystonemiddleware
curl -o /etc/swift/proxy-server.conf https://git.openstack.org/cgit/openstack/swift/plain/etc/proxy-server.conf-sample?h=stable/ocata
crudini --set /etc/swift/proxy-server.conf DEFAULT bind_port
8080
crudini --set /etc/swift/proxy-server.conf DEFAULT user
swift
crudini --set /etc/swift/proxy-server.conf DEFAULT swift_dir
/etc/swift
crudini --set /etc/swift/proxy-server.conf 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"
crudini --set /etc/swift/proxy-server.conf app:proxy-server
use egg:swift#proxy
crudini --set /etc/swift/proxy-server.conf app:proxy-server
account_autocreate true
crudini --set /etc/swift/proxy-server.conf filter:keystoneauth
use egg:swift#keystoneauth
crudini --set /etc/swift/proxy-server.conf filter:keystoneauth
operator_roles admin,user
crudini --set /etc/swift/proxy-server.conf filter:authtoken
paste.filter_factory
keystonemiddleware.auth_token:filter_factory
crudini --set /etc/swift/proxy-server.conf filter:authtoken
auth_uri http://192.168.130.101:5000
crudini --set /etc/swift/proxy-server.conf filter:authtoken
auth_url http://192.168.130.101:35357
crudini --set /etc/swift/proxy-server.conf filter:authtoken
memcached_servers 192.168.130.254:11211
crudini --set /etc/swift/proxy-server.conf filter:authtoken
auth_type password
crudini --set /etc/swift/proxy-server.conf filter:authtoken
project_domain_id default
crudini --set /etc/swift/proxy-server.conf filter:authtoken
user_domain_id default
crudini --set /etc/swift/proxy-server.conf filter:authtoken
project_name service
crudini --set /etc/swift/proxy-server.conf filter:authtoken
username swift
crudini --set /etc/swift/proxy-server.conf filter:authtoken
password SWIFT_PASS
crudini --set /etc/swift/proxy-server.conf filter:authtoken
delay_auth_decision true
crudini --set /etc/swift/proxy-server.conf filter:cache use
egg:swift#memcache
crudini --set /etc/swift/proxy-server.conf filter:cache
memcache_servers 192.168.130.254:11211
二.storage
1.准备存储设备
yum -y install xfsprogs rsync
mkfs.xfs -f /dev/sdc
mkfs.xfs -f /dev/sdd
mkdir -p /srv/node/sdc
mkdir -p /srv/node/sdd
cat >>/etc/fstab <<EOF
/dev/sdc /srv/node/sdc xfs
noatime,nodiratime,nobarrier,logbufs=8 0 2
/dev/sdd /srv/node/sdd xfs
noatime,nodiratime,nobarrier,logbufs=8 0 2
EOF
mount -a
2.配置rsyncd
export MANAGEMENT_INTERFACE_IP_ADDRESS=$(ip a|grep "$1"|grep
-oP "(?<=inet ).*(?= brd)"|awk -F'/' '{print $1}')
cat >/etc/rsyncd.conf <<EOF
uid = swift
gid = swift
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
address = $MANAGEMENT_INTERFACE_IP_ADDRESS
[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
EOF
systemctl enable rsyncd.service
systemctl start rsyncd.service
3.安装配置swift存储组件
yum -y install openstack-swift-account
openstack-swift-container openstack-swift-object
curl -o
/etc/swift/account-server.conf https://git.openstack.org/cgit/openstack/swift/plain/etc/account-server.conf-sample?h=stable/ocata
curl -o
/etc/swift/container-server.conf https://git.openstack.org/cgit/openstack/swift/plain/etc/container-server.conf-sample?h=stable/ocata
curl -o
/etc/swift/object-server.conf https://git.openstack.org/cgit/openstack/swift/plain/etc/object-server.conf-sample?h=stable/ocata
crudini --set /etc/swift/account-server.conf DEFAULT bind_ip
$MANAGEMENT_INTERFACE_IP_ADDRESS
crudini --set /etc/swift/account-server.conf DEFAULT bind_port
6202
crudini --set /etc/swift/account-server.conf DEFAULT user
swift
crudini --set /etc/swift/account-server.conf DEFAULT swift_dir
/etc/swift
crudini --set /etc/swift/account-server.conf DEFAULT devices
/srv/node
crudini --set /etc/swift/account-server.conf DEFAULT
mount_check true
crudini --set /etc/swift/account-server.conf pipeline:main
pipeline "healthcheck recon account-server"
crudini --set /etc/swift/account-server.conf filter:recon use
egg:swift#recon
crudini --set /etc/swift/account-server.conf filter:recon
recon_cache_path /var/cache/swift
crudini --set /etc/swift/container-server.conf DEFAULT bind_ip
$MANAGEMENT_INTERFACE_IP_ADDRESS
crudini --set /etc/swift/container-server.conf DEFAULT
bind_port 6201
crudini --set /etc/swift/container-server.conf DEFAULT user
swift
crudini --set /etc/swift/container-server.conf DEFAULT
swift_dir /etc/swift
crudini --set /etc/swift/container-server.conf DEFAULT devices
/srv/node
crudini --set /etc/swift/container-server.conf DEFAULT
mount_check true
crudini --set /etc/swift/container-server.conf pipeline:main
pipeline "healthcheck recon container-server"
crudini --set /etc/swift/container-server.conf filter:recon
use egg:swift#recon
crudini --set /etc/swift/container-server.conf filter:recon
recon_cache_path /var/cache/swift
crudini --set /etc/swift/object-server.conf DEFAULT bind_ip
$MANAGEMENT_INTERFACE_IP_ADDRESS
crudini --set /etc/swift/object-server.conf DEFAULT bind_port
6200
crudini --set /etc/swift/object-server.conf DEFAULT user
swift
crudini --set /etc/swift/object-server.conf DEFAULT swift_dir
/etc/swift
crudini --set /etc/swift/object-server.conf DEFAULT devices
/srv/node
crudini --set /etc/swift/object-server.conf DEFAULT
mount_check true
crudini --set /etc/swift/object-server.conf pipeline:main
pipeline "healthcheck recon object-server"
crudini --set /etc/swift/object-server.conf filter:recon use
egg:swift#recon
crudini --set /etc/swift/object-server.conf filter:recon
recon_cache_path /var/cache/swift
crudini --set /etc/swift/object-server.conf filter:recon
recon_lock_path /var/lock
chown -R swift:swift /srv/node
mkdir -p /var/cache/swift
chown -R root:swift /var/cache/swift
chmod -R 775 /var/cache/swift
三.initial account,
container, and object rings(controller)
cd /etc/swift
rm -f *.builder *.ring.gz backups/*.builder
backups/*.ring.gz
Create
account ring
swift-ring-builder account.builder create 10 3 1
swift-ring-builder account.builder add --region 1 --zone 1
--ip 192.168.130.111 --port 6202 --device sdc --weight 100
swift-ring-builder account.builder add --region 1 --zone 1
--ip 192.168.130.111 --port 6202 --device sdd --weight 100
swift-ring-builder account.builder add --region 1 --zone 1
--ip 192.168.130.112 --port 6202 --device sdc --weight 100
swift-ring-builder account.builder add --region 1 --zone 1
--ip 192.168.130.112 --port 6202 --device sdd --weight 100
swift-ring-builder account.builder
swift-ring-builder account.builder rebalance
Create
container ring
swift-ring-builder container.builder create 10 3 1
swift-ring-builder container.builder add --region 1 --zone 1
--ip 192.168.130.111 --port 6201 --device sdc --weight 100
swift-ring-builder container.builder add --region 1 --zone 1
--ip 192.168.130.111 --port 6201 --device sdd --weight 100
swift-ring-builder container.builder add --region 1 --zone 1
--ip 192.168.130.112 --port 6201 --device sdc --weight 100
swift-ring-builder container.builder add --region 1 --zone 1
--ip 192.168.130.112 --port 6201 --device sdd --weight 100
swift-ring-builder container.builder
swift-ring-builder container.builder rebalance
Create
object ring
swift-ring-builder object.builder create 10 3 1
swift-ring-builder object.builder add --region 1 --zone 1 --ip
192.168.130.111 --port 6200 --device sdc --weight 100
swift-ring-builder object.builder add --region 1 --zone 1 --ip
192.168.130.111 --port 6200 --device sdd --weight 100
swift-ring-builder object.builder add --region 1 --zone 1 --ip
192.168.130.112 --port 6200 --device sdc --weight 100
swift-ring-builder object.builder add --region 1 --zone 1 --ip
192.168.130.112 --port 6200 --device sdd --weight 100
swift-ring-builder object.builder
swift-ring-builder object.builder rebalance
同步account.ring.gz, container.ring.gz,
object.ring.gz到所有swift存储节点和proxy节点
四.启服务
1.swift
proxy节点和storage节点/etc/swift/swift.conf保持一致
curl -o /etc/swift/swift.conf
https://git.openstack.org/cgit/openstack/swift/plain/etc/swift.conf-sample?h=stable/ocata
crudini --set /etc/swift/swift.conf swift-hash
swift_hash_path_suffix HASH_PATH_SUFFIX
crudini --set /etc/swift/swift.conf swift-hash
swift_hash_path_prefix HASH_PATH_PREFIX
crudini --set /etc/swift/swift.conf storage-policy:0 name
Policy-0
crudini --set /etc/swift/swift.conf storage-policy:0 default
yes
chown -R root:swift /etc/swift
2.proxy节点swift-proxy服务
systemctl enable openstack-swift-proxy.service
systemctl restart openstack-swift-proxy.service
3.storage节点swift组件
systemctl enable openstack-swift-account.service
openstack-swift-account-auditor.service
openstack-swift-account-reaper.service
openstack-swift-account-replicator.service
systemctl restart openstack-swift-account.service
openstack-swift-account-auditor.service
openstack-swift-account-reaper.service
openstack-swift-account-replicator.service
systemctl status 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 restart openstack-swift-container.service
openstack-swift-container-auditor.service
openstack-swift-container-replicator.service
openstack-swift-container-updater.service
systemctl status 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 restart openstack-swift-object.service
openstack-swift-object-auditor.service
openstack-swift-object-replicator.service
openstack-swift-object-updater.service
systemctl status openstack-swift-object.service
openstack-swift-object-auditor.service
openstack-swift-object-replicator.service
openstack-swift-object-updater.service
五.测试
source admin-openrc
openstack catalog show object-store
swift stat
touch FILE
openstack container create container1
openstack object create container1 FILE
openstack object list container1
openstack object save container1 FILE
提示:需要重启 dashboard才能看到对象存储的栏位
六.API
七.常用命令行
openstack object store account show