项目--对象存储--容器 在容器里你创建的即使是一个文件夹,那么体现在硬盘里,也是一个文件,也就是对象object
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
[root@h1 ~(keystone_admin)]
# openstack service list
+----------------------------------+------------+--------------+
| ID | Name | Type |
+----------------------------------+------------+--------------+
| 30c62c3c0797462a8bd4ff059a71296e | swift | object-store |
[root@h1 ~(keystone_admin)]
# keystone endpoint-list | grep 30c62c3c0797462a8bd4ff059a71296e
| 2408bc6cb5164053b86c0983fd39961a | RegionOne | http:
//192
.168.1.201:8080
/v1/AUTH_
%(tenant_id)s | http:
//192
.168.1.201:8080
/v1/AUTH_
%(tenant_id)s | http:
//192
.168.1.201:8080 | 30c62c3c0797462a8bd4ff059a71296e |
[root@h1 ~(keystone_admin)]
# swift list
h1
[root@h1 ~(keystone_admin)]
# swift list h1
test1/
test1
/k1
.pem
[root@h1 ~(keystone_admin)]
# find /srv/node/swiftloopback/ -type f -name "*.data"
/srv/node/swiftloopback/objects/188901/27f/b87961659e1149b7094bb52b5d60f27f/1467698512
.58656.data
##删除k1后就没有了
/srv/node/swiftloopback/objects/59261/c81/39df7c7803321e4878fdcec1ac469c81/1467698493
.15690.data
|
映射 :ring(环) 映射到硬盘
-
容器 在容器里面创建对象
-
对象 文件就是对象
-
账户 权限
ring文件 保存到硬盘
-
account.ring.gz 账户
-
container.ring.gz 容器
-
object.ring.gz 对象
保存到硬盘里的目录,这个目录为zone /srv/node/swiftloopback/ 挂载点 必须放在/srv/node/目录下
-
zone1
-
zone2 两个相同,备份
packstack方式安装完成后,上传一个文件,只在硬盘里保留一份
对象先映射到 虚拟节点/分区partition 2^n 再映射到zone
目的:减少数据的迁移量
swift服务
1 一致性服务 consisteny server
-
auditor 定期扫描,如果出现问题,就把有问题的文件放隔离区
-
replicate 从另外的zone复制相同的文件过来,实现数据同步
-
update 如果replicate失效了,那么等段时间再试
2 代维服务proxy server
接受用户发送过来的请求,比如上传、删除等请求
3 存储服务
容器服务器 container server
对象服务器 object server
账户服务器 acount server
安装软件
1
2
|
[root@h4 ~]
# yum list openstack-swift*
[root@h4 ~]
# yum -y install openstack-swift.noarch openstack-swift-account.noarch openstack-swift-container.noarch openstack-swift-object.noarch openstack-swift-proxy.noarch memcache* python-swiftclient
|
任何服务都要向keystone进行注册
1
2
3
|
[root@h4 ~(keystone_admin)]
# keystone user-create --name swift --pass hequan
[root@h4 ~(keystone_admin)]
# keystone tenant-create --name services
[root@h4 ~(keystone_admin)]
# keystone user-role-add --user swift --tenant services --role admin
|
创建服务,指定endpoint
1
2
|
[root@h4 ~(keystone_admin)]
# keystone service-create --name swift --type object-store --description "swift"
keystone endpoint-create --service-
id
0995c9a9ed4847da86435bca9a7be8fc --publicurl
'http://192.168.1.204:8080/v1/AUTH_%(tenant_id)s'
--internalurl
'http://192.168.1.204:8080/v1/AUTH_%(tenant_id)s'
--adminurl
' http://192.168.1.204:8080'
|
配置swift 准备了2个分区
1
2
3
|
zone1 zone2 在
/srv/node
12
/dev/sdb1
/srv/node/zone1
xfs defaults 0 0
##挂载
13
/dev/sdb2
/srv/node/zone2
xfs defaults 0 0
|
1
|
[root@h4 ~(keystone_admin)]
# chown -R swift.swift /srv/node/
|
1
2
3
4
5
6
7
8
9
10
|
[root@h4 swift(keystone_admin)]
# cat swift.conf
[swift-
hash
]
swift_hash_path_suffix = %SWIFT_HASH_PATH_SUFFIX%
[root@h1 ~(keystone_admin)]
# find /srv/node/swiftloopback/ -type f -name "*.data"
/srv/node/swiftloopback/objects/102340/afe/63f12ea37cca17f0227381adcf93eafe/1467982747
.16551.data
zone 对象类型/分区的编号
/sufix/
文件名字的
hash
/上传文件的时间戳
[root@h1 ~(keystone_admin)]
# date --date=@1467982747.16551
2016年 07月 08日 星期五 20:59:07 CST
|
创建ring文件的准备工作 创建模板,设定有几个备份,有多少分区。
1
2
3
|
[root@h4 swift(keystone_admin)]
# swift-ring-builder account.builder create 12 2 1
[root@h4 swift(keystone_admin)]
# swift-ring-builder object.builder create 12 2 1
[root@h4 swift(keystone_admin)]
# swift-ring-builder container.builder create 12 2 1
|
指定映射位置
1
2
3
4
5
6
7
8
|
[root@h4 swift]
# vim account-server.conf #3个都要改ip
6 bind_ip = 192.168.1.204
[root@h4 swift(keystone_admin)]
# swift-ring-builder account.builder add z1-192.168.1.204:6202/zone1 100
[root@h4 swift(keystone_admin)]
# swift-ring-builder account.builder add z2-192.168.1.204:6202/zone2 100
[root@h4 swift(keystone_admin)]
# swift-ring-builder object.builder add z1-192.168.1.204:6200/zone1 100
[root@h4 swift(keystone_admin)]
# swift-ring-builder object.builder add z2-192.168.1.204:6200/zone2 100
[root@h4 swift(keystone_admin)]
# swift-ring-builder container.builder add z1-192.168.1.204:6201/zone1 100
[root@h4 swift(keystone_admin)]
# swift-ring-builder container.builder add z2-192.168.1.204:6201/zone2 100
|
创建ring文件
1
2
3
4
5
|
[root@h4 swift(keystone_admin)]
# swift-ring-builder account.builder rebalance
[root@h4 swift(keystone_admin)]
# swift-ring-builder object.builder rebalance
[root@h4 swift(keystone_admin)]
# swift-ring-builder container.builder rebalance
[root@h4 swift(keystone_admin)]
# ls *.gz
account.ring.gz container.ring.gz object.ring.gz
|
启动服务
1
2
3
4
5
6
|
[root@h4 srv(keystone_admin)]
# systemctl start openstack-swift-account openstack-swift-object openstack-swift-container
[root@h4 srv(keystone_admin)]
# systemctl is-active openstack-swift-account openstack-swift-object openstack-swift-container
active
active
active
[root@h4 srv(keystone_admin)]
# systemctl enable openstack-swift-account openstack-swift-object openstack-swift-container
|
代维服务proxy server
1
2
3
4
5
6
7
8
9
10
11
|
[root@h4 swift(keystone_admin)]
# vim proxy-server.conf
53 [filter:authtoken]
54
paste
.filter_factory = keystonemiddleware.auth_token:filter_factory
55 admin_tenant_name = services
56 admin_user = swift
57 admin_password = hequan
58
#
59 identity_uri = http:
//192
.168.1.204:35357/
60 auth_port = 35357
61 auth_protocol = http
62
#auth_uri = http://192.168.1.204:5000/
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
[root@h4 swift(keystone_admin)]
# systemctl start openstack-swift-proxy.service
[root@h4 swift(keystone_admin)]
# systemctl enable openstack-swift-proxy.service
[root@h4 swift(keystone_admin)]
# systemctl start memcached.service
[root@h4 swift(keystone_admin)]
# systemctl enable memcached.service
[root@h4 swift(keystone_admin)]
# swift post h1
[root@h4 swift(keystone_admin)]
# swift list
h1
[root@h4 swift(keystone_admin)]
# swift upload h1 /etc/hosts
任意一个分区挂了,还是可以正常查看
两个都挂了,就看不到了
|