CentOS7下分佈式系統GlusterFS安裝配置

一、主機規劃

操作系統版本爲CentOS 7.2.1511

node1:172.17.0.1 gfs1

node2:172.17.0.2 gfs2

node3:172.17.0.3 gfs3

node4:172.17.0.4 gfs

client:172.17.0.5 


二、安裝:

1.在node1-4上安裝glusterfs-server

yum install -y centos-release-gluster38

yum install -y glusterfs glusterfs-server glusterfs-fuse


設置開機自啓動並啓動

systemctl enable glusterd.service

systemctl start glusterd.service


2.在gfs1-gfs4節點上配置整個GlusterFS集羣,把各個節點加入到集羣

vim /etc/hosts

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4

::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

172.17.0.1  gfs1

172.17.0.2  gfs2

172.17.0.3  gfs3

172.17.0.4  gfs4


[root@gfs1 ~]# gluster peer probe gfs1

[root@gfs1 ~]# gluster peer probe gfs2

[root@gfs1 ~]# gluster peer probe gfs3

[root@gfs1 ~]# gluster peer probe gfs4


3.查看節點狀態

[root@gfs1 ~]#gluster peer status


4.在gfs{1-4}上創建數據存儲目錄

# mkdir -p  /usr/local/share/models


5.在gfs1上創建GlusterFS磁盤

注意:

加上replica 4就是4個節點中,每個節點都要把數據存儲一次,就是一個數據存儲4份,每個節點一份

如果不加replica 4,就是4個節點的磁盤空間整合成一個硬盤,

[root@gfs1 ~]#gluster volume create models replica 4 gfs1:/usr/local/share/models gfs2:/usr/local/share/models gfs3:/usr/local/share/models gfs4:/usr/local/share/models force


6.啓動

[root@gfs1 ~]# gluster volume start models


客戶端

1.部署GlusterFS客戶端並mount GlusterFS文件系統

[root@client ~]# yum install -y centos-release-gluster38

[root@client ~]# yum install -y glusterfs glusterfs-fuse

[root@client ~]# mkdir -p /mnt/models

[root@client ~]# mount -t glusterfs -o ro gfs1:models /mnt/models/


2.查看效果

[root@client ~]# df -h


3.觀察分佈式文件系統的效果

umount /mnt/models

mount -t glusterfs -o rw gfs1:models /mnt/models/

[root@client ~]# cd /mnt/models/

[root@client mnt]# for i in `seq -w 10`; do mkdir $i ; done

[root@client models]# for i in `seq -w 10`; do mkdir $i ; done

[root@client models]# ll

total 40

drwxr-xr-x 2 root root 4096 Feb 14 21:56 01

drwxr-xr-x 2 root root 4096 Feb 14 21:59 02

drwxr-xr-x 2 root root 4096 Feb 14 21:56 03

drwxr-xr-x 2 root root 4096 Feb 14 21:56 04

drwxr-xr-x 2 root root 4096 Feb 14 21:56 05

drwxr-xr-x 2 root root 4096 Feb 14 21:56 06

drwxr-xr-x 2 root root 4096 Feb 14 21:59 07

drwxr-xr-x 2 root root 4096 Feb 14 21:56 08

drwxr-xr-x 2 root root 4096 Feb 14 21:56 09

drwxr-xr-x 2 root root 4096 Feb 14 21:59 10


分別在4臺Server上查看新建的文件夾同步情況

[root@gfs1 ~]# ls /usr/local/share/models/ -l

total 0

drwxr-xr-x 2 root root 6 Feb 14 21:56 01

drwxr-xr-x 2 root root 6 Feb 14 21:59 02

drwxr-xr-x 2 root root 6 Feb 14 21:56 03

drwxr-xr-x 2 root root 6 Feb 14 21:56 04

drwxr-xr-x 2 root root 6 Feb 14 21:56 05

drwxr-xr-x 2 root root 6 Feb 14 21:56 06

drwxr-xr-x 2 root root 6 Feb 14 21:59 07

drwxr-xr-x 2 root root 6 Feb 14 21:56 08

drwxr-xr-x 2 root root 6 Feb 14 21:56 09

drwxr-xr-x 2 root root 6 Feb 14 21:59 10


可以看到4臺服務器都同步過來了。


當單臺Server出現故障,比如服務器斷開連接的情況,創建一個文件需要比較長的時間。

但是當Server重新連上之後,文件可以及時的同步過來。


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章