OpenstackO版配置swift对象存储服务-创新互联
环境如下图所示:
IP:192.168.0.111 controller
IP:192.168.0.112 compute
IP:192.168.0.113 object1
IP:192.168.0.117 object2
IP:192.168.0.118 cinder
1.在控制节点上安装 swift服务
[root@controller ~]# source admin-openrc
创建swift用户
[root@controller ~]# openstack user create --domain default --password-prompt swift
[root@controller ~]# openstack role add --project service --user swift admin
创建swift服务
[root@controller ~]# openstack service create --name swift --description "OpenStack Object Storage" object-store
创建对象存储服务API端点:
[root@controller ~]# openstack endpoint create --region RegionOne \
object-store public http://controller:8080/v1/AUTH_%\(tenant_id\)s
[root@controller ~]# openstack endpoint create --region RegionOne \
object-store internal http://controller:8080/v1/AUTH_%\(tenant_id\)s
[root@controller ~]# openstack endpoint create --region RegionOne \
object-store admin http://controller:8080/v1
安装服务包
[root@controller ~]# yum install openstack-swift-proxy python-swiftclient python-keystoneclient python-keystonemiddleware memcached
拷贝proxy-server.conf配置文件到/etc/swift/目录下面
[root@controller swift]# vim /etc/swift/proxy-server.conf
[DEFAULT]
bind_port = 8080
swift_dir = /etc/swift
user = swift
[pipeline:main] (删除tempurl和tempauth,添加authtoken和keystoneauth模块)
pipeline = catch_errors gatekeeper healthcheck proxy-logging cache container_sync bulk ratelimit authtoken keystoneauth copy container-quotas account-quotas slo dlo versioned_writes proxy-logging proxy-server
[app:proxy-server]
use = egg:swift#proxy
account_autocreate = True
[filter:keystoneauth]
use = egg:swift#keystoneauth
operator_roles = admin,user
[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_id = default
user_domain_id = default
project_name = service
username = swift
password = devops
delay_auth_decision = True
[filter:cache]
use = egg:swift#memcache
memcache_servers = controller:11211
2.安装和配置存储节点分别为object1和object2在两个节点上分别进行一下操作,并且在存储节点上分别各有两块硬盘,分别为sdb和sdc
安装xfsprogs rsync服务
[root@object1 ~]# ifconfig | head -2
ens33: flags=4163mtu 1500
inet 192.168.0.113 netmask 255.255.255.0 broadcast 192.168.0.255
[root@object1 ~]# yum -y install xfsprogs rsync
格式化sdb和sdc设备
[root@object1 ~]# mkfs.xfs /dev/sdb
[root@object1 ~]# mkfs.xfs /dev/sdc
创建安装点目录结构
[root@object1 ~]# mkdir -p /srv/node/sdb
[root@object1 ~]# mkdir -p /srv/node/sdc
编辑/etc/fstab文件并添加一下内容
[root@object1 ~]# cat /etc/fstab | tail -2
/dev/sdb /srv/node/sdb xfs noatime,nodiratime,nobarrier,logbufs=8 0 2
/dev/sdc /srv/node/sdc xfs noatime,nodiratime,nobarrier,logbufs=8 0 2
挂载设备
[root@object1 ~]# mount /srv/node/sdb/
[root@object1 ~]# mount /srv/node/sdc
[root@object1 ~]# vim /etc/rsyncd.conf
uid = swift
gid = swift
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
address = 192.168.0.113
[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
启动rsyncd服务
[root@object1 ~]# systemctl enable rsyncd.service
[root@object1 ~]# systemctl start rsyncd.service
[root@object1 ~]# systemctl status rsyncd.service
安装和配置组件
[root@object1 ~]# yum install openstack-swift-account openstack-swift-container openstack-swift-object
[root@object1 ~]# curl -o /etc/swift/account-server.conf https://git.openstack.org/cgit/openstack/swift/plain/etc/account-server.conf-sample?h=stable/newton
[root@object1 ~]# curl -o /etc/swift/container-server.conf https://git.openstack.org/cgit/openstack/swift/plain/etc/container-server.conf-sample?h=stable/newton
[root@object1 ~]# curl -o /etc/swift/object-server.conf https://git.openstack.org/cgit/openstack/swift/plain/etc/object-server.conf-sample?h=stable/newton
[root@object1 ~]# vim /etc/swift/account-server.conf
[DEFAULT]
bind_ip =192.168.0.113
bind_port = 6202
user = swift
swift_dir = /etc/swift
devices = /srv/node
mount_check = true
[pipeline:main]
pipeline = healthcheck recon account-server
[filter:recon]
use = egg:swift#recon
recon_cache_path = /var/cache/swift
[root@object1 ~]# vim /etc/swift/container-server.conf
[DEFAULT]
bind_ip = 192.168.0.113
bind_port = 6201
user = swift
swift_dir = /etc/swift
devices = /srv/node
mount_check = true
[pipeline:main]
pipeline = healthcheck recon container-server
[filter:recon]
use = egg:swift#recon
recon_cache_path = /var/cache/swift
[root@object1 ~]# vim /etc/swift/object-server.conf
[DEFAULT]
bind_ip = 192.168.0.113
bind_port = 6200
user = swift
swift_dir = /etc/swift
devices = /srv/node
mount_check = true
[pipeline:main]
pipeline = healthcheck recon object-server
[filter:recon]
use = egg:swift#recon
recon_cache_path = /var/cache/swift
recon_lockpath = /var/lock
[root@object1 ~]# chown -R swift:swift /srv/node
[root@object1 ~]# chown -R root:swift /var/cache/swift/
[root@object1 ~]# chmod -R 755 /var/cache/swift/
同理在object2上同上操作,配置文件中修改IP地址的IP就可以。
[root@object2 ~]# systemctl enable rsyncd.service
[root@object2 ~]# systemctl start rsyncd.service
[root@object2 ~]# systemctl status rsyncd.service
3.创建和分发初始环在控制节点上执行一下步骤
创建账号
切换到/etc/swift目录下面
[root@controller ~]# cd /etc/swift/
[root@controller swift]# swift-ring-builder account.builder create 10 3 1
添加存储节点
[root@controller swift]# swift-ring-builder account.builder add --region 1 --zone 1 --ip 192.168.0.113 --port 6202 --device sdb --weight 100
Device d0r1z1-192.168.0.113:6202R192.168.0.113:6202/sdb"" with 100.0 weight got id 0
You have mail in /var/spool/mail/root
[root@controller swift]# swift-ring-builder account.builder add --region 1 --zone 1 --ip 192.168.0.113 --port 6202 --device sdc --weight 100
Device d1r1z1-192.168.0.113:6202R192.168.0.113:6202/sdc"" with 100.0 weight got id 1
[root@controller swift]# swift-ring-builder account.builder add --region 1 --zone 2 --ip 192.168.0.117 --port 6202 --device sdb --weight 100
Device d2r1z2-192.168.0.117:6202R192.168.0.117:6202/sdb"" with 100.0 weight got id 2
[root@controller swift]# swift-ring-builder account.builder add --region 1 --zone 2 --ip 192.168.0.117 --port 6202 --device sdc --weight 100
Device d3r1z2-192.168.0.117:6202R192.168.0.117:6202/sdc_"" with 100.0 weight got id 3
[root@controller swift]# swift-ring-builder account.builder
account.builder, build version 4
1024 partitions, 3.000000 replicas, 1 regions, 2 zones, 4 devices, 100.00 balance, 0.00 dispersion
The minimum number of hours before a partition can be reassigned is 1 (0:00:00 remaining)
The overload factor is 0.00% (0.000000)
Ring file account.ring.gz not found, probably it hasn't been written yet
Devices: id region zone ip address:port replication ip:port name weight partitions balance flags meta
0 1 1 192.168.0.113:6202 192.168.0.113:6202 sdb 100.00 0 -100.00
1 1 1 192.168.0.113:6202 192.168.0.113:6202 sdc 100.00 0 -100.00
2 1 2 192.168.0.117:6202 192.168.0.117:6202 sdb 100.00 0 -100.00
3 1 2 192.168.0.117:6202 192.168.0.117:6202 sdc 100.00 0 -100.00
[root@controller swift]# swift-ring-builder account.builder rebalance
Reassigned 3072 (300.00%) partitions. Balance is now 0.00. Dispersion is now 0.00
[root@controller swift]# swift-ring-builder container.builder create 10 3 1
[root@controller swift]# swift-ring-builder container.builder add --region 1 --zone 1 --ip 192.168.0.113 --port 6201 --device sdb --weight 100
Device d0r1z1-192.168.0.113:6201R192.168.0.113:6201/sdb"" with 100.0 weight got id 0
[root@controller swift]# swift-ring-builder container.builder add --region 1 --zone 1 --ip 192.168.0.113 --port 6201 --device sdc --weight 100
Device d1r1z1-192.168.0.113:6201R192.168.0.113:6201/sdc"" with 100.0 weight got id 1
[root@controller swift]# swift-ring-builder container.builder add --region 1 --zone 2 --ip 192.168.0.117 --port 6201 --device sdb --weight 100
Device d2r1z2-192.168.0.117:6201R192.168.0.117:6201/sdb"" with 100.0 weight got id 2
[root@controller swift]# swift-ring-builder container.builder add --region 1 --zone 2 --ip 192.168.0.117 --port 6201 --device sdc --weight 100
Device d3r1z2-192.168.0.117:6201R192.168.0.117:6201/sdc"" with 100.0 weight got id 3
[root@controller swift]# swift-ring-builder container.builder
container.builder, build version 4
1024 partitions, 3.000000 replicas, 1 regions, 2 zones, 4 devices, 100.00 balance, 0.00 dispersion
The minimum number of hours before a partition can be reassigned is 1 (0:00:00 remaining)
The overload factor is 0.00% (0.000000)
Ring file container.ring.gz not found, probably it hasn't been written yet
Devices: id region zone ip address:port replication ip:port name weight partitions balance flags meta
0 1 1 192.168.0.113:6201 192.168.0.113:6201 sdb 100.00 0 -100.00
1 1 1 192.168.0.113:6201 192.168.0.113:6201 sdc 100.00 0 -100.00
2 1 2 192.168.0.117:6201 192.168.0.117:6201 sdb 100.00 0 -100.00
3 1 2 192.168.0.117:6201 192.168.0.117:6201 sdc 100.00 0 -100.00
[root@controller swift]# swift-ring-builder container.builder rebalance
Reassigned 3072 (300.00%) partitions. Balance is now 0.00. Dispersion is now 0.00
[root@controller swift]# swift-ring-builder object.builder create 10 3 1
[root@controller swift]# swift-ring-builder object.builder add --region 1 --zone 1 --ip 192.168.0.113 --port 6200 --device sdb --weight 100
Device d0r1z1-192.168.0.113:6200R192.168.0.113:6200/sdb"" with 100.0 weight got id 0
[root@controller swift]# swift-ring-builder object.builder add --region 1 --zone 1 --ip 192.168.0.113 --port 6200 --device sdc --weight 100
Device d1r1z1-192.168.0.113:6200R192.168.0.113:6200/sdc"" with 100.0 weight got id 1
[root@controller swift]# swift-ring-builder object.builder add --region 1 --zone 2 --ip 192.168.0.117 --port 6200 --device sdb --weight 100
Device d2r1z2-192.168.0.117:6200R192.168.0.117:6200/sdb"" with 100.0 weight got id 2
[root@controller swift]# swift-ring-builder object.builder add --region 1 --zone 2 --ip 192.168.0.117 --port 6200 --device sdc --weight 100
Device d3r1z2-192.168.0.117:6200R192.168.0.117:6200/sdc"" with 100.0 weight got id 3
[root@controller swift]# swift-ring-builder object.builder
object.builder, build version 4
1024 partitions, 3.000000 replicas, 1 regions, 2 zones, 4 devices, 100.00 balance, 0.00 dispersion
The minimum number of hours before a partition can be reassigned is 1 (0:00:00 remaining)
The overload factor is 0.00% (0.000000)
Ring file object.ring.gz not found, probably it hasn't been written yet
Devices: id region zone ip address:port replication ip:port name weight partitions balance flags meta
0 1 1 192.168.0.113:6200 192.168.0.113:6200 sdb 100.00 0 -100.00
1 1 1 192.168.0.113:6200 192.168.0.113:6200 sdc 100.00 0 -100.00
2 1 2 192.168.0.117:6200 192.168.0.117:6200 sdb 100.00 0 -100.00
3 1 2 192.168.0.117:6200 192.168.0.117:6200 sdc 100.00 0 -100.00
[root@controller swift]# swift-ring-builder object.builder rebalance
Reassigned 3072 (300.00%) partitions. Balance is now 0.00. Dispersion is now 0.00
下载controller 中/etc/swift目录下account.ring.gz container.ring.gz object.ring.gz放到各个存储节点上/etc/swift/目录下面
4.在controller控制节点上下载和配置swift.conf配置文件
[root@controller swift]# curl -o /etc/swift/swift.conf https://git.openstack.org/cgit/openstack/swift/plain/etc/swift.conf-sample?h=stable/newton
[root@controller swift]# vim /etc/swift/swift.conf
[swift-hash]
swift_hash_path_suffix = openstack
swift_hash_path_prefix = openstack
[storage-policy:0]
name = Policy-0
default = yes
下载swift.conf配置文件到各个存储节点上
过程省略。。。。。。。。。。。。。。。。。。。
[root@controller swift]# chown -R root:swift /etc/swift/
[root@controller swift]# systemctl enable openstack-swift-proxy.service memcached.service
[root@controller swift]# systemctl start openstack-swift-proxy.service memcached.service
[root@controller swift]# systemctl status openstack-swift-proxy.service memcached.service
5.在存储节点上启动swift服务
[root@object1 swift]# systemctl enable openstack-swift-account.service openstack-swift-account-auditor.service openstack-swift-account-reaper.service openstack-swift-account-replicator.service
[root@object1 swift]# systemctl start openstack-swift-account.service openstack-swift-account-auditor.service openstack-swift-account-reaper.service openstack-swift-account-replicator.service
[root@object1 swift]# systemctl status openstack-swift-account.service openstack-swift-account-auditor.service openstack-swift-account-reaper.service openstack-swift-account-replicator.service
[root@object1 swift]# systemctl enable openstack-swift-container.service openstack-swift-container-auditor.service openstack-swift-container-replicator.service openstack-swift-container-updater.service
[root@object1 swift]# systemctl start openstack-swift-container.service openstack-swift-container-auditor.service openstack-swift-container-replicator.service openstack-swift-container-updater.service
[root@object1 swift]# systemctl status openstack-swift-container.service openstack-swift-container-auditor.service openstack-swift-container-replicator.service openstack-swift-container-updater.service
[root@object1 swift]# systemctl enable openstack-swift-object.service openstack-swift-object-auditor.service openstack-swift-object-replicator.service openstack-swift-object-updater.service
[root@object1 swift]# systemctl start openstack-swift-object.service openstack-swift-object-auditor.service openstack-swift-object-replicator.service openstack-swift-object-updater.service
[root@object1 swift]# systemctl status openstack-swift-object.service openstack-swift-object-auditor.service openstack-swift-object-replicator.service openstack-swift-object-updater.service
5.验证
在controller主节点上操作
[root@controller ~]# cat demo-openrc
export OS_USER_DOMAIN_ID=default
export OS_PROJECT_DOMAIN_ID=default
export OS_USERNAME=demo
export OS_PROJECT_NAME=demo
export OS_PASSWORD=devops
export OS_IDENTITY_API_VERSION=3
export OS_IMAGE_API_VERSION=2
export OS_AUTH_URL=http://controller:5000/v3
[root@controller ~]# source /root/demo-openrc
显示服务状态
[root@controller ~]# swift stat
创建container1容器
[root@controller ~]# openstack container create container1
将测试文件上传到container1容器:
[root@controller ~]# openstack object create container1 admin-openrc
[root@controller ~]# openstack objecct list container1
[root@controller ~]# openstack object save container1 admin-openrc
所有的配置文件在百度云盘中:
链接:https://pan.baidu.com/s/1CnmKkFMTemv199ctgb5Oig
提取码:27om
复制这段内容后打开百度网盘手机App,操作更方便哦
另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
网页标题:OpenstackO版配置swift对象存储服务-创新互联
当前URL:http://azwzsj.com/article/cocjig.html