swift项目自己创建package swift存储 搭建

admin2024-06-01  12

九、Swift对象存储服务(双节点搭建)

要求:Controoler节点需要2块空盘

Compute节点需要再加2块空盘

swift项目自己创建package swift存储 搭建,swift项目自己创建package swift存储 搭建_swift项目自己创建package,第1张

本次搭建采用Controller 和 Compute双节点节点做swift组件

1.Controller安装并配置控制节点

2.Compute安装和配置存储节点

3.Compute节点安装并配置组件

4.Controller节点创建,分发并初始化rings

5.启动服务

6.Controller执行验证操作

1.Controller安装并配置控制节点

#### 1.获得凭证并创建身份认证服务的凭证

# . /root/admin-openrc
# openstack user create --domain default --password 000000 swift
# openstack role add --project service --user swift admin
# openstack service create --name swift --description "OpenStack Object Storage" object-store

swift项目自己创建package swift存储 搭建,swift项目自己创建package swift存储 搭建_swift项目自己创建package_02,第2张

创建对象存储服务 API 端点

# openstack endpoint create --region RegionOne object-store public http://controller:8080/v1/AUTH_%\(tenant_id\)s

# openstack 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项目自己创建package swift存储 搭建,swift项目自己创建package swift存储 搭建_swift项目自己创建package_03,第3张

swift项目自己创建package swift存储 搭建,swift项目自己创建package swift存储 搭建_swift项目自己创建package_04,第4张

3.安装并配置组件

[root@controller ~]# yum -y install openstack-swift-proxy python-swiftclient python-keystoneclient python-keystonemiddleware memcached xfsprogs rsync openstack-swift-account openstack-swift-container openstack-swift-object

编辑文件 /etc/swift/proxy-server.conf,删除原有内容,直接添加如下内容

# vi /etc/swift/proxy-server.conf


[DEFAULT]
bind_port = 8080
swift_dir = /etc/swift
user = swift
[pipeline:main]
pipeline = catch_errors gatekeeper healthcheck proxy-logging cache_sync bulk ratelimit authtoken keystoneauth-quotas account-quotas slo dlo versioned_writes proxy-logging proxy-server
[app:proxy-server]
use = egg:swift#proxy
account_autocreate = True
[filter:tempauth]
use = egg:swift#tempauth
user_admin_admin = admin .admin .reseller_admin
user_test_tester = testing .admin
user_test2_tester2 = testing2 .admin
user_test_tester3 = testing3
user_test5_tester5 = testing5 service
[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_name = default
user_domain_name = default
project_name = service
username = swift
password = 000000
delay_auth_decision = True
[filter:keystoneauth]
use = egg:swift#keystoneauth
operator_roles = admin,user
[filter:healthcheck]
use = egg:swift#healthcheck
[filter:cache]
memcache_servers = controller:11211
use = egg:swift#memcache
[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

编辑文件/etc/swift/swift.conf 删除原有内容,添加如下内容

# vi /etc/swift/swift.conf

[swift-hash]
swift_hash_path_suffix = changeme
swift_hash_path_prefix = changeme
[storage-policy:0]
name = Policy-0
default = yes
aliases = yellow, orange
[swift-constraints]
查看空盘
lsblk

swift项目自己创建package swift存储 搭建,swift项目自己创建package swift存储 搭建_配置文件_05,第5张

每个盘划分一个空白分区

# fdisk /dev/sdb
# fdisk /dev/sdc

swift项目自己创建package swift存储 搭建,swift项目自己创建package swift存储 搭建_python_06,第6张

swift项目自己创建package swift存储 搭建,swift项目自己创建package swift存储 搭建_配置文件_07,第7张

创建挂载目录

[root@controller ~]# mkdir -p /swift/sdb
[root@controller ~]# mkdir -p /swift/sdc

swift项目自己创建package swift存储 搭建,swift项目自己创建package swift存储 搭建_配置文件_08,第8张

指定分区格式

swift项目自己创建package swift存储 搭建,swift项目自己创建package swift存储 搭建_swift_09,第9张

挂载分区到目录

swift项目自己创建package swift存储 搭建,swift项目自己创建package swift存储 搭建_配置文件_10,第10张

添加到/etc/fstab配置文件中

[root@controller ~]# vi /etc/fstab 
/dev/sdb1 /swift/sdb xfs noatime,nodiratime,nobarrier,logbufs=8 0 0
/dev/sdc1 /swift/sdc xfs noatime,nodiratime,nobarrier,logbufs=8 0 0

swift项目自己创建package swift存储 搭建,swift项目自己创建package swift存储 搭建_swift项目自己创建package_11,第11张

编辑配置文件 /etc/rsyncd.conf

[root@controller ~]# vi /etc/rsyncd.conf

swift项目自己创建package swift存储 搭建,swift项目自己创建package swift存储 搭建_python_12,第12张

启动服务

[root@controller ~]# systemctl start rsyncd.service
[root@controller ~]# systemctl enable rsyncd.service

swift项目自己创建package swift存储 搭建,swift项目自己创建package swift存储 搭建_swift项目自己创建package_13,第13张

6.赋权:

# mkdir -p /var/cache/swift
# chown -R root:swift /var/cache/swift
# chmod -R 775 /var/cache/swift
# chown -R swift:swift /swift
# chown -R root:swift /etc/swift

编辑三个配置文件account object

1.编辑 /etc/swift/account-server.conf 文件,删除原有内容,直接添加以下内容
#vi /etc/swift/account-server.conf

[DEFAULT]
bind_ip = 192.168.100.10
bind_port = 6002
user = swift
swift_dir = /etc/swift
devices = /swift
mount_check = false
[pipeline:main]
pipeline = healthcheck recon account-server
[app:account-server]
use = egg:swift#account
[filter:healthcheck]
use = egg:swift#healthcheck
[filter:recon]
use = egg:swift#recon
recon_cache_path = /var/cache/swift
[account-replicator]
[account-auditor]
[account-reaper]
[filter:xprofile]
use = egg:swift#xprofile


2.编辑``/etc/swift/container-server.conf``文件,删除原有内容,直接添加以下内容:
# vi /etc/swift/container-server.conf

[DEFAULT]
bind_ip = 192.168.100.10
bind_port = 6001
user = swift
swift_dir = /etc/swift
devices = /swift
mount_check = false
[pipeline:main]
pipeline = healthcheck recon-server
[app:container-server]
use = egg:swift#container
[filter:healthcheck]
use = egg:swift#healthcheck
[filter:recon]
use = egg:swift#recon
recon_cache_path = /var/cache/swift
[container-replicator]
[container-updater]
[container-auditor]
[container-sync]
[filter:xprofile]
use = egg:swift#xprofile


3.编辑``/etc/swift/object-server.conf``文件,删除原有内容,直接添加以下内容:
# vi /etc/swift/object-server.conf

[DEFAULT]
bind_ip = 192.168.100.10
bind_port = 6000
user = swift
swift_dir = /etc/swift
devices = /swift
mount_check = false
[pipeline:main]
pipeline = healthcheck recon object-server
[app:object-server]
use = egg:swift#object
[filter:healthcheck]
use = egg:swift#healthcheck
[filter:recon]
use = egg:swift#recon
recon_cache_path = /var/cache/swift
recon_lock_path = /var/lock
[object-replicator]
[object-reconstructor]
[object-updater]
[object-auditor]
[filter:xprofile]
use = egg:swift#xprofile

2.Compute安装和配置存储节点

1.安装软件包

[root@compute ~]# yum -y install xfsprogs rsync openstack-swift-account openstack-swift-container openstack-swift-object

搭建Swift Compute节点需要两块空盘,此处我们查看添加的空盘

# lsblk

swift项目自己创建package swift存储 搭建,swift项目自己创建package swift存储 搭建_swift项目自己创建package_14,第14张

创建分区

# fdisk /dev/sdc
# fdisk /dev/sdd

swift项目自己创建package swift存储 搭建,swift项目自己创建package swift存储 搭建_配置文件_15,第15张

swift项目自己创建package swift存储 搭建,swift项目自己创建package swift存储 搭建_python_16,第16张

指定文件格式

# mkfs.xfs /dev/sdc1
# mkfs.xfs /dev/sdd1

swift项目自己创建package swift存储 搭建,swift项目自己创建package swift存储 搭建_python_17,第17张

3.创建挂载点目录结构:

[root@compute ~]# mkdir -p /swift/sdc
[root@compute ~]# mkdir -p /swift/sdd

swift项目自己创建package swift存储 搭建,swift项目自己创建package swift存储 搭建_python_18,第18张

挂载分区到目录

[root@compute ~]# mount /dev/sdc1 /swift/sdc/
[root@compute ~]# mount /dev/sdd1 /swift/sdd/

swift项目自己创建package swift存储 搭建,swift项目自己创建package swift存储 搭建_配置文件_19,第19张

4.编辑/etc/fstab文件并添加以下内容:
vi /etc/fstab

/dev/sdc1 /swift/sdc xfs noatime,nodiratime,nobarrier,logbufs=8 0 0
/dev/sdd1 /swift/sdd xfs noatime,nodiratime,nobarrier,logbufs=8 0 0

swift项目自己创建package swift存储 搭建,swift项目自己创建package swift存储 搭建_swift项目自己创建package_20,第20张

5.编辑/etc/rsyncd.conf文件并添加以下内容:

[root@compute ~]#vi /etc/rsyncd.conf

pid file = /var/run/rsyncd.pid
log file = /var/log/rsyncd.log
uid = swift
gid = swift
address = 192.168.100.20
[account]
path            = /swift
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            = /swift
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            = /swift
read only       = false
write only      = no
list            = yes
incoming chmod  = 0644
outgoing chmod  = 0644
max connections = 25
lock file =     /var/lock/object.lock

swift项目自己创建package swift存储 搭建,swift项目自己创建package swift存储 搭建_配置文件_21,第21张

6.启动 “rsyncd” 服务和配置它随系统启动:

# systemctl start rsyncd.service
# systemctl enable rsyncd.service

6.赋权:

# mkdir -p /var/cache/swift
# chown -R root:swift /var/cache/swift
# chmod -R 775 /var/cache/swift
# chown -R swift:swift /swift
# chown -R root:swift /etc/swift

编辑配置文件 account object

1.编辑 /etc/swift/account-server.conf 文件,删除原有内容,直接添加以下内容
#vi /etc/swift/account-server.conf

[DEFAULT]
bind_ip = 192.168.100.20
bind_port = 6002
user = swift
swift_dir = /etc/swift
devices = /swift
mount_check = false
[pipeline:main]
pipeline = healthcheck recon account-server
[app:account-server]
use = egg:swift#account
[filter:healthcheck]
use = egg:swift#healthcheck
[filter:recon]
use = egg:swift#recon
recon_cache_path = /var/cache/swift
[account-replicator]
[account-auditor]
[account-reaper]
[filter:xprofile]
use = egg:swift#xprofile


2.编辑``/etc/swift/container-server.conf``文件,删除原有内容,直接添加以下内容:
# vi /etc/swift/container-server.conf

[DEFAULT]
bind_ip = 192.168.100.20
bind_port = 6001
user = swift
swift_dir = /etc/swift
devices = /swift
mount_check = false
[pipeline:main]
pipeline = healthcheck recon-server
[app:container-server]
use = egg:swift#container
[filter:healthcheck]
use = egg:swift#healthcheck
[filter:recon]
use = egg:swift#recon
recon_cache_path = /var/cache/swift
[container-replicator]
[container-updater]
[container-auditor]
[container-sync]
[filter:xprofile]
use = egg:swift#xprofile


3.编辑``/etc/swift/object-server.conf``文件,删除原有内容,直接添加以下内容:
# vi /etc/swift/object-server.conf

[DEFAULT]
bind_ip = 192.168.100.20
bind_port = 6000
user = swift
swift_dir = /etc/swift
devices = /swift
mount_check = false
[pipeline:main]
pipeline = healthcheck recon object-server
[app:object-server]
use = egg:swift#object
[filter:healthcheck]
use = egg:swift#healthcheck
[filter:recon]
use = egg:swift#recon
recon_cache_path = /var/cache/swift
recon_lock_path = /var/lock
[object-replicator]
[object-reconstructor]
[object-updater]
[object-auditor]
[filter:xprofile]
use = egg:swift#xprofile

4.编辑文件/etc/swift/swift.conf 删除原有内容,添加如下内容

# vi /etc/swift/swift.conf

[swift-hash]
swift_hash_path_suffix = changeme
swift_hash_path_prefix = changeme
[storage-policy:0]
name = Policy-0
default = yes
aliases = yellow, orange
[swift-constraints]

swift项目自己创建package swift存储 搭建,swift项目自己创建package swift存储 搭建_python_22,第22张

3.Controller 和 Compute节点安装并配置组件

4.Controller节点创建,分发并初始化rings

1.创建账户ring

1.切换到 ``/etc/swift``目录。创建基本 account.builder 文件:

# cd /etc/swift
# swift-ring-builder account.builder create 18 1 1
2.添加每个节点到 ring 中:
# swift-ring-builder account.builder add --region 1 --zone 1 --ip 192.168.100.20 --port 6002 --device sdc1 --weight 100
# swift-ring-builder account.builder add --region 1 --zone 1 --ip 192.168.100.20 --port 6002 --device sdd1 --weight 100
# swift-ring-builder account.builder add --region 1 --zone 1 --ip 192.168.100.10 --port 6002 --device sdc1 --weight 100
# swift-ring-builder account.builder add --region 1 --zone 1 --ip 192.168.100.10 --port 6002 --device sdb1 --weight 100
2.验证ring内容
# swift-ring-builder account.builder
3.平衡ring
# swift-ring-builder account.builder rebalance

swift项目自己创建package swift存储 搭建,swift项目自己创建package swift存储 搭建_python_23,第23张

2.创建ring容器

1.切换到 ``/etc/swift``目录。创建基本``container.builder``文件:
# cd /etc/swift
# swift-ring-builder.builder create 10 1 1
2.添加每个节点到 ring 中:
# swift-ring-builder.builder add --region 1 --zone 1 --ip 192.168.100.20 --port 6001 --device sdc1 --weight 100
# swift-ring-builder.builder add --region 1 --zone 1 --ip 192.168.100.20 --port 6001 --device sdd1 --weight 100
# swift-ring-builder.builder add --region 1 --zone 1 --ip 192.168.100.10 --port 6001 --device sdc1 --weight 100
# swift-ring-builder.builder add --region 1 --zone 1 --ip 192.168.100.10 --port 6001 --device sdb1 --weight 100
3.验证 ring 的内容:
# swift-ring-builder.builder
4.平衡 ring:
# swift-ring-builder.builder rebalance

swift项目自己创建package swift存储 搭建,swift项目自己创建package swift存储 搭建_swift_24,第24张

3.创建Ring对象

1.切换到 ``/etc/swift``目录。创建基本``object.builder``文件:
# swift-ring-builder object.builder create 10 1 1
2.添加每个节点到 ring 中:
# swift-ring-builder object.builder add --region 1 --zone 1 --ip 192.168.100.20 --port 6000 --device sdc1 --weight 100
# swift-ring-builder object.builder add --region 1 --zone 1 --ip 192.168.100.20 --port 6000 --device sdd1 --weight 100
# swift-ring-builder object.builder add --region 1 --zone 1 --ip 192.168.100.10 --port 6000 --device sdc1 --weight 100
# swift-ring-builder object.builder add --region 1 --zone 1 --ip 192.168.100.10 --port 6000 --device sdb1 --weight 100
3.验证 ring 的内容:
# swift-ring-builder object.builder
4.平衡 ring:
# swift-ring-builder object.builder rebalance

swift项目自己创建package swift存储 搭建,swift项目自己创建package swift存储 搭建_swift_25,第25张

4.Compute节点复制Controller的配置文件
复制``account.ring.gz``,container.ring.gz``和``object.ring.gz 文件到每个存储节点和其他运行了代理服务的额外节点的 /etc/swift 目录。
[root@compute ~]# scp controller:/etc/swift/*.ring.gz /etc/swift/

swift项目自己创建package swift存储 搭建,swift项目自己创建package swift存储 搭建_swift项目自己创建package_26,第26张

5.启动服务

#### 1.在控制节点``Controller``上,启动对象存储代理服务及其依赖服务,并将它们配置为随系统启动:

# systemctl start openstack-swift-proxy.service memcached.service
# systemctl enable openstack-swift-proxy.service memcached.service

swift项目自己创建package swift存储 搭建,swift项目自己创建package swift存储 搭建_swift项目自己创建package_27,第27张

2.在存储节点Controller 和 Compute 两个节点上,启动对象存储服务,并将其设置为随系统启动

两个节点均需操作

# 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-account.service openstack-swift-account-auditor.service openstack-swift-account-reaper.service openstack-swift-account-replicator.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-container.service openstack-swift-container-auditor.service openstack-swift-container-replicator.service openstack-swift-container-updater.service

# systemctl start openstack-swift-object.service openstack-swift-object-auditor.service openstack-swift-object-replicator.service openstack-swift-object-updater.service
# systemctl enable openstack-swift-object.service openstack-swift-object-auditor.service openstack-swift-object-replicator.service openstack-swift-object-updater.service

6.Controller执行验证操作

#### 1.导入demo凭证

# . /root/admin-openrc

2. 显示服务状态:

# swift stat

swift项目自己创建package swift存储 搭建,swift项目自己创建package swift存储 搭建_python_28,第28张

3.创建容器1

# openstack create1

swift项目自己创建package swift存储 搭建,swift项目自己创建package swift存储 搭建_配置文件_29,第29张

4.上传一个测试文件到container1容器

# openstack object create1 /root/demo-openrc

swift项目自己创建package swift存储 搭建,swift项目自己创建package swift存储 搭建_swift_30,第30张

5.列出container1容器里的所有文件

# openstack object list1

swift项目自己创建package swift存储 搭建,swift项目自己创建package swift存储 搭建_swift_31,第31张

6.从container1容器里下载一个测试文件

# openstack object save1 /root/demo-openrc

swift项目自己创建package swift存储 搭建,swift项目自己创建package swift存储 搭建_配置文件_32,第32张



本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明原文出处。如若内容造成侵权/违法违规/事实不符,请联系SD编程学习网:675289112@qq.com进行投诉反馈,一经查实,立即删除!