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. 檢視配置資訊
# cat /etc/rc.local
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等。
更多細節請參考《Gluster_File_System-3.3.0-Administration_Guide-en-US.pdf》。