天天看點

openstack pike安裝swift 對象存儲--centos 7.4 (十)

一、控制節點(192.168.26.240)

1.source admin-openstack.sh  #獲得admin憑證

2.建立 swift 使用者,給 swift 使用者添加 admin 角色:

  1. openstack user create --domain default --password=swift swift  
  2. openstack role add --project service --user swift admin  

3. 建立  swift  服務條目,建立對象存儲服務 API 端點,dashboard中看效果

openstack service create --name swift   --description "OpenStack Object Storage" object-store
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
           
openstack pike安裝swift 對象存儲--centos 7.4 (十)

4.安裝軟體包

yum install openstack-swift-proxy python-swiftclient python-keystoneclient python-keystonemiddleware memcached -y
           

5. 從對象存儲的倉庫源中擷取代理服務的配置檔案

curl -o /etc/swift/proxy-server.conf https://git.openstack.org/cgit/openstack/swift/plain/etc/proxy-server.conf-sample?h=stable/pike
           

6.配置檔案

# vi /etc/swift/proxy-server.conf 
#在[DEFAULT]項,配置Swift對象存儲服務元件使用的端口、使用者和配置路徑
[DEFAULT]
# bind_ip = 0.0.0.0
bind_port = 8080
# bind_timeout = 30
# backlog = 4096
swift_dir = /etc/swift
user = swift
#在[pipeline:main]項,啟用相關的子產品
[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]項,啟用自動賬戶建立
[app:proxy-server]
use = egg:swift#proxy
account_autocreate = true
#在[filter:keystoneauth]項,配置操作使用者角色
[filter:keystoneauth]
use = egg:swift#keystoneauth
operator_roles = admin, user
#在[filter:authtoken]項,配置keystone身份認證服務元件通路
[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 = swift
delay_auth_decision = True
#在[filter:cache]項,配置MemCached的通路路徑
[filter:cache]
use = egg:swift#memcache
memcache_servers = controller:11211
           

二、存儲節點配置(192.168.26.242),sda系統盤,sdb資料盤,xfs格式

1.安裝服務工具包

yum install xfsprogs rsync -y
           

2.資料盤配置 /dev/sdb

mkfs.xfs /dev/sdb  #格式化xfs
mkdir -p /srv/node/sdb  #建立挂載點目錄結構
#編輯``/etc/fstab``檔案并添加以下内容
/dev/sdb /srv/node/sdb xfs noatime,nodiratime,nobarrier,logbufs=8 0 2
 mount /srv/node/sdb   #挂載硬碟
           
openstack pike安裝swift 對象存儲--centos 7.4 (十)

3.檔案配置rsync

vi /etc/rsyncd.conf
uid = swift
gid = swift
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
address = 192.168.26.242
[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” 服務和配置它随系統啟動
systemctl enable rsyncd.service
systemctl start rsyncd.service
           

4.安裝和配置Swift對象存儲服務元件

#安裝軟體包
yum install openstack-swift-account openstack-swift-container \
  openstack-swift-object
           
#從對象存儲源倉庫中擷取accounting, container以及object服務配置檔案
curl -o /etc/swift/account-server.conf https://git.openstack.org/cgit/openstack/swift/plain/etc/account-server.conf-sample?h=stable/pike
curl -o /etc/swift/container-server.conf https://git.openstack.org/cgit/openstack/swift/plain/etc/container-server.conf-sample?h=stable/pike
curl -o /etc/swift/object-server.conf https://git.openstack.org/cgit/openstack/swift/plain/etc/object-server.conf-sample?h=stable/pike
           
vi /etc/swift/account-server.conf
[DEFAULT]
bind_ip = 192.168.26.242
bind_port = 6002
# bind_timeout = 30
# backlog = 4096
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
           
vi /etc/swift/container-server.conf
[DEFAULT]
bind_ip = 192.168.26.242
bind_port = 6001
# bind_timeout = 30
# backlog = 4096
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
           
vi /etc/swift/object-server.conf
[DEFAULT]
bind_ip = 192.168.26.242
bind_port = 6000
# bind_timeout = 30
# backlog = 4096
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
recon_lock_path = /var/lock
           

5.建立目錄,更改權限

chown -R swift:swift /srv/node
mkdir -p /var/cache/swift
chown -R root:swift /var/cache/swift
chmod -R 775 /var/cache/swift
           

三、控制節點:

1.建立目錄,更改權限建立,分發并初始化環(rings)

#在/etc/swift/目錄建立賬戶Account Ring,隻有一個硬碟,隻能建立一個副本
swift-ring-builder account.builder create 10 1 1  #建立基本 account.builder 檔案
#添加每個節點到 ring 中
swift-ring-builder account.builder add  \
 --region 1 --zone 1 --ip 192.168.26.242 --port 6002 --device sdb --weight 100
swift-ring-builder account.builder  #驗證 ring 的内容
[[email protected] swift]# swift-ring-builder account.builder
account.builder, build version 2, id 5a28a7bcb2d843f3ab511975cffbe299
1024 partitions, 1.000000 replicas, 1 regions, 1 zones, 1 devices, 0.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 is up-to-date
Devices:   id region zone     ip address:port replication ip:port  name weight partitions balance flags meta
            0      1    1 192.168.26.242:6002 192.168.26.242:6002   sdb 500.00       1024    0.00     
swift-ring-builder account.builder rebalance   #平衡 ring
#在/etc/swift/目錄建立容器container.builder,隻有一個硬碟,隻能建立一個副本
swift-ring-builder container.builder create 10 1 1  #建立基本 container.builder 檔案
#添加每個節點到 ring 中
swift-ring-builder container.builder add  \
 --region 1 --zone 1 --ip 192.168.26.242 --port 6001 --device sdb --weight 100
swift-ring-builder container.builder  #驗證 ring 的内容     
swift-ring-builder container.builder rebalance   #平衡 ring
#在/etc/swift/目錄建立對象object.builder,隻有一個硬碟,隻能建立一個副本
swift-ring-builder object.builder create 10 1 1  #建立基本 object.builder 檔案
#添加每個節點到 ring 中
swift-ring-builder container.builder add  \
 --region 1 --zone 1 --ip 192.168.26.242 --port 6000 --device sdb --weight 100
swift-ring-builder object.builder  #驗證 ring 的内容     
swift-ring-builder object.builder   #平衡 ring
           

2.複制``account.ring.gz``,container.ring.gz``和``object.ring.gz 檔案到每個存儲節點和其他運作了代理服務的額外節點的 /etc/swift 目錄。

3.配置/etc/swift/swift.conf

#從對象存儲源倉庫中擷取 /etc/swift/swift.conf 檔案
curl -o /etc/swift/swift.conf \
  https://git.openstack.org/cgit/openstack/swift/plain/etc/swift.conf-sample?h=stable/pike
vi /etc/swift/swift.conf
[swift-hash]
swift_hash_path_suffix = start
swift_hash_path_prefix = end
[storage-policy:0]
name = Policy-0
default = yes
複制``swift.conf`` 檔案到每個存儲節點和其他允許了代理服務的額外節點的 /etc/swift 目錄,
修改權限:chown -R root:swift /etc/swift/*
           

四、啟動服務:swift-init all start

#控制節點
systemctl enable openstack-swift-proxy.service memcached.service
systemctl start openstack-swift-proxy.service memcached.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-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
           

五:驗證:swift stat

openstack pike安裝swift 對象存儲--centos 7.4 (十)
openstack pike安裝swift 對象存儲--centos 7.4 (十)