1. 程式人生 > >Openstack 安裝之 Swift

Openstack 安裝之 Swift

openstack 版本為Q版

伺服器系統:centos7

控制節點:192.168.50.31

swift儲存節點: 192.168.50.32

swift儲存節點: 192.168.50.33

swift儲存節點: 192.168.50.33

所有儲存節點操作:

#安裝相關軟體
yum install xfsprogs rsync 

#格式化對應分割槽 
mkfs.xfs /dev/sdc1

#建立資料夾
mkdir -p /swift/node/sdc1

#fstab掛載磁碟
vim /etc/fstab
/dev/sdc1 /swift/node/sdc1 xfs noatime,nodiratime,nobarrier,logbufs=8 0 2

# mount掛載
mount /dev/sdc1 /swift/node/sdc1

# 編輯配置檔案
vim /etc/rsyncd.conf
 
uid = swift
gid = swift
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
address = 192.168.50.32(這裡有幾臺 就寫能對應的IP地址)

[account]
max connections = 2
path = /swift/node/
read only = False
lock file = /var/lock/account.lock

[container]
max connections = 2
path = /swift/node/
read only = False
lock file = /var/lock/container.lock

[object]
max connections = 2
path = /swift/node/
read only = False
lock file = /var/lock/object.lock


# 配置服務
systemctl enable rsyncd.service
systemctl start rsyncd.service


# 安裝swift
yum install openstack-swift-account openstack-swift-container \
  openstack-swift-object
  

# 下載替換配置檔案
curl -o /etc/swift/account-server.conf https://git.openstack.org/cgit/openstack/swift/plain/etc/account-server.conf-sample?h=stable/queens
curl -o /etc/swift/container-server.conf https://git.openstack.org/cgit/openstack/swift/plain/etc/container-server.conf-sample?h=stable/queens
curl -o /etc/swift/object-server.conf https://git.openstack.org/cgit/openstack/swift/plain/etc/object-server.conf-sample?h=stable/queens 


# 編輯配置檔案account-server.conf
vim /etc/swift/account-server.conf
[DEFAULT]
bind_ip = 192.168.50.32(對應儲存節點的IP)
bind_port = 6202
user = swift
swift_dir = /etc/swift
devices = /swift/node/
mount_check = True
[filter:recon]
use = egg:swift#recon
recon_cache_path = /var/cache/swift

# 編輯配置檔案container-server.conf
vim /etc/swift/container-server.conf
[DEFAULT]
bind_ip = 192.168.50.32(對應儲存節點的IP)
bind_port = 6201
user = swift
swift_dir = /etc/swift
devices = /swift/node/
mount_check = True

[pipeline:main]
pipeline = healthcheck recon container-server

[filter:recon]
use = egg:swift#recon
recon_cache_path = /var/cache/swift

# 編輯配置檔案object-server.conf
vim /etc/swift/object-server.conf
[DEFAULT]
bind_ip = 192.168.50.32(對應儲存節點的IP)
bind_port = 6200
user = swift
swift_dir = /etc/swift
devices = /swift/node/
mount_check = True
[pipeline:main]
pipeline = healthcheck recon object-server

[filter:recon]
use = egg:swift#recon
recon_cache_path = /var/cache/swift
recon_lock_path = /var/lock



# 建立資料夾 並設定許可權
chown -R swift:swift /swift/node/
mkdir -p /var/cache/swift
chown -R root:swift /var/cache/swift
chmod -R 775 /var/cache/swift

# 在控制節點操作

cd /etc/swift   在/etc/swift目錄下面操作

swift-ring-builder account.builder create 10 3 1
swift-ring-builder account.builder add \
  --region 1 --zone 1 --ip 192.168.50.32 --port 6202 --device sdc1 --weight 100
swift-ring-builder account.builder add \
  --region 1 --zone 1 --ip 192.168.50.33 --port 6202 --device sdc1 --weight 100
swift-ring-builder account.builder add \
  --region 1 --zone 1 --ip 192.168.50.34 --port 6202 --device sdc1 --weight 100 
swift-ring-builder account.builder
swift-ring-builder account.builder rebalance


swift-ring-builder container.builder create 10 3 1
swift-ring-builder container.builder add \
  --region 1 --zone 1 --ip 192.168.50.32 --port 6201 --device sdc1 --weight 100
swift-ring-builder container.builder add \
  --region 1 --zone 1 --ip 192.168.50.33 --port 6201 --device sdc1 --weight 100  
swift-ring-builder container.builder add \
  --region 1 --zone 1 --ip 192.168.50.34 --port 6201 --device sdc1 --weight 100 
swift-ring-builder container.builder
swift-ring-builder container.builder rebalance


swift-ring-builder object.builder create 10 3 1
swift-ring-builder object.builder add \
  --region 1 --zone 1 --ip 192.168.50.32 --port 6200 --device sdc1 --weight 100
swift-ring-builder object.builder add \
  --region 1 --zone 1 --ip 192.168.50.33 --port 6200 --device sdc1 --weight 100  
swift-ring-builder object.builder add \
  --region 1 --zone 1 --ip 192.168.50.34 --port 6200 --device sdc1 --weight 100  
swift-ring-builder object.builder
swift-ring-builder object.builder rebalance

#把/etc/swift的gz檔案複製到另外兩臺
scp /etc/swift/*.gz 
[email protected]
:/etc/swift scp /etc/swift/*.gz [email protected]:/etc/swift scp /etc/swift/*.gz [email protected]:/etc/swift # 下載替換配置檔案 curl -o /etc/swift/swift.conf \ https://git.openstack.org/cgit/openstack/swift/plain/etc/swift.conf-sample?h=stable/queens vim /etc/swift/swift.conf [swift-hash] swift_hash_path_suffix = jzdata swift_hash_path_prefix = jzdata [storage-policy:0] name = Policy-0 default = yes #把/etc/swift的swift.conf檔案複製到另外兩臺 scp /etc/swift/swift.conf
[email protected]
:/etc/swift scp /etc/swift/swift.conf [email protected]:/etc/swift scp /etc/swift/swift.conf [email protected]:/etc/swift # 配置服務 systemctl enable openstack-swift-proxy.service memcached.service systemctl restart openstack-swift-proxy.service memcached.service

所有儲存節點執行:

# 給/etc/swift 加許可權
chown -R root:swift /etc/swift
#配置服務
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-account.service openstack-swift-account-auditor.service \
  openstack-swift-account-reaper.service openstack-swift-account-replicator.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-container.service \
  openstack-swift-container-auditor.service openstack-swift-container-replicator.service \
  openstack-swift-container-updater.service
systemctl enable openstack-swift-object.service openstack-swift-object-auditor.service \
  openstack-swift-object-replicator.service openstack-swift-object-updater.service
systemctl start openstack-swift-object.service openstack-swift-object-auditor.service \
  openstack-swift-object-replicator.service openstack-swift-object-updater.service