Openstack Swift 对象存储集群部署

依赖包安装:
# yum install git curl gcc memcached rsync sqlite xfsprogs git-core libffi-devel xinetd python-setuptools python-coverage python-devel python-nose python-simplejson pyxattr python-eventlet python-greenlet python-paste-deploy python-netifaces python-pip python-dns python-mock
 
Swift-proxy 节点部署:
 
     安装软件包:(默认使用keystone认证)
# yum install openstack-swift-proxy python-swiftclient python-keystoneclient python-keystonemiddleware memcached
 
修改 /etc/swift/proxy-server.conf如下:
修改 [DEFAULT]模块:
[DEFAULT]
bind_ip = 127.0.0.1    (提供服务的ip)
bind_port = 8080
user = swift
swift_dir = /etc/swift
 
如果使用keystone认证,修改 [pipeline:main] 配置信息下:(删除tempurl和 tempauth 模块,添加   authtoken and keystoneauth模块
[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]设置keystone认证角色:(使用keystone时才配置)
[filter:keystoneauth]
use = egg:swift#keystoneauth
...
operator_roles = admin,user
修改 [filter:authtoken]设置自动认证模块:
[filter:authtoken]
paste.filter_factory = keystonemiddleware.auth_token:filter_factory
...
auth_uri = http://127.0.0.1:5000
auth_url = http://127.0.0.1:35357
memcached_servers = 127.0.0.1:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = swift
password = SWIFT_PASS
delay_auth_decision = True
修改 [filter:cache]设置缓存服务器:
[filter:cache]
use = egg:swift#memcache
...
memcache_servers = 127.0.0.1:11211
 
 
Storage 节点部署:
 
安装依赖包:
# yum install xfsprogs rsync
格式化磁盘,将本地需要加入storage节点的磁盘格式化成 XFS 文件系统
# mkfs.xfs /dev/sdb
# mkfs.xfs /dev/sdc
......
创建目录挂载点:
# mkdir -p /srv/node/sdb
# mkdir -p /srv/node/sdc
....
挂载目录,先编辑 /etc/fstab文件:
#vim /etc/fstab
/dev/sdb /srv/node/sdb xfs noatime,nodiratime,nobarrier,logbufs=8 0 2
/dev/sdc /srv/node/sdc xfs noatime,nodiratime,nobarrier,logbufs=8 0 2
......
 
# mount -a
配置同步设置,创建或修改 /etc/rsyncd.conf文件,没有就创建然后改成如下内容:
uid = swift
gid = swift
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
address = MANAGEMENT_INTERFACE_IP_ADDRESS   (这里用storage节点的管理ip替换,如果没有专门的管理网络,用主网ip)

[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
 
安装软件包:
# yum install openstack-swift-account openstack-swift-container openstack-swift-object
配置account-server: 修改/etc/swift/account-server.conf 文件为如下内容:(没有就添加)
[DEFAULT]
...
bind_ip = MANAGEMENT_INTERFACE_IP_ADDRESS     (这里用storage节点的管理ip替换,如果没有专门的管理网络,用主网ip)
bind_port = 6202
user = swift
swift_dir = /etc/swift
devices = /srv/node
mount_check = True
[pipeline:main]
pipeline = healthcheck recon account-server
[filter:healthcheck]
use = egg:swift#healthcheck
 
[filter:recon]
use = egg:swift#recon
...
recon_cache_path = /var/cache/swift
配置container-server:修改 /etc/swift/container-server.conf 文件为如下内容:(没有就添加)
[DEFAULT]
...
bind_ip = MANAGEMENT_INTERFACE_IP_ADDRESS
bind_port = 6201
user = swift
swift_dir = /etc/swift
devices = /srv/node
mount_check = True
[pipeline:main]
pipeline = healthcheck recon container-server
[filter:healthcheck]
use = egg:swift#healthcheck
 
[filter:recon]
use = egg:swift#recon
...
recon_cache_path = /var/cache/swift
配置object-server:修改  /etc/swift/object-server.conf 文件为如下内容:(没有就添加)
[DEFAULT]
...
bind_ip = MANAGEMENT_INTERFACE_IP_ADDRESS
bind_port = 6200
user = swift
swift_dir = /etc/swift
devices = /srv/node
mount_check = True
[pipeline:main]
pipeline = healthcheck recon object-server
[filter:healthcheck]
use = egg:swift#healthcheck
 
[filter:recon]
use = egg:swift#recon
...
recon_cache_path = /var/cache/swift
recon_lock_path = /var/lock
授权swift用户管理挂载的存储目录:
# chown -R swift:swift /srv/node
 
创建数据缓存目录并授权:
# mkdir -p /var/cache/swift
# chown -R root:swift /var/cache/swift
# chmod -R 775 /var/cache/swift
 
创建相应的ring文件:
# swift-ring-builder account.builder create 15 3 1     (15表示分区数为2^15,3表示副本数为3,1表示最大复制时间为1小时)这些数据需要根据具体环境计算得出
# swift-ring-builder container.builder create 15 3 1
# swift-ring-builder object.builder create 15 3 1
向ring中添加磁盘:
格式如下:
# swift-ring-builder account.builder \
  add --region 1 --zone 1 --ip STORAGE_NODE_MANAGEMENT_INTERFACE_IP_ADDRESS --port 6202 \
  --device DEVICE_NAME --weight DEVICE_WEIGHT
# swift-ring-builder container.builder \
  add --region 1 --zone 1 --ip STORAGE_NODE_MANAGEMENT_INTERFACE_IP_ADDRESS --port 6201 \
  --device DEVICE_NAME --weight DEVICE_WEIGHT
# swift-ring-builder object.builder \
  add --region 1 --zone 1 --ip STORAGE_NODE_MANAGEMENT_INTERFACE_IP_ADDRESS --port 6200 \
  --device DEVICE_NAME --weight DEVICE_WEIGHT
具体操作实例:
[root@cnsz20pl2644 swift]# swift-ring-builder account.builder add r1z1-192.168.99.230:6202/sdb 100
Device d0r1z1-192.168.99.230:6202R192.168.99.230:6202/sdb_"" with 100.0 weight got id 0
[root@cnsz20pl2644 swift]# swift-ring-builder account.builder add r1z1-192.168.99.230:6202/sdc 100
Device d1r1z1-192.168.99.230:6202R192.168.99.230:6202/sdc_"" with 100.0 weight got id 1
[root@cnsz20pl2644 swift]# swift-ring-builder account.builder add r1z1-192.168.99.230:6202/sdd 100
Device d2r1z1-192.168.99.230:6202R192.168.99.230:6202/sdd_"" with 100.0 weight got id 2
[root@cnsz20pl2644 swift]# swift-ring-builder account.builder add r1z1-192.168.99.230:6202/sde 100
Device d3r1z1-192.168.99.230:6202R192.168.99.230:6202/sde_"" with 100.0 weight got id 3
[root@cnsz20pl2644 swift]# swift-ring-builder account.builder add r1z2-192.168.99.231:6202/sdb 100
Device d4r1z2-192.168.99.231:6202R192.168.99.231:6202/sdb_"" with 100.0 weight got id 4
[root@cnsz20pl2644 swift]# swift-ring-builder account.builder add r1z2-192.168.99.231:6202/sdc 100
Device d5r1z2-192.168.99.231:6202R192.168.99.231:6202/sdc_"" with 100.0 weight got id 5
[root@cnsz20pl2644 swift]# swift-ring-builder account.builder add r1z2-192.168.99.231:6202/sdd 100
Device d6r1z2-192.168.99.231:6202R192.168.99.231:6202/sdd_"" with 100.0 weight got id 6
[root@cnsz20pl2644 swift]# swift-ring-builder account.builder add r1z2-192.168.99.231:6202/sde 100
Device d7r1z2-192.168.99.231:6202R192.168.99.231:6202/sde_"" with 100.0 weight got id 7
[root@cnsz20pl2644 swift]# swift-ring-builder account.builder add r1z3-192.168.99.232:6202/sdb 100
Device d8r1z3-192.168.99.232:6202R192.168.99.232:6202/sdb_"" with 100.0 weight got id 8
[root@cnsz20pl2644 swift]# swift-ring-builder account.builder add r1z3-192.168.99.232:6202/sdc 100
Device d9r1z3-192.168.99.232:6202R192.168.99.232:6202/sdc_"" with 100.0 weight got id 9
[root@cnsz20pl2644 swift]# swift-ring-builder account.builder add r1z3-192.168.99.232:6202/sdd 100
Device d10r1z3-192.168.99.232:6202R192.168.99.232:6202/sdd_"" with 100.0 weight got id 10
[root@cnsz20pl2644 swift]# swift-ring-builder account.builder add r1z3-192.168.99.232:6202/sde 100
Device d11r1z3-192.168.99.232:6202R192.168.99.232:6202/sde_"" with 100.0 weight got id 11
 
[root@cnsz20pl2644 swift]# swift-ring-builder container.builder add r1z1-192.168.99.230:6201/sdb 100
Device d0r1z1-192.168.99.230:6201R192.168.99.230:6201/sdb_"" with 100.0 weight got id 0
[root@cnsz20pl2644 swift]# swift-ring-builder container.builder add r1z1-192.168.99.230:6201/sdc 100
Device d1r1z1-192.168.99.230:6201R192.168.99.230:6201/sdc_"" with 100.0 weight got id 1
[root@cnsz20pl2644 swift]# swift-ring-builder container.builder add r1z1-192.168.99.230:6201/sdd 100
Device d2r1z1-192.168.99.230:6201R192.168.99.230:6201/sdd_"" with 100.0 weight got id 2
[root@cnsz20pl2644 swift]# swift-ring-builder container.builder add r1z1-192.168.99.230:6201/sde 100
Device d3r1z1-192.168.99.230:6201R192.168.99.230:6201/sde_"" with 100.0 weight got id 3
[root@cnsz20pl2644 swift]# swift-ring-builder container.builder add r1z2-192.168.99.231:6201/sdb 100
Device d4r1z2-192.168.99.231:6201R192.168.99.231:6201/sdb_"" with 100.0 weight got id 4
[root@cnsz20pl2644 swift]# swift-ring-builder container.builder add r1z2-192.168.99.231:6201/sdc 100
Device d5r1z2-192.168.99.231:6201R192.168.99.231:6201/sdc_"" with 100.0 weight got id 5
[root@cnsz20pl2644 swift]# swift-ring-builder container.builder add r1z2-192.168.99.231:6201/sdd 100
Device d6r1z2-192.168.99.231:6201R192.168.99.231:6201/sdd_"" with 100.0 weight got id 6
[root@cnsz20pl2644 swift]# swift-ring-builder container.builder add r1z2-192.168.99.231:6201/sde 100
Device d7r1z2-192.168.99.231:6201R192.168.99.231:6201/sde_"" with 100.0 weight got id 7
[root@cnsz20pl2644 swift]# swift-ring-builder container.builder add r1z3-192.168.99.232:6201/sdb 100
Device d8r1z3-192.168.99.232:6201R192.168.99.232:6201/sdb_"" with 100.0 weight got id 8
[root@cnsz20pl2644 swift]# swift-ring-builder container.builder add r1z3-192.168.99.232:6201/sdc 100
Device d9r1z3-192.168.99.232:6201R192.168.99.232:6201/sdc_"" with 100.0 weight got id 9
[root@cnsz20pl2644 swift]# swift-ring-builder container.builder add r1z3-192.168.99.232:6201/sdd 100
Device d10r1z3-192.168.99.232:6201R192.168.99.232:6201/sdd_"" with 100.0 weight got id 10
[root@cnsz20pl2644 swift]# swift-ring-builder container.builder add r1z3-192.168.99.232:6201/sde 100
Device d11r1z3-192.168.99.232:6201R192.168.99.232:6201/sde_"" with 100.0 weight got id 11
 
[root@cnsz20pl2644 swift]# swift-ring-builder object.builder add r1z1-192.168.99.230:6200/sdb 100
Device d0r1z1-192.168.99.230:6200R192.168.99.230:6200/sdb_"" with 100.0 weight got id 0
[root@cnsz20pl2644 swift]# swift-ring-builder object.builder add r1z1-192.168.99.230:6200/sdc 100
Device d1r1z1-192.168.99.230:6200R192.168.99.230:6200/sdc_"" with 100.0 weight got id 1
[root@cnsz20pl2644 swift]# swift-ring-builder object.builder add r1z1-192.168.99.230:6200/sdd 100
Device d2r1z1-192.168.99.230:6200R192.168.99.230:6200/sdd_"" with 100.0 weight got id 2
[root@cnsz20pl2644 swift]# swift-ring-builder object.builder add r1z1-192.168.99.230:6200/sde 100
Device d3r1z1-192.168.99.230:6200R192.168.99.230:6200/sde_"" with 100.0 weight got id 3
[root@cnsz20pl2644 swift]# swift-ring-builder object.builder add r1z2-192.168.99.231:6200/sdb 100
Device d4r1z2-192.168.99.231:6200R192.168.99.231:6200/sdb_"" with 100.0 weight got id 4
[root@cnsz20pl2644 swift]# swift-ring-builder object.builder add r1z2-192.168.99.231:6200/sdc 100
Device d5r1z2-192.168.99.231:6200R192.168.99.231:6200/sdc_"" with 100.0 weight got id 5
[root@cnsz20pl2644 swift]# swift-ring-builder object.builder add r1z2-192.168.99.231:6200/sdd 100
Device d6r1z2-192.168.99.231:6200R192.168.99.231:6200/sdd_"" with 100.0 weight got id 6
[root@cnsz20pl2644 swift]# swift-ring-builder object.builder add r1z2-192.168.99.231:6200/sde 100
Device d7r1z2-192.168.99.231:6200R192.168.99.231:6200/sde_"" with 100.0 weight got id 7
[root@cnsz20pl2644 swift]# swift-ring-builder object.builder add r1z3-192.168.99.232:6200/sdb 100
Device d8r1z3-192.168.99.232:6200R192.168.99.232:6200/sdb_"" with 100.0 weight got id 8
[root@cnsz20pl2644 swift]# swift-ring-builder object.builder add r1z3-192.168.99.232:6200/sdc 100
Device d9r1z3-192.168.99.232:6200R192.168.99.232:6200/sdc_"" with 100.0 weight got id 9
[root@cnsz20pl2644 swift]# swift-ring-builder object.builder add r1z3-192.168.99.232:6200/sdd 100
Device d10r1z3-192.168.99.232:6200R192.168.99.232:6200/sdd_"" with 100.0 weight got id 10
[root@cnsz20pl2644 swift]# swift-ring-builder object.builder add r1z3-192.168.99.232:6200/sde 100
Device d11r1z3-192.168.99.232:6200R192.168.99.232:6200/sde_"" with 100.0 weight got id 11
确认ring信息:
[root@cnsz20pl2644 swift]# swift-ring-builder account.builder
account.builder, build version 12, id eed5b8a4355c4b17b9059b30833e22e5
32768 partitions, 3.000000 replicas, 1 regions, 3 zones, 12 devices, 100.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 not found, probably it hasn't been written yet
Devices:   id region zone    ip address:port replication ip:port  name weight partitions balance flags meta
            0      1    1 192.168.99.230:6202  192.168.99.230:6202   sdb 100.00          0 -100.00       
            1      1    1 192.168.99.230:6202  192.168.99.230:6202   sdc 100.00          0 -100.00       
            2      1    1 192.168.99.230:6202  192.168.99.230:6202   sdd 100.00          0 -100.00       
            3      1    1 192.168.99.230:6202  192.168.99.230:6202   sde 100.00          0 -100.00       
            4      1    2 192.168.99.231:6202  192.168.99.231:6202   sdb 100.00          0 -100.00       
            5      1    2 192.168.99.231:6202  192.168.99.231:6202   sdc 100.00          0 -100.00       
            6      1    2 192.168.99.231:6202  192.168.99.231:6202   sdd 100.00          0 -100.00       
            7      1    2 192.168.99.231:6202  192.168.99.231:6202   sde 100.00          0 -100.00       
            8      1    3 192.168.99.232:6202  192.168.99.232:6202   sdb 100.00          0 -100.00       
            9      1    3 192.168.99.232:6202  192.168.99.232:6202   sdc 100.00          0 -100.00       
           10      1    3 192.168.99.232:6202  192.168.99.232:6202   sdd 100.00          0 -100.00       
           11      1    3 192.168.99.232:6202  192.168.99.232:6202   sde 100.00          0 -100.00       
[root@cnsz20pl2644 swift]# swift-ring-builder container.builder
container.builder, build version 12, id 126c240155e1446d98cb41cbd456f5a4
32768 partitions, 3.000000 replicas, 1 regions, 3 zones, 12 devices, 100.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 container.ring.gz not found, probably it hasn't been written yet
Devices:   id region zone    ip address:port replication ip:port  name weight partitions balance flags meta
            0      1    1 192.168.99.230:6201  192.168.99.230:6201   sdb 100.00          0 -100.00       
            1      1    1 192.168.99.230:6201  192.168.99.230:6201   sdc 100.00          0 -100.00       
            2      1    1 192.168.99.230:6201  192.168.99.230:6201   sdd 100.00          0 -100.00       
            3      1    1 192.168.99.230:6201  192.168.99.230:6201   sde 100.00          0 -100.00       
            4      1    2 192.168.99.231:6201  192.168.99.231:6201   sdb 100.00          0 -100.00       
            5      1    2 192.168.99.231:6201  192.168.99.231:6201   sdc 100.00          0 -100.00       
            6      1    2 192.168.99.231:6201  192.168.99.231:6201   sdd 100.00          0 -100.00       
            7      1    2 192.168.99.231:6201  192.168.99.231:6201   sde 100.00          0 -100.00       
            8      1    3 192.168.99.232:6201  192.168.99.232:6201   sdb 100.00          0 -100.00       
            9      1    3 192.168.99.232:6201  192.168.99.232:6201   sdc 100.00          0 -100.00       
           10      1    3 192.168.99.232:6201  192.168.99.232:6201   sdd 100.00          0 -100.00       
           11      1    3 192.168.99.232:6201  192.168.99.232:6201   sde 100.00          0 -100.00       
[root@cnsz20pl2644 swift]# swift-ring-builder object.builder
object.builder, build version 12, id 8b9eba9963d242b18665dad9e68e0d0f
32768 partitions, 3.000000 replicas, 1 regions, 3 zones, 12 devices, 100.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 object.ring.gz not found, probably it hasn't been written yet
Devices:   id region zone    ip address:port replication ip:port  name weight partitions balance flags meta
            0      1    1 192.168.99.230:6200  192.168.99.230:6200   sdb 100.00          0 -100.00       
            1      1    1 192.168.99.230:6200  192.168.99.230:6200   sdc 100.00          0 -100.00       
            2      1    1 192.168.99.230:6200  192.168.99.230:6200   sdd 100.00          0 -100.00       
            3      1    1 192.168.99.230:6200  192.168.99.230:6200   sde 100.00          0 -100.00       
            4      1    2 192.168.99.231:6200  192.168.99.231:6200   sdb 100.00          0 -100.00       
            5      1    2 192.168.99.231:6200  192.168.99.231:6200   sdc 100.00          0 -100.00       
            6      1    2 192.168.99.231:6200  192.168.99.231:6200   sdd 100.00          0 -100.00       
            7      1    2 192.168.99.231:6200  192.168.99.231:6200   sde 100.00          0 -100.00       
            8      1    3 192.168.99.232:6200  192.168.99.232:6200   sdb 100.00          0 -100.00       
            9      1    3 192.168.99.232:6200  192.168.99.232:6200   sdc 100.00          0 -100.00       
           10      1    3 192.168.99.232:6200  192.168.99.232:6200   sdd 100.00          0 -100.00       
           11      1    3 192.168.99.232:6200  192.168.99.232:6200   sde 100.00          0 -100.00
平衡所有的ring:
# swift-ring-builder account.builder rebalance
# swift-ring-builder container.builder rebalance
# swift-ring-builder object.builder rebalance
[root@cnsz20pl2644 swift]# swift-ring-builder account.builder rebalance
Reassigned 98304 (300.00%) partitions. Balance is now 0.00.  Dispersion is now 0.00
[root@cnsz20pl2644 swift]# swift-ring-builder account.builder
account.builder, build version 13, id eed5b8a4355c4b17b9059b30833e22e5
32768 partitions, 3.000000 replicas, 1 regions, 3 zones, 12 devices, 0.00 balance, 0.00 dispersion
The minimum number of hours before a partition can be reassigned is 1 (0:59:43 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.99.230:6202  192.168.99.230:6202   sdb 100.00       8192    0.00       
            1      1    1 192.168.99.230:6202  192.168.99.230:6202   sdc 100.00       8192    0.00       
            2      1    1 192.168.99.230:6202  192.168.99.230:6202   sdd 100.00       8192    0.00       
            3      1    1 192.168.99.230:6202  192.168.99.230:6202   sde 100.00       8192    0.00       
            4      1    2 192.168.99.231:6202  192.168.99.231:6202   sdb 100.00       8192    0.00       
            5      1    2 192.168.99.231:6202  192.168.99.231:6202   sdc 100.00       8192    0.00       
            6      1    2 192.168.99.231:6202  192.168.99.231:6202   sdd 100.00       8192    0.00       
            7      1    2 192.168.99.231:6202  192.168.99.231:6202   sde 100.00       8192    0.00       
            8      1    3 192.168.99.232:6202  192.168.99.232:6202   sdb 100.00       8192    0.00       
            9      1    3 192.168.99.232:6202  192.168.99.232:6202   sdc 100.00       8192    0.00       
           10      1    3 192.168.99.232:6202  192.168.99.232:6202   sdd 100.00       8192    0.00       
           11      1    3 192.168.99.232:6202  192.168.99.232:6202   sde 100.00       8192    0.00       
[root@cnsz20pl2644 swift]# swift-ring-builder container.builder rebalance
Reassigned 98304 (300.00%) partitions. Balance is now 0.00.  Dispersion is now 0.00
[root@cnsz20pl2644 swift]# swift-ring-builder container.builder
container.builder, build version 13, id 126c240155e1446d98cb41cbd456f5a4
32768 partitions, 3.000000 replicas, 1 regions, 3 zones, 12 devices, 0.00 balance, 0.00 dispersion
The minimum number of hours before a partition can be reassigned is 1 (0:59:51 remaining)
The overload factor is 0.00% (0.000000)
Ring file container.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.99.230:6201  192.168.99.230:6201   sdb 100.00       8192    0.00       
            1      1    1 192.168.99.230:6201  192.168.99.230:6201   sdc 100.00       8192    0.00       
            2      1    1 192.168.99.230:6201  192.168.99.230:6201   sdd 100.00       8192    0.00       
            3      1    1 192.168.99.230:6201  192.168.99.230:6201   sde 100.00       8192    0.00       
            4      1    2 192.168.99.231:6201  192.168.99.231:6201   sdb 100.00       8192    0.00       
            5      1    2 192.168.99.231:6201  192.168.99.231:6201   sdc 100.00       8192    0.00       
            6      1    2 192.168.99.231:6201  192.168.99.231:6201   sdd 100.00       8192    0.00       
            7      1    2 192.168.99.231:6201  192.168.99.231:6201   sde 100.00       8192    0.00       
            8      1    3 192.168.99.232:6201  192.168.99.232:6201   sdb 100.00       8192    0.00       
            9      1    3 192.168.99.232:6201  192.168.99.232:6201   sdc 100.00       8192    0.00       
           10      1    3 192.168.99.232:6201  192.168.99.232:6201   sdd 100.00       8192    0.00       
           11      1    3 192.168.99.232:6201  192.168.99.232:6201   sde 100.00       8192    0.00       
[root@cnsz20pl2644 swift]# swift-ring-builder object.builder rebalance
Reassigned 98304 (300.00%) partitions. Balance is now 0.00.  Dispersion is now 0.00
[root@cnsz20pl2644 swift]# swift-ring-builder object.builder
object.builder, build version 13, id 8b9eba9963d242b18665dad9e68e0d0f
32768 partitions, 3.000000 replicas, 1 regions, 3 zones, 12 devices, 0.00 balance, 0.00 dispersion
The minimum number of hours before a partition can be reassigned is 1 (0:59:51 remaining)
The overload factor is 0.00% (0.000000)
Ring file object.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.99.230:6200  192.168.99.230:6200   sdb 100.00       8192    0.00       
            1      1    1 192.168.99.230:6200  192.168.99.230:6200   sdc 100.00       8192    0.00       
            2      1    1 192.168.99.230:6200  192.168.99.230:6200   sdd 100.00       8192    0.00       
            3      1    1 192.168.99.230:6200  192.168.99.230:6200   sde 100.00       8192    0.00       
            4      1    2 192.168.99.231:6200  192.168.99.231:6200   sdb 100.00       8192    0.00       
            5      1    2 192.168.99.231:6200  192.168.99.231:6200   sdc 100.00       8192    0.00       
            6      1    2 192.168.99.231:6200  192.168.99.231:6200   sdd 100.00       8192    0.00       
            7      1    2 192.168.99.231:6200  192.168.99.231:6200   sde 100.00       8192    0.00       
            8      1    3 192.168.99.232:6200  192.168.99.232:6200   sdb 100.00       8192    0.00       
            9      1    3 192.168.99.232:6200  192.168.99.232:6200   sdc 100.00       8192    0.00       
           10      1    3 192.168.99.232:6200  192.168.99.232:6200   sdd 100.00       8192    0.00       
           11      1    3 192.168.99.232:6200  192.168.99.232:6200   sde 100.00       8192    0.00
配置 /etc/swift/swift.conf 文件
[swift-hash]
...
swift_hash_path_suffix = HASH_PATH_SUFFIX
swift_hash_path_prefix = HASH_PATH_PREFIX
[storage-policy:0]
name = Policy-0
default = yes
将swift.conf文件复制到所有的proxy和storage节点
 
将目录权限授权给swift用户:
# chown -R root:swift /etc/swift
在控制节点上设置proxy及相关依赖服务为开机启动,并启动相关服务:
# systemctl enable openstack-swift-proxy.service memcached.service
# systemctl start openstack-swift-proxy.service memcached.service
在所有的storage节点上为account、container、object及相关服务设置开机启动并启动服务:
# 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
验证:
# curl -v -H 'X-Auth-User:myaccount:me' -H 'X-Auth-Key:sf123456' http://localhost:8080/auth/v1.0/   (账号密码为tempauth中添加的账号和密码)
 
* About to connect() to localhost port 8080 (#0)
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 8080 (#0)
> GET /auth/v1.0/ HTTP/1.1
> User-Agent: curl/7.29.0
> Host: localhost:8080
> Accept: */*
> X-Auth-User:myaccount:me
> X-Auth-Key:sf123456
>
< HTTP/1.1 200 OK
< X-Storage-Url: http://localhost:8080/v1/AUTH_myaccount
< X-Auth-Token-Expires: 84250
< X-Auth-Token: AUTH_tkb66e28e115744e48aba885e01b93aae1
< Content-Type: text/html; charset=UTF-8
< X-Storage-Token: AUTH_tkb66e28e115744e48aba885e01b93aae1
< Content-Length: 0
< X-Trans-Id: tx653408a702c44fee8807f-005a716ba1
< X-Openstack-Request-Id: tx653408a702c44fee8807f-005a716ba1
< Date: Wed, 31 Jan 2018 07:09:21 GMT
<
* Connection #0 to host localhost left intact
 
 
[root@cnsz20pl2644 swift]# python
Python 2.7.5 (default, Aug  4 2017, 00:39:18)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import swift.common.memcached as memcached
>>> memcache = memcached.MemcacheRing(['127.0.0.1:11211'])
>>> print memcache.get('AUTH_/user/myaccount:me')
AUTH_tkb66e28e115744e48aba885e01b93aae1   (token值)
 
# curl -v -H 'X-Storage-Token:AUTH_tkb66e28e115744e48aba885e01b93aae1' http://localhost:8080/v1/AUTH_myaccount/
 
* About to connect() to localhost port 8080 (#0)
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 8080 (#0)
> GET /v1/AUTH_myaccount/ HTTP/1.1
> User-Agent: curl/7.29.0
> Host: localhost:8080
> Accept: */*
> X-Storage-Token:AUTH_tkb66e28e115744e48aba885e01b93aae1
>
< HTTP/1.1 204 No Content
< Content-Type: text/plain; charset=utf-8
< X-Account-Object-Count: 0
< X-Timestamp: 1517382565.03297
< X-Account-Bytes-Used: 0
< X-Account-Container-Count: 0
< X-Put-Timestamp: 1517382565.03297
< Content-Length: 0
< X-Trans-Id: txce20a8b6cb3b4d85a724a-005a716ba5
< X-Openstack-Request-Id: txce20a8b6cb3b4d85a724a-005a716ba5
< Date: Wed, 31 Jan 2018 07:09:25 GMT
<
* Connection #0 to host localhost left intact
 
# curl -v -H 'X-Storage-Token:AUTH_tkb66e28e115744e48aba885e01b93aae1' -X PUT http://localhost:8080/v1/AUTH_myaccount/container0001
 
* About to connect() to localhost port 8080 (#0)
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 8080 (#0)
> PUT /v1/AUTH_myaccount/container0001 HTTP/1.1
> User-Agent: curl/7.29.0
> Host: localhost:8080
> Accept: */*
> X-Storage-Token:AUTH_tkb66e28e115744e48aba885e01b93aae1
>
< HTTP/1.1 201 Created
< Content-Length: 0
< Content-Type: text/html; charset=UTF-8
< X-Trans-Id: tx7815e43aa9c74730a2d55-005a716ec1
< X-Openstack-Request-Id: tx7815e43aa9c74730a2d55-005a716ec1
< Date: Wed, 31 Jan 2018 07:22:41 GMT
<
* Connection #0 to host localhost left intact
 
# curl -v -H 'X-Storage-Token:AUTH_tkb66e28e115744e48aba885e01b93aae1' -X PUT -T test-obj-001 http://localhost:8080/v1/AUTH_myaccount/container0001/test-obj-001
 
* About to connect() to localhost port 8080 (#0)
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 8080 (#0)
> PUT /v1/AUTH_myaccount/container0001/test-obj-001 HTTP/1.1
> User-Agent: curl/7.29.0
> Host: localhost:8080
> Accept: */*
> X-Storage-Token:AUTH_tkb66e28e115744e48aba885e01b93aae1
> Content-Length: 0
> Expect: 100-continue
>
< HTTP/1.1 100 Continue
< HTTP/1.1 201 Created
< Last-Modified: Wed, 31 Jan 2018 07:28:22 GMT
< Content-Length: 0
< Etag: d41d8cd98f00b204e9800998ecf8427e
< Content-Type: text/html; charset=UTF-8
< X-Trans-Id: tx10cc5e96093a42a3a473e-005a717015
< X-Openstack-Request-Id: tx10cc5e96093a42a3a473e-005a717015
< Date: Wed, 31 Jan 2018 07:28:21 GMT
<
* Connection #0 to host localhost left intact

转载于:https://www.cnblogs.com/chmyee/p/9149580.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值