參考文檔:html
Glusterfs(Gluster file system)是開源的,具備強大橫向擴展能力的(scale-out),分佈式的,可未來自多個服務器的存儲資源經過tcp/ip或infiniBand RDMA 網絡整合到一個統一的全局命名空間中的文件系統。node
Hostnamelinux |
IPgit |
Servicegithub |
Remarkvim |
glusterfs-clientcentos |
172.30.200.50緩存 |
glusterfs(3.12.9) 服務器 glusterfs-fuse網絡 |
客戶端 |
glusterfs01 |
172.30.200.51 |
glusterfs(3.12.9) glusterfs-server(3.12.9) glusterfs-fuse |
服務器端 |
glusterfs02 |
172.30.200.52 |
glusterfs(3.12.9) glusterfs-server(3.12.9) glusterfs-fuse |
服務器端 |
glusterfs03 |
172.30.200.53 |
glusterfs(3.12.9) glusterfs-server(3.12.9) glusterfs-fuse |
服務器端 |
glusterfs04 |
172.30.200.54 |
glusterfs(3.12.9) glusterfs-server(3.12.9) glusterfs-fuse |
服務器端 |
# 全部節點保持一致的hosts便可,以gluster01節點爲例; # 綁定hosts不是必須的,後續組建受信存儲池也可以使用ip的形式 [root@glusterfs01 ~]# vim /etc/hosts # glusterfs 172.30.200.50 glusterfs-client 172.30.200.51 glusterfs01 172.30.200.52 glusterfs02 172.30.200.53 glusterfs03 172.30.200.54 glusterfs04 [root@glusterfs01 ~]# cat /etc/hosts
# 至少4個Brick Server節點須要保持時鐘同步(重要),以glusterfs01節點爲例 [root@glusterfs01 ~]# yum install chrony -y # 編輯/etc/chrony.conf文件,設置」172.20.0.252」爲時鐘源; [root@glusterfs01 ~]# egrep -v "^$|^#" /etc/chrony.conf server 172.20.0.252 iburst driftfile /var/lib/chrony/drift makestep 1.0 3 rtcsync logdir /var/log/chrony # 設置開機啓動,並重啓 [root@glusterfs01 ~]# systemctl enable chronyd.service [root@glusterfs01 ~]# systemctl restart chronyd.service # 查看狀態 [root@glusterfs01 ~]# systemctl status chronyd.service [root@glusterfs01 ~]# chronyc sources -v
# 所有節點安裝glusterfs yum源 [root@glusterfs01 ~]# yum install -y centos-release-gluster # 查看 [root@glusterfs01 ~]# yum repolist
# 提早統一設置iptables(至少4個Brick Server節點),以glusterfs01節點爲例; # 初始環境已使用iptables替代centos7.x自帶的firewalld,同時關閉selinux; [root@glusterfs01 ~]# vim /etc/sysconfig/iptables # tcp24007:24008:glusterfsd daemon management服務監聽端口; # tcp49152:49160:3.4版本以後(以前的版本的起始端口是24009),啓動1個brick,即啓動1個監聽端口,起始端口爲49152,依次類推,如這裏設置49152:49160,可開啓9個brick; # 另若是啓動nfs server,須要開啓38465:38467,111等端口 -A INPUT -p tcp -m state --state NEW -m tcp --dport 24007:24008 -j ACCEPT -A INPUT -p tcp -m state --state NEW -m tcp --dport 49152:49160 -j ACCEPT [root@glusterfs01 ~]# service iptables restart
# 各brick server的磁盤掛載前須要建立分區並格式化,以glusterfs01節點爲例; # 將整個/dev/sdb磁盤設置爲1個分區,分區設置默認便可 [root@glusterfs01 ~]# fdisk /dev/sdb Command (m for help): n Select (default p): Partition number (1-4, default 1): First sector (2048-209715199, default 2048): Last sector, +sectors or +size{K,M,G} (2048-209715199, default 209715199): Command (m for help): w # 查看 [root@glusterfs01 ~]# fdisk -l /dev/sdb
[root@glusterfs01 ~]# mkfs.xfs -i size=512 /dev/sdb1
# 建立掛載目錄,目錄名自定義; # 這裏爲區分,能夠將4個server節點的目錄名按順序命名(非必須) [root@glusterfs01 ~]# mkdir -p /brick1 [root@glusterfs02 ~]# mkdir -p /brick2 [root@glusterfs03 ~]# mkdir -p /brick3 [root@glusterfs04 ~]# mkdir -p /brick4 # 修改/etc/fstab文件,以glusterfs01節點爲例,注意其他3各節點掛載點目錄名不一樣; # 第一欄:設備裝置名; # 第二欄:掛載點; # 第三欄:文件系統; # 第四欄:文件系統參數,默認狀況使用 defaults 便可,同時具備 rw, suid, dev, exec, auto, nouser, async 等參數; # 第五欄:是否被 dump 備份命令做用,"0"表明不作 dump 備份; "1"表明要天天進行 dump; "2"表明其餘不定日期的 dump; 一般設置"0" 或者"1"; # 第六欄:是否以 fsck 檢驗扇區,啓動過程當中,系統默認會以 fsck 檢驗 filesystem 是否完整 (clean), 但某些 filesystem 是不須要檢驗的,如swap;"0"是不要檢驗,"1"表示最先檢驗(通常只有根目錄會配置爲 "1"),"2"是檢驗,但晚於"1";一般根目錄配置爲"1" ,其他須要要檢驗的 filesystem 都配置爲"2"; [root@glusterfs01 ~]# echo "/dev/sdb1 /brick1 xfs defaults 1 2" >> /etc/fstab # 掛載並展現 [root@glusterfs01 ~]# mount -a && mount
# 在4個brick server節點安裝glusterfs-server,以glusterfs01節點爲例 [root@glusterfs01 ~]# yum install -y glusterfs-server
[root@glusterfs01 ~]# systemctl enable glusterd [root@glusterfs01 ~]# systemctl restart glusterd # 查看狀態 [root@glusterfs01 ~]# systemctl status glusterd
# 查看服務監聽端口 [root@glusterfs01 ~]# netstat -tunlp
受信存儲池(trusted storage pools),是1個可信的網絡存儲服務器,爲卷提供brick,能夠理解爲集羣。
# 在任意一個server節點組建受信存儲池都可,即由任意節點邀請其餘節點組建存儲池; # 組建時,作爲」邀請者」,不須要再加入本節點; # 使用ip或dns主機名解析均可以,這裏已在hosts文件綁定主機,採用主機名; # 從集羣移除節點:gluster peer detach <ip or hostname> [root@glusterfs01 ~]# gluster peer probe glusterfs02 [root@glusterfs01 ~]# gluster peer probe glusterfs03 [root@glusterfs01 ~]# gluster peer probe glusterfs04
# 查看受信存儲池狀態; # 在glusterfs01節點查看集羣狀態,不會list出本節點,只展現peers [root@glusterfs01 ~]# gluster peer status
# 客戶端主要安裝兩個組件,glusterfs與glusterfs-fuse; # glusterfs-client具有如數據卷管理、I/O 調度、文件定位、數據緩存等功能; # glusterfs-fuse將遠端glusterfs掛載到本地文件系統,可經過」modinfo fuse」,「ll /dev/fuse」等命令查看 [root@glusterfs-client ~]# yum install -y glusterfs glusterfs-fuse