glusterfs是一款開源的分布式文件系統。
它具備高擴展、高可用及高性能等特性,由於其無元數據服務器的設計,使其真正實現了線性的擴展能力,使存儲總容量可輕松達到PB級別,支持數千客戶端並發訪問。
主要應用在跨集群系統中,具有很好的可擴展性。
glusterfs常用的命令
安裝
# yum install centos-release-gluster -y
服務器端:
# yum install glusterfs-server -y
客戶端:
# yum install glusterfs-client -y
# yum install glusterfs-fuse -y
1 服務器節點
# gluster peer status //查看所有節點信息,顯示時不包括本節點
# gluster peer probe NODE-NAME //添加節點
# gluster peer detach NODE-NAME //移除節點
2 glusterd服務
/etc/init.d/glusterd start |stop |status
3.卷管理
創建卷(在任一節點執行)
卷有6種類型:
<1>復制卷
gluster volume create VOLNAME [replica COUNT] [transport tcp | rdma | tcp, rdma] BRICK...
<2>條帶卷
gluster volume create VOLNAME [stripe COUNT] [transport tcp | rdma | tcp, rdma] BRICK...
<3>分布式卷
gluster volume create VOLNAME [transport tcp | rdma | tcp, rdma] BRICK
<4>分布式復制卷
gluster volume create VOLNAME [replica COUNT] [transport tcp | rdma | tcp, rdma] BRICK...
<5>分布式條帶卷
gluster volume create VOLNAME [stripe COUNT] [transport tcp | rdma | tcp, rdma] BRICK...
<6>條帶復制卷
gluster volume create VOLNAME [stripe COUNT] [replica COUNT] [transport tcp | rdma | tcp, rdma] BRICK...
啟動|停止卷
#gluster volume start|stop test-volume
刪除卷
#gluster volume delete test-volume //先停止卷后才能刪除
查看卷
# gluster volume list /*列出集群中的所有卷*/
# gluster volume info [all] /*查看集群中的卷信息*/
# gluster volume status [all] /*查看集群中的卷狀態*/
# gluster volume status [detail| clients | mem | inode | fd]
配置卷
# gluster volume set <VOLNAME> <OPTION> <PARAMETER>
擴展卷
# gluster volume add-brick <VOLNAME> <NEW-BRICK>
注意,如果是復制卷或者條帶卷,則每次添加的Brick數必須是replica或者stripe的整數倍。
收縮卷
格式:volume remove-brick <VOLNAME> [replica <COUNT>] <BRICK> ... <start|stop|status|commit|force>
使用start是先將數據遷移到其它可用的Brick,遷移結束后才將該Brick移除
使用commit命令執行Brick移除,則不會進行數據遷移而直接刪除Brick
遷移卷 (主要完成數據在卷之間的在線遷移)
volume replace-brick <VOLNAME> <SOURCE-BRICK> <NEW-BRICK> {commit force}
重新均衡卷
不遷移數據:
# gluster volume rebalance lay-outstart
# gluster volume rebalance start|stop|status
# gluster volume rebalance startforce
客戶端掛載卷
mount -t glusterfs 192.168.1.28:/testvol /mnt/
異常信息:volume add-brick: failed: /data/brick/brick01 is already part of a volume
說明/data/brick/brick01 曾經是一個Brick。解決方法:
# rm -rf /data/brick/brick01.glusterfs
# setfattr -x trusted.glusterfs.volume-id /data/brick/brick01
# setfattr -x trusted.gfid /data/brick/brick01
遇到一台機器報錯:
E [MSGID: 101066] [graph.c:327:glusterfs_graph_init] 0-data-quick-read: initializing translator failed
E [MSGID: 101176] [graph.c:698:glusterfs_graph_activate] 0-graph: init failed
W [MSGID: 101002] [options.c:995:xl_opt_validate] 0-glusterfs: option 'address-family' is deprecated, preferred is 'transport.address-family', continuing with correction
E [MSGID: 127002] [quick-read.c:838:check_cache_size_ok] 0-mysql-backup-quick-read: Cache size 4294967296 is greater than the max size of 4142899200
排查發現,機器的內存小於glusterfs的performance.cache-size,導致掛載失敗,調整cache-size之后解決。