GlusterFS常用维护操作命令

2022-12-26,,,,

GlusterFS常用维护操作命令

1.启动/关闭/查看glusterd服务
# /etc/init.d/glusterd start
# /etc/init.d/glusterd stop
# /etc/init.d/glusterd status

2. 开机自动启动glusterd服务

# chkconfig glusterd on # Red Hat
# update-rc.d glusterd defaults # Debian
# echo "glusterd" >>/etc/rc.local # Others

3. 查看卷信息

gluster volume info

4.为存储池添加/移除服务器节点

在其中一个节点上操作即可:
# gluster peer probe <SERVER>
# gluster peer detach <SERVER>
注意,移除节点时,需要提前将该节点上的Brick移除。 查看所有节点的基本状态(显示的时候不包括本节点):
# gluster peer status

5. 挂载分区

# mount -t ext4 /dev/sdd1 /mnt/brick1

6.  创建/启动/停止/删除卷

# gluster volume create <NEW-VOLNAME>[stripe <COUNT> | replica <COUNT>] [transport [tcp | rdma | tcp,rdma]] <NEW-BRICK1> <NEW-BRICK2> <NEW-BRICK3> <NEW-BRICK4>...
# gluster volume start <VOLNAME>
# gluster volume stop <VOLNAME>
# gluster volume delete <VOLNAME> 注意,删除卷的前提是先停止卷。

7. 客户端以glusterfs方式挂载

# mount -t glusterfs <SERVER>:/<VOLNAME><MOUNTDIR>
对于OpenStack,计算和控制节点都要挂载/var/lib/nova/instances,控制节点还要挂载/var/lib/glance/images。

8. 查看卷信息

列出集群中的所有卷:
# gluster volume list 查看集群中的卷信息:
# gluster volume info [all] 查看集群中的卷状态:
# gluster volume status [all]
# gluster volume status <VOLNAME> [detail| clients | mem | inode | fd] 查看本节点的文件系统信息:
# df -h [<MOUNT-PATH>] 查看本节点的磁盘信息:
# fdisk -l

9.配置卷

# gluster volume set <VOLNAME> <OPTION> <PARAMETER>

10.    扩展卷

# gluster volume add-brick <VOLNAME> <NEW-BRICK>
注意,如果是复制卷或者条带卷,则每次添加的Brick数必须是replica或者stripe的整数倍。

11. 收缩卷

先将数据迁移到其它可用的Brick,迁移结束后才将该Brick移除:
# gluster volume remove-brick <VOLNAME> <BRICK> start 在执行了start之后,可以使用status命令查看移除进度:
# gluster volume remove-brick <VOLNAME> <BRICK> status 不进行数据迁移,直接删除该Brick:
# gluster volume remove-brick <VOLNAME> <BRICK> commit 注意,如果是复制卷或者条带卷,则每次移除的Brick数必须是replica或者stripe的整数倍。

 

12.迁移卷

使用start命令开始进行迁移:
# gluster volume replace-brick <VOLNAME> <BRICK> <NEW-BRICK> start 在数据迁移过程中,可以使用pause命令暂停迁移:
# gluster volume replace-brick <VOLNAME> <BRICK> <NEW-BRICK> pause 在数据迁移过程中,可以使用abort命令终止迁移:
# gluster volume replace-brick <VOLNAME> <BRICK> <NEW-BRICK> abort 在数据迁移过程中,可以使用status命令查看迁移进度:
# gluster volume replace-brick <VOLNAME> <BRICK> <NEW-BRICK> status 在数据迁移结束后,执行commit命令来进行Brick替换:
# gluster volume replace-brick <VOLNAME> <BRICK> <NEW-BRICK> commit

13.    重新均衡卷

不迁移数据:

# gluster volume rebalance <VOLNAME> lay-outstart
# gluster volume rebalance <VOLNAME> start
# gluster volume rebalance <VOLNAME> startforce
# gluster volume rebalance <VOLNAME> status
# gluster volume rebalance <VOLNAME> stop

14.系统扩展维护

开启/关闭系统配额:
# gluster volume quota <VOLNAME> enable | disable 设置目录配额:
# gluster volume quota <VOLNAME> limit-usage <DIR> <VALUE> 查看配额:
# gluster volume quota <VOLNAME> list [<DIR>] 地域复制(geo-replication):
# gluster volume geo-replication <MASTER> <SLAVE> start | status | stop IO信息查看:
# gluster volume profile <VOLNAME> start | info | stop Top监控:
Top命令允许你查看Brick的性能,例如:read,write, file open calls, file read calls, file write calls, directory opencalls, and directory real calls。所有的查看都可以设置 top数,默认100。 查看打开的 fd:
# gluster volume top <VOLNAME> open[brick <BRICK>] [list-cnt <COUNT>] 其中,open可以替换为read, write, opendir, readdir等。
查看每个 Brick 的读性能: # gluster volume top <VOLNAME> read-perf [bs <BLOCK-SIZE> count <COUNT>] [brick <BRICK>] [list-cnt <COUNT>] 其中,read-perf可以替换为write-perf等。

15.GlusterFS优化

# 设置 cache 大小, 默认32MB
gluster volume set senyintvolume performance.cache-size 4GB # 设置 io 线程, 太大会导致进程崩溃
gluster volume set senyintvolume performance.io-thread-count 16 # 设置 网络检测时间, 默认42s
gluster volume set senyintvolume network.ping-timeout 10 # 设置 写缓冲区的大小, 默认1M
gluster volume set senyintvolume performance.write-behind-window-size 1024MB # 开启 指定 volume 的配额,不使用
gluster volume quota k8s-volume enable # 限制 指定 volume 的配额,不使用
gluster volume quota k8s-volume limit-usage / 1TB

16.操作示例

强制创建卷

gluster volume create testvol ip:/date/brick1 ip:/date/brick2 force

磁盘限额

to quota glusterfs
主要是对挂载点下的某个目录进行空间限额(对客户端下某个目录限制,而不是对组成的空间进行的限制 如:server1目录、server2目录) #gluster volume quota test-volume enable 激活quota功能 #gluster volume quota test-volume disable 关闭quota功能 #gluster volume quota test-volume limit-usage /data 10GB           ---/exp2/data 目录限制 #gluster volume quota test-volume list         ---quota信息列表 #gluster volume set test-volume features.quota-timeout 5  设置信息的超时时间 #gluster volume quota test-volume remove  /data  删除某个目录的quota设置

添加存储节点

#gluster peer probe server4   向turst pool  添加新server4

#gluster volume add-brick test-volume server4:/server4  卷组添加新空间

gluster volume info 查看当前所有volume状态

#gluster volume rebalance test-volume start          对扩容后的卷组进行rebalance

#gluster volume rebalance test-volume status

#gluster volume rebalance test-volume stop

glusterfs的参数进行设置优化

#gluserfs volume set test-volume performance.cache-size 256M

删除GlusterFS磁盘:

# gluster volume stop datavolume1
# gluster volume delete datavolume1

卸载GlusterFS磁盘:

# gluster peer detach idc1-server4

ACL访问控制:

# gluster volume set datavolume1 auth.allow 10.100.1.*,10.200.1.*

添加GlusterFS节点:

# gluster peer probe idc1-server5

# gluster peer probe idc1-server6

# gluster volume add-brick datavolume1 idc1-server5:/usr/local/share/datavolume1 idc1-server6:/usr/local/share/datavolume1

迁移GlusterFS磁盘数据:

# gluster volume remove-brick datavolume1 idc1-server1:/usr/local/share/datavolume1 idc1-server5:/usr/local/share/datavolume1 start

# gluster volume remove-brick datavolume1 idc1-server1:/usr/local/share/datavolume1 idc1-server5:/usr/local/share/datavolume1 status

# gluster volume remove-brick datavolume1 idc1-server1:/usr/local/share/datavolume1 idc1-server5:/usr/local/share/datavolume1 commit

数据重新分配:

# gluster volume rebalance datavolume1 start

# gluster volume rebalance datavolume1 status

# gluster volume rebalance datavolume1 stop

修复GlusterFS磁盘数据(例如在idc1-server1宕机的情况下):

# gluster volume replace-brick datavolume1 idc1-server1:/usr/local/share/datavolume1 idc1-server5:/usr/local/share/datavolume1 commit -force

# gluster volume heal datavolume1 full

GlusterFS常用维护操作命令的相关教程结束。

《GlusterFS常用维护操作命令.doc》

下载本文的Word格式文档,以方便收藏与打印。