GlusterFs是一個開源分布式文件系統
GlusterFs主要由存儲服務器,客戶端及NFS/samba存儲網關組成,
GlusterFs特點:擴展性和高性能,高可用性,全局統一命名空間,彈性卷管理,基于標準協議
GlusterFs術語:Brick(存儲塊),Vlume(邏輯卷),FUSE(內核模塊),VFS,Glusterd(后臺管理進程)
GlusterFs的工作原理:
彈性HASH算法的優點:1)保證數據平均分布在每個Brick中。
(2)解決了對元數據服務器的依賴,進而解決了單點故障及訪問瓶頸。
GlusterFS七種卷:分布式卷,條帶卷,復制卷,分布式條帶卷,分布式復制卷,條帶復制卷,分布式條帶復制卷
GlusterFS七種卷中,具備冗余性的:復制卷,分布式復制卷,條帶復制卷,分布式條帶復制卷。
實驗步驟如下:四臺服務器,一臺客戶機
四臺服務器的信息如下:
在所有節點上執行以下操作
開啟4臺虛擬機,根據上述表添加磁盤,通過fdisk分區,mkfs格式化,創建相應的掛載目錄,并將格式化的磁盤掛載到相應的目錄中,最后修改/etc/fstab配置文件,使其永久生效。
附上命令,以node1為例
(1)創建掛載目錄:mkidr -p /b3 /c4 /d5 /e6
(2)分區所有硬盤以sdb為例:fdisk /dev/sdb
(3)格式化:#mkfs.ext4 /dev/sdb1
(4)掛載:#mount /dev/sdb1 /b3
(5)永久掛載
#vim /etc/fstab
/dev/sdb1 /b3 ext4 defaults 0 0
/dev/sdc1 /c4 ext4 defaults 0 0
/dev/sdd1 /d5 ext4 defaults 0 0
/dev/sde1 /e6 ext4 defaults 0 0
二,
1.關閉所有防火墻和SElinux
#systemctl stop firewalld
#systemctl disable firewalld
#setenforce 0
2.配置hosts文件(所有主機上都要配置)
vim /etc/hosts
192.168.1.1 node1
192.168.1.2 node2
192.168.1.3 node3
192.168.1.4 node4
3.安裝軟件,在所有的服務器上都要安裝(GlusterFS)
#yum -y install glusterfs glusterfs-server glusterfs-fuse glusterfs-rdma
4.啟動glusterfs(在所有節點上)
#systemctl start glusterd
#systemctl enable glusterd
5.添加節點(在node1上執行),添加node1—node4節點
[root@node1 ~]# gluster peer probe node1
peer probe: success. Probe on localhost not needed
[root@node1 ~]# gluster peer probe node2
peer probe: success.
[root@node1 ~]# gluster peer probe node3
peer probe: success.
[root@node1 ~]# gluster peer probe node4
peer probe: success.
6.創建卷(在node1上創建卷)(加粗的為命令)
(1)創建分布式卷:
[root@node1 ~]# gluster volume create dis-volume node1:/e6 node2:/e6 force
volume create: dis-volume: success: please start the volume to access data
啟動卷:
[root@node1 ~]# gluster volume start dis-volume
volume start: dis-volume: success
沒有指定類型默認創建的是分布式卷
(2)創建條帶卷
[root@node1 ~]# gluster volume create stripe-volume stripe 2 node1:/d5 node2:/d5 force
volume create: stripe-volume: success: please start the volume to access data
啟動卷:
[root@node1 ~]# gluster volume start stripe-volume
volume start: stripe-volume: success
(3)創建復制卷
[root@node1 ~]# gluster volume create rep-volume replica 2 node3:/d5 node4:/d5 force
volume create: rep-volume: success: please start the volume to access data
啟動卷:
[root@node1 ~]# gluster volume start rep-volume
volume start: rep-volume: success
(4)創建分布式條帶卷
[root@node1 ~]# gluster volume create dis-stripe stripe 2 node1:/b3 node2:/b3 node3:/b3 node4:/b3 force
volume create: dis-stripe: success: please start the volume to access data
啟動:
[root@node1 ~]# gluster volume start dis-stripe
volume start: dis-stripe: success
(5)創建分布式復制卷
[root@node1 ~]# gluster volume create dis-rep replica 2 node1:/c4 node2:/c4 node3:/c4 node4:/c4 force
volume create: dis-rep: success: please start the volume to access data
啟動卷:
[root@node1 ~]# gluster volume start dis-rep
volume start: dis-rep: success
三,客戶端配置如下:
1.安裝客戶端軟件
[root@node5 yum.repos.d]# yum -y install glusterfs glusterfs-fuse
2創建掛載目錄
[root@node5 ~]# mkdir -p /test /{dis,stripe,rep,dis_and_stripe,dis_and_rep}
3.修改hosts文件
[root@node5 ~]# vim /etc/hosts
192.168.1.1 node1
192.168.1.2 node2
192.168.1.3 node3
192.168.1.6 node6
192.168.1.4 node4
192.168.1.5 node5
4.掛載gluster文件系統
[root@node5 test]# mount -t glusterfs node1:dis-volume /test/dis
[root@node5 test]# mount -t glusterfs node1:stripe-volume /test/stripe
[root@node5 test]# mount -t glusterfs node1:rep-volume /test/rep
[root@node5 test]# mount -t glusterfs node1:dis-volume /test/dis_and_stripe
[root@node5 test]# mount -t glusterfs node1:dis-rep /test/dis_and_rep
四、測試gluster文件系統
1.卷中寫入文件(前5條生成一個43M的文件,后5條石復制文件到卷中)
[root@node5 ~]# dd if=/dev/zero of=demo1.log bs=43M count=1
[root@node5 ~]# dd if=/dev/zero of=demo2.log bs=43M count=1
[root@node5 ~]# dd if=/dev/zero of=demo3.log bs=43M count=1
[root@node5 ~]# dd if=/dev/zero of=demo4.log bs=43M count=1
[root@node5 ~]# dd if=/dev/zero of=demo5.log bs=43M count=1
[root@node5 ~]#cp demo /test/dis
[root@node5 ~]#cp demo /test/stripe
[root@node5 ~]#cp demo /test/rep
[root@node5 ~]#cp demo /test/dis_and_stripe
[root@node5 ~]#*cp demo /test/dis_and_rep
.查看文件分布
(1)查看分布式卷文件分布
[root@node1 ~]# ll -h /e6
總用量 130M
-rw-r--r-- 2 root root 43M 10月 25 19:35 demo1.log
-rw-r--r-- 2 root root 43M 10月 25 19:35 demo2.log
-rw-r--r-- 2 root root 43M 10月 25 19:35 demo3.log
drwx------ 2 root root 16K 9月 23 09:07 lost+found
[root@node2 ~]# ll -h /e6
總用量 86M
-rw-r--r-- 2 root root 43M 10月 25 19:35 demo4.log
-rw-r--r-- 2 root root 43M 10月 25 19:36 demo5.log
[root@node2 ~]#
(2)查看條帶卷文件分布
[root@node1 ~]# ll -h /d5
總用量 108M
-rw-r--r-- 2 root root 22M 10月 25 19:34 demo1.log
-rw-r--r-- 2 root root 22M 10月 25 19:34 demo2.log
-rw-r--r-- 2 root root 22M 10月 25 19:34 demo3.log
-rw-r--r-- 2 root root 22M 10月 25 19:34 demo4.log
-rw-r--r-- 2 root root 22M 10月 25 19:36 demo5.log
drwx------ 2 root root 16K 9月 23 09:06 lost+found
[root@node2 ~]# ll -h /d5
總用量 108M
-rw-r--r-- 2 root root 22M 10月 25 19:34 demo1.log
-rw-r--r-- 2 root root 22M 10月 25 19:34 demo2.log
-rw-r--r-- 2 root root 22M 10月 25 19:34 demo3.log
-rw-r--r-- 2 root root 22M 10月 25 19:34 demo4.log
-rw-r--r-- 2 root root 22M 10月 25 19:36 demo5.log
drwx------ 2 root root 16K 9月 23 09:14 lost+found
(3)查看復制卷文件分布
[root@node3 ~]# ll -h /d5
總用量 216M
-rw-r--r-- 2 root root 43M 10月 25 19:34 demo1.log
-rw-r--r-- 2 root root 43M 10月 25 19:34 demo2.log
-rw-r--r-- 2 root root 43M 10月 25 19:34 demo3.log
-rw-r--r-- 2 root root 43M 10月 25 19:34 demo4.log
-rw-r--r-- 2 root root 43M 10月 25 19:36 demo5.log
drwx------ 2 root root 16K 9月 23 09:59 lost+found
[root@node4 ~]# ll -h /d5**
總用量 216M
-rw-r--r-- 2 root root 43M 10月 25 19:34 demo1.log
-rw-r--r-- 2 root root 43M 10月 25 19:34 demo2.log
-rw-r--r-- 2 root root 43M 10月 25 19:34 demo3.log
-rw-r--r-- 2 root root 43M 10月 25 19:34 demo4.log
-rw-r--r-- 2 root root 43M 10月 25 19:36 demo5.log
drwx------ 2 root root 16K 9月 23 10:08 lost+found
實驗到此結束
其它的維護命令
(1)查看glusterfs卷
[root@node1 ~]# gluster volume list
dis-rep
dis-stripe
dis-volume
rep-volume
stripe-volume
(2)查看所有卷的狀態
[root@node1 ~]# gluster volume status
(3)查看所有卷的信息
[root@node1 ~]# gluster volume info
(4)設置卷的訪問控制
[root@node1 ~]# gluster volume set dis-rep auth.allow 192.168.1.*
volume set: success
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。