1) 为所有存储节点安装Swift-Account, Swift-Container, Swift-Object等软件
[root@node2 ~]# pssh -h host-list.txt -i ' \
yum --enablerepo=centos-openstack-queens,epel install \
openstack-swift-account openstack-swift-container openstack-swift-object xfsprogs rsync openssh-clients -y'
[1] 19:55:30 [SUCCESS] root@192.168.10.13
[2] 19:55:30 [SUCCESS] root@192.168.10.14
[3] 19:55:30 [SUCCESS] root@192.168.10.15
2) 为所有存储节点分区、格式化并挂载
[root@node2 ~]# vim fdisk-vdc1.sh
#! /bin/bash
fdisk /dev/vdc << EOF
n
# 回车
# 回车
# 回车
# 回车
w
EOF
[root@node2 ~]# pscp.pssh -h host-list.txt fdisk-vdc1.sh /root/
[1] 20:06:35 [SUCCESS] root@192.168.10.14
[2] 20:06:35 [SUCCESS] root@192.168.10.15
[3] 20:06:35 [SUCCESS] root@192.168.10.13
[root@node2 ~]# pssh -h host-list.txt -i 'fdisk /dev/vdc < /root/fdisk-vdc1.sh'
[root@node2 ~]# pssh -h host-list.txt -i 'lsblk | grep vdc'
[1] 20:08:21 [SUCCESS] root@192.168.10.14
vdc 253:32 0 20G 0 disk
└─vdc1 253:33 0 20G 0 part
[2] 20:08:21 [SUCCESS] root@192.168.10.15
vdc 253:32 0 20G 0 disk
└─vdc1 253:33 0 20G 0 part
[3] 20:08:21 [SUCCESS] root@192.168.10.13
vdc 253:32 0 20G 0 disk
└─vdc1 253:33 0 20G 0 part
[root@node2 ~]# pssh -h host-list.txt -i 'mkfs.xfs -i size=1024 -s size=4096 /dev/vdc1'
[1] 20:09:04 [SUCCESS] root@192.168.10.13
meta-data=/dev/vdc1 isize=1024 agcount=4, agsize=1310656 blks
= sectsz=4096 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=5242624, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=4096 sunit=1 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
[2] 20:09:04 [SUCCESS] root@192.168.10.14
meta-data=/dev/vdc1 isize=1024 agcount=4, agsize=1310656 blks
= sectsz=4096 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=5242624, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=4096 sunit=1 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
[3] 20:09:04 [SUCCESS] root@192.168.10.15
meta-data=/dev/vdc1 isize=1024 agcount=4, agsize=1310656 blks
= sectsz=4096 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=5242624, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=4096 sunit=1 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
# 建立各节点的挂载点并挂载
[root@node3 ~]# mkdir -p /srv/node/device0
[root@node3 ~]# mount -o noatime,nodiratime,nobarrier /dev/vdc1 /srv/node/device0
[root@node3 ~]# chown -R swift. /srv/node
[root@node4 ~]# mkdir -p /srv/node/device1
[root@node4 ~]# mount -o noatime,nodiratime,nobarrier /dev/vdc1 /srv/node/device1
[root@node4 ~]# chown -R swift. /srv/node
[root@node5 ~]# mkdir -p /srv/node/device2
[root@node5 ~]# mount -o noatime,nodiratime,nobarrier /dev/vdc1 /srv/node/device2
[root@node5 ~]# chown -R swift. /srv/node
# 添加fstab
[root@node3 ~]# echo '/dev/vdc1 /srv/node/device0 xfs noatime,nodiratime,nobarrier 0 0' >> /etc/fstab
[root@node4 ~]# echo '/dev/vdc1 /srv/node/device1 xfs noatime,nodiratime,nobarrier 0 0' >> /etc/fstab
[root@node3 ~]# echo '/dev/vdc1 /srv/node/device2 xfs noatime,nodiratime,nobarrier 0 0' >> /etc/fstab
3) 复制Ring文件到所有节点并更改属主等信息
[root@node2 ~]# pscp.pssh -h host-list.txt /etc/swift/*.gz /etc/swift/
[1] 20:14:00 [SUCCESS] root@192.168.10.14
[2] 20:14:00 [SUCCESS] root@192.168.10.15
[3] 20:14:00 [SUCCESS] root@192.168.10.13
[root@node2 ~]# pssh -h host-list.txt -i 'chown swift. /etc/swift/*.gz'
[1] 20:15:56 [SUCCESS] root@192.168.10.14
[2] 20:15:56 [SUCCESS] root@192.168.10.15
[3] 20:15:56 [SUCCESS] root@192.168.10.13
[root@node2 ~]# pscp.pssh -h host-list.txt /etc/swift/swift.conf /etc/swift/
[1] 20:16:51 [SUCCESS] root@192.168.10.14
[2] 20:16:51 [SUCCESS] root@192.168.10.13
[3] 20:16:51 [SUCCESS] root@192.168.10.15
4) 设置所有存储节点上的account、container、object配置文件
[root@node3 ~]# cd /etc/swift/
[root@node3 swift]# vim account-server.conf container-server.conf object-server.conf
# 将三个文件的第6行,改为0.0.0.0
account-server.conf文件
......
bind_ip = 0.0.0.0
bind_port = 6202
......
container-server.conf文件
......
bind_ip = 0.0.0.0
bind_port = 6201
......
objecct-server.conf文件
......
bind_ip = 0.0.0.0
bind_port = 6200
......
5) 在所有的节点上配置rsync
[root@node3 ~]# vim /etc/rsyncd.conf
......
......
......
......
......
......
# 于最后添加如下内容
pid file = /var/run/rsyncd.pid
log file = /var/log/rsyncd.log
uid = swift
gid = swift
# 指定本机IP地址
address = 192.168.10.13
[account]
path = /srv/node
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 = /srv/node
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 = /srv/node
read only = false
write only = no
list = yes
incoming chmod = 0644
outgoing chmod = 0644
max connections = 25
lock file = /var/lock/object.lock
[swift_server]
path = /etc/swift
read only = true
write only = no
list = yes
incoming chmod = 0644
outgoing chmod = 0644
max connections = 5
lock file = /var/lock/swift_server.lock
[root@node4 ~]# vim /etc/rsyncd.conf
......
......
......
......
......
......
# 于最后添加如下内容
pid file = /var/run/rsyncd.pid
log file = /var/log/rsyncd.log
uid = swift
gid = swift
# 指定本机IP地址
address = 192.168.10.14
[account]
path = /srv/node
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 = /srv/node
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 = /srv/node
read only = false
write only = no
list = yes
incoming chmod = 0644
outgoing chmod = 0644
max connections = 25
lock file = /var/lock/object.lock
[swift_server]
path = /etc/swift
read only = true
write only = no
list = yes
incoming chmod = 0644
outgoing chmod = 0644
max connections = 5
lock file = /var/lock/swift_server.lock
[root@node5 ~]# vim /etc/rsyncd.conf
......
......
......
......
......
......
# 于最后添加如下内容
pid file = /var/run/rsyncd.pid
log file = /var/log/rsyncd.log
uid = swift
gid = swift
# 指定本机IP地址
address = 192.168.10.13
[account]
path = /srv/node
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 = /srv/node
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 = /srv/node
read only = false
write only = no
list = yes
incoming chmod = 0644
outgoing chmod = 0644
max connections = 25
lock file = /var/lock/object.lock
[swift_server]
path = /etc/swift
read only = true
write only = no
list = yes
incoming chmod = 0644
outgoing chmod = 0644
max connections = 5
lock file = /var/lock/swift_server.lock
6) 在所有节点设定SELinux
[root@node3 ~]# semanage fcontext -a -t swift_data_t /srv/node/device0
[root@node3 ~]# restorecon /srv/node/device0
[root@node4 ~]# semanage fcontext -a -t swift_data_t /srv/node/device1
[root@node4 ~]# restorecon /srv/node/device0
[root@node5 ~]# semanage fcontext -a -t swift_data_t /srv/node/device2
[root@node5 ~]# restorecon /srv/node/device0
7) 在所有节点设定防火墙
[root@node3 ~]# firewall-cmd --add-port={873/tcp,6200/tcp,6201/tcp,6202/tcp} --permanent
success
[root@node3 ~]# firewall-cmd --reload
success
[root@node4 ~]# firewall-cmd --add-port={873/tcp,6200/tcp,6201/tcp,6202/tcp} --permanent
success
[root@node4 ~]# firewall-cmd --reload
success
[root@node5 ~]# firewall-cmd --add-port={873/tcp,6200/tcp,6201/tcp,6202/tcp} --permanent
success
[root@node5 ~]# firewall-cmd --reload
success
8) 在所有节点上启动服务
[root@node3 ~]# systemctl enable --now rsyncd
[root@node3 ~]# for ringtype in account container object; do
systemctl start openstack-swift-$ringtype
systemctl enable openstack-swift-$ringtype
for service in replicator updater auditor; do
if [ $ringtype != 'account' ] || [ $service != 'updater' ]; then
systemctl start openstack-swift-$ringtype-$service
systemctl enable openstack-swift-$ringtype-$service
fi
done
done
|