可信存储池(Trusted Storage Pool)
创建存储池
例如要创建一个包含3个服务器的存储池,则需要从第一个服务器server1中把另外两个服务器加入存储池中:
# gluster peer probe server2
Probe successful
# gluster pool peer server3
Probe successful
查看存储池状态:
# gluster peer status
Number of Peers: 2
Hostname: server2.quenywell.com
Uuid: 86bd7b96-1320-4cd5-b3e1-e537d06dd5f7
State: Peer in Cluster (Connected)
Hostname: server3.quenywell.com
Uuid: c191b17b-ab9d-4b15-a70d-dcc92be067c9
State: Peer in Cluster (Connected)
从存储池移除服务器
假设要把server3从存储池里删除,可以使用以下命令:
# gluster peer detach server3
Detach successful
GlusterFS逻辑卷(Volume)
逻辑卷由一个或多个存储块(Brick)组成,每个存储块对应存储池中的一个目录。
GlusterFS的基本类型有三个,分别是分散存储(Distributed,将不同的文件放在不同的存储块)、镜像存储(Replicated,同一个文件存放在两个以上的存储块,相当于RAID1) 和分片存储(Striped,将一个文件分划分为多个固定长度的数据,分散存放在所有存储块,相当于RAID0)。另外Distributed也可以跟Replicated和Striped组合形成新的类型。
建立GlusterFS逻辑卷的基本语法:
# gluster volume create [stripe ] [replica ] [device vg] [transport ] ...
创建Distributed逻辑卷
创建一个名字为dis-volume、包含两个存储块、使用TCP协议的Distributed逻辑卷:
# gluster volume create dis-volume server1:/data server2:/data
Creation of dis-volume has been successful
Please start the volume to access data.
查看逻辑卷状态:
# gluster volume info
Volume Name: dis-volume
Type: Distribute
Volume ID: 5429d6c1-44e5-43ad-a495-0a1f5b6d774b
Status: Started
Number of Bricks: 1 x 2 = 2
Transport-type: tcp
Bricks:
Brick1: server1.quenywell.com:/data
Brick2: server2.quenywell.com:/data
创建Replicated逻辑卷
创建一个名字为rep-volume,包含两个存储块,使用TCP协议的Replicated逻辑卷:
# gluster volume create rep-volume replica 2 transport tcp server1:/data server2:/data
Creation of rep-volume has been successful
Please start the volume to access data.
创建Striped逻辑卷
创建一个名字为strip-volume,包含两个存储块,使用TCP协议的Striped逻辑卷:
# gluster volume create strip-volume stripe 2 transport tcp server1:/data server2:/data
Creation of strip-volume has been successful
Please start the volume to access data.
GlusterFS逻辑卷权限控制(可选,非必须)
可以给Gluster逻辑卷设置访问权限以增加安全性。可使用auth.allow和auth.reject允许或禁止特定IP地址访问逻辑卷,支持*通配符。例如:192.168.0.*、192.168.*、192.*都是符合规则的。
例如允许192.168.0.*网段的主机访问rep-volume:
# gluster volume set rep-volume auth.allow 192.168.0.*
启动GlusterFS逻辑卷
注意:逻辑卷在使用前必须先启动!
基本语法:
# gluster volume start
例如要启动rep-volume:
# gluster start rep-volume
Starting rep-volume has been successful
查看GlusterFS逻辑卷状态
基本语法:
# gluster volume info
例如要查看rep-volume状态:
# gluster volume info rep-volume
Volume Name: rep-volume
Type: Replicate
Volume ID: 5429d6c1-44e5-43ad-a495-0a1f5b6d774b
Status: Started
Number of Bricks: 1 x 2 = 2
Transport-type: tcp
Bricks:
Brick1: server1.quenywell.com:/data
Brick2: server2.quenywell.com:/data
停止GlusterFS逻辑卷
# gluster volume stop rep-volume
Stopping volume will make its data inaccessible. Do you want to continue? (y/n)
输入y然后按回车键(Enter),将会出现如下信息:
Stopping volume rep-volume has been successful
删除GlusterFS逻辑卷
# gluster volume delete rep-volume
Deleting volume will erase all information about the volume. Do you want to continue? (y/n)
输入y然后按回车键(Enter),将会出现如下信息:
Deleting volume test-volume has been successful
存储块Brick操作命令
增加Brick
在rep-volume卷中增加一个存储块server3:/data:
# gluster volume add-brick rep-volume server3:/data
Add Brick successful
重要:每次操作存储块之后都必须执行一次rebalance命令!
# gluster volume rebalance rep-volume start
Starting rebalancing on volume rep-volume has been successful
删除Brick
在rep-volume卷中删除存储块server3:/data:
# gluster volume remove-brick rep-volume server3:/data
Removing brick(s) can result in data loss. Do you want to Continue? (y/n)
输入y然后按回车键(Enter),将会出现如下信息:
Remove Brick successful
执行rebalance命令:
# gluster volume rebalance rep-volume start
Starting rebalancing on volume rep-volume has been successful