欢迎阅读!

潇湘夜雨

当前位置: 主页 > 系统 > 云计算 >

openstack-havana云平台实验(12)

时间:2016-10-10 09:32来源:潇湘夜雨 作者:华嵩阳 点击:
Devices: id region zone ip address port replication ip replication port name weight partitions balance meta 0 1 1 172.18.109.237 6000 172.18.109.237 6000 sdb1 100.00 0 -100.00 1 1 2 172.18.109.237 600
Devices:    id  region  zone      ip address  port  replication ip  replication port      name weight partitions balance meta
0       1     1  172.18.109.237  6000  172.18.109.237              6000      sdb1 100.00          0 -100.00 
1       1     2  172.18.109.237  6000  172.18.109.237              6000      sdc1 100.00          0 -100.00 
2       1     3  172.18.109.237  6000  172.18.109.237              6000      sdd1 100.00          0 -100.00 
d1 100.00          0 -100.00 
使用如下命令重新平衡三个环,即将对应的设备分布式环中的节点上。不过,执行这些命令可能会需要一些时间。
[root@localhost ~]#  swift-ring-builder account.builder rebalance
Reassigned 262144 (100.00%) partitions. Balance is now 0.00.
[root@localhost ~]# swift-ring-builder container.builder rebalance
Reassigned 262144 (100.00%) partitions. Balance is now 0.00.
[root@localhost ~]# swift-ring-builder object.builder rebalance
Reassigned 262144 (100.00%) partitions. Balance is now 0.00.
执行完成后,它们被保存为三个压缩文件account.ring.gz、container.ring.gz和object.ring.gz,请自行确保有些三个
文件。在多节点的场景中,这三个文件需要复制到每个代理节点和存储节点的/etc/swift目录中。
确保每个节点的/etc/swift目录及其内部子目录和文件的属主为swift用户,属组为swift组。
[root@localhost ~]# chown -R swift:swift /etc/swift
另外,最好为swift设定一个hash key:
[root@localhost ~]# openstack-config --set /etc/swift/swift.conf swift-hash swift_hash_path_suffix $(openssl rand -hex 10)
[root@localhost ~]# cat /etc/swift/swift.conf 
[swift-hash]
swift_hash_path_suffix = d0ac43e6f3fba5b2b431
 
6.3.6 启动代理服务
[root@localhost ~]# service openstack-swift-proxy start
Starting openstack-swift-proxy:                            [确定]
[root@localhost ~]# chkconfig openstack-swift-proxy on
 
6.4 在KeyStone中注册swift
 
接下来需要将swift在KeyStone中注册,dashboard需要基于此与swift交互。下面的部分要以keystone的管理员admin身份执行,如果当前未为连接KeyStone设置环境变量,可以使用“source ~/.keystonerc_admin”进行。
在swif节点主册需要使用控制节点的环境变量
[root@localhost ~]# source .keystonerc_admin 
在Keystone中注册swift服务:
[root@localhost ~(keystone_admin)]# keystone service-create --name swift --type object-store --description "Swift Storage Service"
+-------------+----------------------------------+
|   Property  |              Value               |
+-------------+----------------------------------+
| description |      Swift Storage Service       |
|      id     | 36cf1b4bfe74478d965037ad4223386c |
|     name    |              swift               |
|     type    |           object-store           |
+-------------+----------------------------------+
[root@localhost ~(keystone_admin)]# keystone endpoint-create --service_id 36cf1b4bfe74478d965037ad4223386c \
>     --publicurl "http://172.18.109.237:8080/v1/AUTH_%(tenant_id)s" \
>     --adminurl "http://172.18.109.237:8080/v1/AUTH_%(tenant_id)s" \
>     --internalurl "http://172.18.109.237:8080/v1/AUTH_%(tenant_id)s"
+-------------+--------------------------------------------------+
|   Property  |                      Value                       |
+-------------+--------------------------------------------------+
|   adminurl  | http://172.18.109.237:8080/v1/AUTH_%(tenant_id)s |
|      id     |         4ab4b7b39de2408fb21f15bcc358cd26         |
| internalurl | http://172.18.109.237:8080/v1/AUTH_%(tenant_id)s |
|  publicurl  | http://172.18.109.237:8080/v1/AUTH_%(tenant_id)s |
|    region   |                    regionOne                     |
|  service_id |         36cf1b4bfe74478d965037ad4223386c         |
+-------------+--------------------------------------------------+
[root@localhost swift(keystone_admin)]# swift stat
  Account: AUTH_a8fbb58fe9c24de38d3290573ecf565a
Containers: 0
  Objects: 0
Bytes: 0
 Content-Type: text/plain; charset=utf-8
Connection: keep-alive
  X-Timestamp: 1475837584.13625
X-Put-Timestamp: 1475837584.13625
[root@localhost swift(keystone_admin)]# swift -V 2.0 -A http://172.18.109.235:5000/v2.0 -U service:swift -K swift stat
  Account: AUTH_5eaea442e6f44ccda09a5ea7847dea36
Containers: 0
  Objects: 0
Bytes: 0
 Content-Type: text/plain; charset=utf-8
Connection: keep-alive
  X-Timestamp: 1475837635.59497
X-Put-Timestamp: 1475837635.59497
注意:验证失败503错误
解决方法:更改下面配置文件绑定的地址为外网地址
[root@localhost swift(keystone_admin)]# vim object-server.conf 
[root@localhost swift(keystone_admin)]# vim container-server.conf 
[root@localhost swift(keystone_admin)]# vim account-server.conf 
[DEFAULT]
bind_ip = 172.18.109.237
上传目录测试
[root@localhost ~(keystone_admin)]# swift -V 2.0 -A http://172.18.109.235:5000/v2.0 -U service:swift -K swift upload test1 backups
backups/1475834093.container.builder
backups/1475834093.container.ring.gz
backups/1475834138.object.ring.gz
backups/1475832886.account.builder
backups/1475832947.object.builder
backups/1475832925.container.builder
backups/1475834049.account.ring.gz
backups/1475834138.object.builder
backups/1475834049.account.builder
[root@localhost ~(keystone_admin)]# swift -V 2.0 -A http://172.18.109.235:5000/v2.0 -U service:swift -K swift list
test1
使用上面指定用户的方式太麻烦,可以设置环境变量,简化操作。
环境变量如下:
export OS_USERNAME=swift
export OS_TENANT_NAME=service
export OS_PASSWORD=swift
export OS_AUTH_URL=http://172.18.109.235:35357/v2.0/
export PS1='[\u@\h \W(keystone_admin)]\$ 
 
[root@localhost ~(keystone_admin)]# vim .keystonerc_admin 
[root@localhost ~(keystone_admin)]# source .keystonerc_admin 
[root@localhost ~(keystone_admin)]# swift list
test1
[root@localhost ~(keystone_admin)]# ls
anaconda-ks.cfg  backups  install.log  install.log.syslog
[root@localhost ~(keystone_admin)]# cp install.log swift2
[root@localhost ~(keystone_admin)]# ls
anaconda-ks.cfg  backups  install.log  install.log.syslog  swift2
[root@localhost ~(keystone_admin)]# swift upload test2 swift2 
swift2
[root@localhost ~(keystone_admin)]# swift list
test1
test2
[root@localhost ~(keystone_admin)]# ls
anaconda-ks.cfg  backups  install.log  install.log.syslog  swift2
[root@localhost ~(keystone_admin)]# rm -rf swift2 
[root@localhost ~(keystone_admin)]# swift download test2
swift2 [auth 0.138s, headers 0.168s, total 0.169s, 0.908 MB/s]
[root@localhost ~(keystone_admin)]# ls
anaconda-ks.cfg  backups  install.log  install.log.syslog  swift2
[root@localhost ~(keystone_admin)]# swift delete test1
backups/1475832886.account.builder
backups/1475832925.container.builder
backups/1475834138.object.builder
backups/1475834049.account.ring.gz
backups/1475834049.account.builder (责任编辑:liangzh)
织梦二维码生成器
顶一下
(9)
100%
踩一下
(0)
0%
------分隔线----------------------------