OpenStack-M版(Mitaka)搭建基于(Centos7.2)+++十、Openstack对象存储服务(swift)下

本文详细介绍了如何在OpenStack Mitaka版本上,基于CentOS7.2系统搭建Swift对象存储服务。内容包括创建账户、容器和对象的ring,设置存储节点,并将配置文件传输到存储节点的过程。
摘要由CSDN通过智能技术生成

十、Openstack对象存储服务(swift)下

控制节点上执行



一、创建账户(account)ring


1.切换到 /etc/swift目录

[root@controller ~]# cd /etc/swift/
[root@controller swift]# 



2.创建基本 account.builder 文件
swift-ring-builder account.builder create 10 1 1


参数解释:

(10)Ring的分区数

(1)表示副本数(我本来一个都不想要的结果要求至少一个副本

(1)表示分区数据的迁移时间为1小时

[root@controller swift]# swift-ring-builder account.builder create 10 1 1
此操作无返回


3.添加每个节点到 ring 中
swift-ring-builder account.builder add --region 1 --zone 1 --ip 192.168.100.20 --port 6002 --device sdb --weight 10

swift-ring-builder account.builder add --region 1 --zone 1 --ip 192.168.100.20 --port 6002 --device sdc --weight 10


--ip(存储节点管理网络ip我这里是安装在计算节点上所以是计算节点管理网络ip)

--port( 端点)

--device (存储设备名称)

--weight (存储设备大小)


[root@controller swift]# swift-ring-builder account.builder add \
> --region 1 --zone 1 --ip 192.168.100.20 --port 6002 --device sdb --weight 10
Device d0r1z1-192.168.100.20:6002R192.168.100.20:6002/sdb_"" with 10.0 weight got id 0

[root@controller swift]# swift-ring-builder account.builder add \
> --region 1 --zone 1 --ip 192.168.100.20 --port 6002 --device sdc --weight 10
Device d1r1z1-192.168.100.20:6002R192.168.100.20:6002/sdc_"" with 10.0 weight got id 1


4.验证 ring 的内容

swift-ring-builder account.builder

[root@controller swift]# swift-ring-builder account.builder
account.builder, build version 2
1024 partitions, 1.000000 replicas, 1 regions, 1 zones, 2 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  replication port      name weight partitions balance flags meta
             0       1     1  192.168.100.20  6002  192.168.100.20              6002       sdb  10.00          0 -100.00       
             1       1     1  192.168.100.20  6002  192.168.100.20              6002       sdc  10.00          0 -100.00       


5.平衡 ring

swift-ring-builder account.builder rebalance

[root@controller swift]# swift-ring-builder account.builder rebalance
Reassigned 1024 (100.00%) partitions. Balance is now 0.00.  Dispersion is now 0.00




二、创建容器(container)ring


1.创建基本 container.builder 文件
swift-ring-builder container.builder create 10 1 1


参数解释:

(10)Ring的分区数

(1)表示副本数(我本来一个都不想要的结果要求至少一个副本

(1)表示分区数据的迁移时间为1小时

[root@controller swift]# swift-ring-builder container.builder create 10 1 1
此操作无返回



2.添加每个节点到 ring 中
swift-ring-builder container.builder add --region 1 --zone 1 --ip 192.168.100.20 --port 6001 --device sdb --weight 10

swift-ring-builder container.builder add --region 1 --zone 1 --ip 192.168.100.20 --port 6001 --device sdc --weight 10


--ip(存储节点管理网络ip我这里是安装在计算节点上所以是计算节点管理网络ip)

--port( 端点)

--device (存储设备名称)

--weight (存储设备大小)


[root@controller swift]# swift-ring-builder container.builder add --region 1 --zone 1 --ip 192.168.100.20 --port 6001 --device sdb --weight 10
Device d0r1z1-192.168.100.20:6001R192.168.100.20:6001/sdb_"" with 10.0 weight got id 0

[root@controller swift]# swift-ring-builder container.builder add --region 1 --zone 1 --ip 192.168.100.20 --port 6001 --device sdc --weight 10
Device d1r1z1-192.168.100.20:6001R192.168.100.20:6001/sdc_"" with 10.0 weight got id 1

3.验证 ring 的内容

swift-ring-builder container.builder

[root@controller swift]# swift-ring-builder container.builder
container.builder, build version 2
1024 partitions, 1.000000 replicas, 1 regions, 1 zones, 2 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  replication port      name weight partitions balance flags meta
             0       1     1  192.168.100.20  6001  192.168.100.20              6001       sdb  10.00          0 -100.00       
             1       1     1  192.168.100.20  6001  192.168.100.20              6001       sdc  10.00          0 -100.00       


4.平衡 ring

swift-ring-builder container.builder rebalance

[root@controller swift]# swift-ring-builder container.builder rebalance
Reassigned 1024 (100.00%) partitions. Balance is now 0.00.  Dispersion is now 0.00



三、创建对象(object)ring


1.创建基本 object.builder 文件
swift-ring-builder object.builder create 10 1 1


参数解释:

(10)Ring的分区数

(1)表示副本数(我本来一个都不想要的结果要求至少一个副本

(1)表示分区数据的迁移时间为1小时

[root@controller swift]# swift-ring-builder object.builder create 10 1 1
此操作无返回



2.添加每个节点到 ring 中
swift-ring-builder object.builder add --region 1 --zone 1 --ip 192.168.100.20 --port 6000 --device sdb --weight 10

swift-ring-builder object.builder add --region 1 --zone 1 --ip 192.168.100.20 --port 6000 --device sdc --weight 10


--ip(存储节点管理网络ip我这里是安装在计算节点上所以是计算节点管理网络ip)

--port( 端点)

--device (存储设备名称)

--weight (存储设备大小)

[root@controller swift]# swift-ring-builder object.builder add --region 1 --zone 1 --ip 192.168.100.20 --port 6001 --device sdb --weight 10
Device d0r1z1-192.168.100.20:6001R192.168.100.20:6000/sdb_"" with 10.0 weight got id 0

[root@controller swift]# swift-ring-builder object.builder add --region 1 --zone 1 --ip 192.168.100.20 --port 6001 --device sdc --weight 10
Device d1r1z1-192.168.100.20:6001R192.168.100.20:6000/sdc_"" with 10.0 weight got id 1


3.验证 ring 的内容

swift-ring-builder object.builder

[root@controller swift]# swift-ring-builder object.builder
object.builder, build version 2
1024 partitions, 1.000000 replicas, 1 regions, 1 zones, 2 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  replication port      name weight partitions balance flags meta
             0       1     1  192.168.100.20  6001  192.168.100.20              6000       sdb  10.00          0 -100.00       
             1       1     1  192.168.100.20  6001  192.168.100.20              6000       sdc  10.00          0 -100.00       


4.平衡 ring

swift-ring-builder object.builder rebalance

[root@controller swift]# swift-ring-builder object.builder rebalance
Reassigned 1024 (100.00%) partitions. Balance is now 0.00.  Dispersion is now 0.00




四、将文件发送到存储节点(我这里计算节点就是存储节点)

文件:object.ring.gz account.ring.gz container.ring.gz


scp *.gz 192.168.100.20:/etc/swift/

[root@controller swift]# scp *.gz 192.168.100.20:/etc/swift/
The authenticity of host '192.168.100.20 (192.168.100.20)' can't be established.
ECDSA key fingerprint is 5a:43:e9:cb:f4:eb:b4:b4:e6:26:1a:5a:f2:f3:55:56.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.100.20' (ECDSA) to the list of known hosts.
root@192.168.100.20's password: 
account.ring.gz                                                                                                                                             100%  455     0.4KB/s   00:00    
container.ring.gz                                                                                                                                           100%  448     0.4KB/s   00:00    
object.ring.gz                                                                                                                                              100%  442     0.4KB/s   00:00    

可以在存储节点 /etc/swift 目录下查看是否有文件

[root@compute ~]# cd /etc/swift/
[root@compute swift]# ls
account.ring.gz  account-server  account-server.conf  container.ring.gz  container-server  container-server.conf  object.ring.gz  object-server  object-server.conf  swift.conf



五、配置swift.conf 文件



1.从对象存储源仓库中获取 /etc/swift/swift.conf 文件

curl -o /etc/swift/swift.conf https://git.openstack.org/cgit/openstack/swift/plain/etc/swift.conf-sample


[root@controller swift]# curl -o /etc/swift/swift.conf   https://git.openstack.org/cgit/openstack/swift/plain/etc/swift.conf-sample
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  7894  100  7894    0     0   6718      0  0:00:01  0:00:01 --:--:--  6729

2.修改配置文件/etc/swift/swift.conf

vi /etc/swift/swift.conf


vi /etc/swift/swift.conf

配置哈希路径前缀和后缀(获取的配置文件有默认值不用改)

swift_hash_path_suffix = changeme
swift_hash_path_prefix = changeme

配置默认存储策略(获取的配置文件中这两个值是打开的其实不用管)

[storage-policy:0]
name = Policy-0
default = yes

3.复制swift.conf文件到每个存储节点(我这里计算节点就是存储节点)

scp swift.conf 192.168.100.20:/etc/swift

[root@controller swift]# scp swift.conf 192.168.100.20:/etc/swift
root@192.168.100.20's password: 
swift.conf                                                                                                                                                  100% 7894     7.7KB/s   00:00    

4.在所有节点上,赋予配置文件目录合适的所有权

chown -R root:swift /etc/swift


(控制节点)
[root@controller swift]# chown -R root:swift /etc/swift

(存储结点【计算节点】)
[root@compute swift]# chown -R root:swift /etc/swift

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值