Openstack O版 配置swift对象存储服务

Openstack O版 配置swift对象存储服务,第1张

概述环境如下图所示: 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服务 [ [email protected] ~]# source admin-openrc 创 环境如下图所示:
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服务
[ [email protected] ~]# source admin-openrc
创建swift用户
[ [email protected] ~]# openstack user create --domain default --password-prompt swift


[ [email protected] ~]# openstack role add --project service --user swift admin
创建swift服务
[ [email protected] ~]# openstack service create --name swift --description "OpenStack Object Storage" object-store


创建对象存储服务API端点:
[[email protected] ~]# openstack endpoint create --region RegionOne \

object-store public http://controller:8080/v1/AUTH_%\(tenant_id\)s


[[email protected] ~]# openstack endpoint create --region RegionOne \

object-store internal http://controller:8080/v1/AUTH_%\(tenant_id\)s


[[email protected] ~]# openstack endpoint create --region RegionOne \
object-store admin http://controller:8080/v1


安装服务包
[[email protected] ~]# yum install openstack-swift-proxy python-swiftclIEnt python-keystoneclIEnt python-keystonemIDdleware memcached
拷贝proxy-server.conf配置文件到/etc/swift/目录下面
[[email protected] 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服务
[[email protected] ~]# ifconfig | head -2
ens33: flags=4163<UP,broADCAST,RUNNING,MulTICAST> mtu 1500
inet 192.168.0.113 netmask 255.255.255.0 broadcast 192.168.0.255
[[email protected] ~]# yum -y install xfsprogs rsync
格式化sdb和sdc设备
[[email protected] ~]# mkfs.xfs /dev/sdb
[[email protected] ~]# mkfs.xfs /dev/sdc
创建安装点目录结构
[[email protected] ~]# mkdir -p /srv/node/sdb
[[email protected] ~]# mkdir -p /srv/node/sdc
编辑/etc/fstab文件并添加一下内容
[[email protected] ~]# 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,logbufs=8 0 2
挂载设备
[[email protected] ~]# mount /srv/node/sdb/
[[email protected] ~]# mount /srv/node/sdc
[[email protected] ~]# 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服务
[[email protected] ~]# systemctl enable rsyncd.service
[[email protected] ~]# systemctl start rsyncd.service
[[email protected] ~]# systemctl status rsyncd.service
安装和配置组件
[[email protected] ~]# yum install openstack-swift-account openstack-swift-container openstack-swift-object
[[email protected] ~]# curl -o /etc/swift/account-server.conf https://git.openstack.org/cgit/openstack/swift/plain/etc/account-server.conf-sample?h=stable/newton
[[email protected] ~]# curl -o /etc/swift/container-server.conf https://git.openstack.org/cgit/openstack/swift/plain/etc/container-server.conf-sample?h=stable/newton
[[email protected] ~]# curl -o /etc/swift/object-server.conf https://git.openstack.org/cgit/openstack/swift/plain/etc/object-server.conf-sample?h=stable/newton
[[email protected] ~]# 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
[[email protected] ~]# 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
[[email protected] ~]# 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
[[email protected] ~]# chown -R swift:swift /srv/node
[[email protected] ~]# chown -R root:swift /var/cache/swift/
[[email protected] ~]# chmod -R 755 /var/cache/swift/
同理在object2上同上 *** 作,配置文件中修改IP地址的IP就可以。
[[email protected] ~]# systemctl enable rsyncd.service
[[email protected] ~]# systemctl start rsyncd.service
[[email protected] ~]# systemctl status rsyncd.service
3.创建和分发初始环在控制节点上执行一下步骤
创建账号
切换到/etc/swift目录下面
[[email protected] ~]# cd /etc/swift/
[[email protected] swift]# swift-ring-builder account.builder create 10 3 1
添加存储节点
[[email protected] 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
[[email protected] 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
[[email protected] 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
[[email protected] 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
[[email protected] 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
[[email protected] swift]# swift-ring-builder account.builder rebalance
Reassigned 3072 (300.00%) partitions. Balance is Now 0.00. dispersion is Now 0.00

[[email protected] swift]# swift-ring-builder container.builder create 10 3 1
[[email protected] 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
[[email protected] 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
[[email protected] 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
[[email protected] 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
[[email protected] swift]# swift-ring-builder container.builder
container.builder,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
[[email protected] swift]# swift-ring-builder container.builder rebalance
Reassigned 3072 (300.00%) partitions. Balance is Now 0.00. dispersion is Now 0.00

[[email protected] swift]# swift-ring-builder object.builder create 10 3 1
[[email protected] 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
[[email protected] 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
[[email protected] 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
[[email protected] 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
[[email protected] swift]# swift-ring-builder object.builder
object.builder,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
[[email protected] 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配置文件
[[email protected] swift]# curl -o /etc/swift/swift.conf https://git.openstack.org/cgit/openstack/swift/plain/etc/swift.conf-sample?h=stable/newton
[[email protected] 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配置文件到各个存储节点上
过程省略。。。。。。。。。。。。。。。。。。。
[[email protected] swift]# chown -R root:swift /etc/swift/
[[email protected] swift]# systemctl enable openstack-swift-proxy.service memcached.service
[[email protected] swift]# systemctl start openstack-swift-proxy.service memcached.service
[[email protected] swift]# systemctl status openstack-swift-proxy.service memcached.service
5.在存储节点上启动swift服务
[[email protected] swift]# systemctl enable openstack-swift-account.service openstack-swift-account-auditor.service openstack-swift-account-reaper.service openstack-swift-account-replicator.service
[[email protected] swift]# systemctl start openstack-swift-account.service openstack-swift-account-auditor.service openstack-swift-account-reaper.service openstack-swift-account-replicator.service
[[email protected] swift]# systemctl status openstack-swift-account.service openstack-swift-account-auditor.service openstack-swift-account-reaper.service openstack-swift-account-replicator.service
[[email protected] swift]# systemctl enable openstack-swift-container.service openstack-swift-container-auditor.service openstack-swift-container-replicator.service openstack-swift-container-updater.service
[[email protected] swift]# systemctl start openstack-swift-container.service openstack-swift-container-auditor.service openstack-swift-container-replicator.service openstack-swift-container-updater.service
[[email protected] swift]# systemctl status openstack-swift-container.service openstack-swift-container-auditor.service openstack-swift-container-replicator.service openstack-swift-container-updater.service
[[email protected] swift]# systemctl enable openstack-swift-object.service openstack-swift-object-auditor.service openstack-swift-object-replicator.service openstack-swift-object-updater.service
[[email protected] swift]# systemctl start openstack-swift-object.service openstack-swift-object-auditor.service openstack-swift-object-replicator.service openstack-swift-object-updater.service
[[email protected] swift]# systemctl status openstack-swift-object.service openstack-swift-object-auditor.service openstack-swift-object-replicator.service openstack-swift-object-updater.service
5.验证
在controller主节点上 *** 作
[[email protected] ~]# 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
[[email protected] ~]# source /root/demo-openrc
显示服务状态
[[email protected] ~]# swift stat


创建container1容器
[[email protected] ~]# openstack container create container1


将测试文件上传到container1容器:
[[email protected] ~]# openstack object create container1 admin-openrc


[[email protected] ~]# openstack objecct List container1


[[email protected] ~]# openstack object save container1 admin-openrc

所有的配置文件在百度云盘中:
链接:https://pan.baidu.com/s/1CnmKkFMTemv199ctgb5Oig 提取码:27om 复制这段内容后打开百度网盘手机App, *** 作更方便哦

总结

以上是内存溢出为你收集整理的Openstack O版 配置swift对象存储服务全部内容,希望文章能够帮你解决Openstack O版 配置swift对象存储服务所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1003187.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-22
下一篇 2022-05-22

发表评论

登录后才能评论

评论列表(0条)

保存