写点什么

(九)OpenStack---M 版 --- 双节点搭建 ---Swift 安装和配置 (单存储节点)

作者:指剑
  • 2022-11-30
    重庆
  • 本文字数:5380 字

    阅读完需:约 18 分钟

(九)OpenStack---M版---双节点搭建---Swift安装和配置(单存储节点)

↓↓↓↓↓↓↓↓视频已上线 B 站↓↓↓↓↓↓↓↓

》》》》》》传送门

本次搭建仅采用 Compute 单节点做 swift 组件

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

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

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

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

5.启动服务

6.Controller执行验证操作

<h2 id="1">1.Controller 安装并配置控制节点</h2>

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
复制代码


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
复制代码



3.安装并配置组件

[root@controller ~]# yum -y install openstack-swift-proxy python-swiftclient python-keystoneclient python-keystonemiddleware memcached

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

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

[DEFAULT]bind_port = 8080swift_dir = /etc/swiftuser = 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#proxyaccount_autocreate = True[filter:tempauth]use = egg:swift#tempauthuser_admin_admin = admin .admin .reseller_adminuser_test_tester = testing .adminuser_test2_tester2 = testing2 .adminuser_test_tester3 = testing3user_test5_tester5 = testing5 service[filter:authtoken]paste.filter_factory = keystonemiddleware.auth_token:filter_factoryauth_uri = http://controller:5000auth_url = http://controller:35357memcached_servers = controller:11211auth_type = passwordproject_domain_name = defaultuser_domain_name = defaultproject_name = serviceusername = swiftpassword = 000000delay_auth_decision = True[filter:keystoneauth]use = egg:swift#keystoneauthoperator_roles = admin,user[filter:healthcheck]use = egg:swift#healthcheck[filter:cache]memcache_servers = controller:11211use = 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 = changemeswift_hash_path_prefix = changeme[storage-policy:0]name = Policy-0default = yesaliases = yellow, orange[swift-constraints]
复制代码


添加权限
# chown -R root:swift /etc/swift
复制代码



<h2 id="2">2.Compute 安装和配置存储节点</h2>

1.安装软件包
[root@compute ~]# yum -y install xfsprogs rsync openstack-swift-account openstack-swift-container openstack-swift-object
复制代码
2.使用 XFS 格式化`/dev/sdc``设备

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


# lsblk
复制代码



创建分区


# fdisk /dev/sdc
复制代码



# mkfs.xfs  /dev/sdc1
复制代码


3.创建挂载点目录结构
[root@compute ~]# mkdir -p /swift/node
复制代码


4.编辑/etc/fstab文件并添加以下内容
# vi /etc/fstab
/dev/sdc1 /swift/node xfs noatime,nodiratime,nobarrier,logbufs=8 0 0
复制代码


5.挂载设备
[root@compute ~]# mount /dev/sdc1 /swift/node/
复制代码


6.编辑/etc/rsyncd.conf文件并添加以下内容
[root@compute ~]#vi /etc/rsyncd.conf
pid file = /var/run/rsyncd.pidlog file = /var/log/rsyncd.loguid = swiftgid = swiftaddress = 127.0.0.1[account]path = /swift/noderead only = falsewrite only = nolist = yesincoming chmod = 0644outgoing chmod = 0644max connections = 25lock file = /var/lock/account.lock[container]path = /swift/noderead only = falsewrite only = nolist = yesincoming chmod = 0644outgoing chmod = 0644max connections = 25lock file = /var/lock/container.lock[object]path = /swift/noderead only = falsewrite only = nolist = yesincoming chmod = 0644outgoing chmod = 0644max connections = 25lock file = /var/lock/object.lock[swift_server]path = /etc/swiftread only = truewrite only = nolist = yesincoming chmod = 0644outgoing chmod = 0644max connections = 5lock file = /var/lock/swift_server.lock
复制代码


7.启动 “rsyncd” 服务和配置它随系统启动
# systemctl start rsyncd.service# systemctl enable rsyncd.service
复制代码



<h2 id="3">3.Compute 节点安装并配置组件</h2>

1.编辑 /etc/swift/account-server.conf 文件,删除原有内容,直接添加以下内容
#vi /etc/swift/account-server.conf
[DEFAULT]bind_port = 6002user = swiftswift_dir = /etc/swiftdevices = /swift/nodemount_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#reconrecon_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_port = 6001user = swiftswift_dir = /etc/swiftdevices = /swift/nodemount_check = false[pipeline:main]pipeline = healthcheck recon container-server[app:container-server]use = egg:swift#container[filter:healthcheck]use = egg:swift#healthcheck[filter:recon]use = egg:swift#reconrecon_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_port = 6000user = swiftswift_dir = /etc/swiftdevices = /swift/nodemount_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#reconrecon_cache_path = /var/cache/swiftrecon_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 = changemeswift_hash_path_prefix = changeme[storage-policy:0]name = Policy-0default = yesaliases = yellow, orange[swift-constraints]
复制代码


5.确认挂载点目录结构是否有合适的所有权:
# chown -R swift:swift /swift/node
复制代码


6.创建 “recon” 目录和确保它有合适的所有权:
# mkdir -p /var/cache/swift# chown -R root:swift /var/cache/swift# chmod -R 775 /var/cache/swift# chown -R root:swift /etc/swift
复制代码



<h2 id="4">4.Controller 节点创建,分发并初始化 rings</h2>

1.创建账户 ring

1.切换到 ``/etc/swift``目录。创建基本 account.builder 文件:
# cd /etc/swift# swift-ring-builder account.builder create 18 1 12.添加每个节点到 ring 中:# swift-ring-builder account.builder add --region 1 --zone 1 --ip 192.168.100.20 --port 6002 --device sdc1 --weight 1003.验证ring内容# swift-ring-builder account.builder4.平衡ring# swift-ring-builder account.builder rebalance
复制代码


2.创建 ring 容器

1.切换到 ``/etc/swift``目录。创建基本``container.builder``文件:# cd /etc/swift# swift-ring-builder container.builder create 10 1 12.添加每个节点到 ring 中:# swift-ring-builder container.builder add --region 1 --zone 1 --ip 192.168.100.20 --port 6001 --device sdc1 --weight 1003.验证 ring 的内容:# swift-ring-builder container.builder4.平衡 ring:# swift-ring-builder container.builder rebalance
复制代码


3.创建 Ring 对象

1.切换到 ``/etc/swift``目录。创建基本``object.builder``文件:# swift-ring-builder object.builder create 10 1 12.添加每个节点到 ring 中:# swift-ring-builder object.builder add --region 1 --zone 1 --ip 192.168.100.20 --port 6000 --device sdc1 --weight 1003.验证 ring 的内容:# swift-ring-builder object.builder4.平衡 ring:# swift-ring-builder object.builder rebalance
复制代码


4.Compute 节点复制 Controller 的配置文件

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



<h2 id="5">5.启动服务</h2>

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

# systemctl start openstack-swift-proxy.service memcached.service# systemctl enable openstack-swift-proxy.service memcached.service
复制代码


2.在存储节点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
复制代码



<h2 id="6">6.Controller 执行验证操作</h2>

1.导入 demo 凭证

# . /root/demo-openrc
复制代码

2. 显示服务状态:

# swift stat 
复制代码


3.创建容器 container1

# openstack container create container1
复制代码


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

# openstack object create container1 /root/demo-openrc
复制代码


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

# openstack object list container1
复制代码


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

# openstack object save container1 /root/demo-openrc
复制代码



发布于: 刚刚阅读数: 3
用户头像

指剑

关注

InfoQ签约作者 2022-07-13 加入

AWS社区建设者,AWS学生大使,微软学生大使,阿里云签约作者,Info Q签约作者,CSDN博客专家,华为云云享专家

评论

发布
暂无评论
(九)OpenStack---M版---双节点搭建---Swift安装和配置(单存储节点)_centos_指剑_InfoQ写作社区