站長資訊網
最全最豐富的資訊網站

CentOS 7.5下部署GlusterFS分布式存儲集群環境

最小化安裝的CentOS 7.5
內存大于1GB
關閉selinux,防火墻端口放行(port:24007,111)(測試建議關閉firewalld)

一、環境部署

所有軟件包離線安裝,原因是yum安裝的不能很好的控制版,用到的軟件包統一放到/gfs目錄,包已整理好

——————————————分割線——————————————

Matlab R2017b的Linux版下載地址可從以下信息的得到下載:

點擊這個http://www.linuxidc.com/Linux/2013-12/93755.htm 鏈接關注 Linux公社官方微信,關注后回復數字158712。即可得到網友的分享密碼。

如果取消關注Linux公社公眾號,即使再次關注,也將無法提供本服務!

鏈接: https://pan.baidu.com/s/1eSSX46yaGBUoEmCqjeAeqw 密碼:獲得見上面的方法,地址失效請在下面留言。

——————————————分割線——————————————

  • 測試用的磁盤分配以及服務器架構圖
    CentOS 7.5下部署GlusterFS分布式存儲集群環境

  • basic代表服務器本來使用的磁盤,基礎上再添加上圖相應的磁盤,由于是測試用,為方便直觀理解,磁盤大小就是后面的數字:如sdb3,該磁盤大小為3GB。
  • 卷的分布方案

卷名稱 卷類型 空間大小/GB  存儲塊
dis-volume 分布式卷 12 node1(/sde6),node2(/sde6)
stripe-volume 條帶卷 10 node1(/sdd5),node2(/sdd5)
rep-volume 復制卷 5 node3(/sdd5),node4(/sdd5)
dis-stripe 分布式條帶卷 12 node1(/sdb3),node2(/sdb3),node3(/sdb3),node4(/sdb3)
dis-rep 分布式復制卷 8 node1(/sdc4),node2(/sdc4),node3(sdc4),node4(sdc4)
  • 全部主機修改主機名
  • 全部主機配置hosts文件,一樣的
  • 全部node主機創建掛載文件夾,依實際掛載點創建
  • 全部主機創建/gfs文件夾,將所需軟件包放入

    mkdir /{gfs,sdb3,sdc4,sdd5} cat /etc/hosts

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4  ::1         localhost localhost.localdomain localhost6 localhost6.localdomain6  192.168.64.11 node1  192.168.64.12 node2  192.168.64.13 node3  192.168.64.14 node4  192.168.64.15 client
  • 完畢之后進行ping測試
  • 通過傳輸方式將軟件包上傳到/gfs文件(里面有一個repo文件夾也要上傳)
  • 以上一切完成之后,全部node主機執行以下腳本
vim install.sh  #!/bin/bash  for i in $(fdisk -l | grep -wo "/dev/sd[b-z]" | sort)  do  dd if=/dev/zero of=$i bs=1024 count=1024  fdisk $i << EOF  n  p        w  EOF  #空行很重要不要刪除  partprobe $i   #//不重啟系統識別分區  mkfs.ext4 ${i}1   #//格式化分區  done    mkdir /b3 /c4 /d5 /e6   fdisk -l | grep -w "/dev/sd[b-z]" | sed -r 's/.*(/d.{8}).*/1/g' | sed -r 's/(.*)(.{3}):(.*)/mount 121 /23/' | bash  fdisk -l | grep -w "/dev/sd[b-z]" | sed -r 's/.*(/d.{8}).*/1/g' | sed -r 's/(.*)(.{3}):(.*)/121 /23 xfs default 0 0/' >> /etc/fstab  #-w 只顯示全字符合的列。  iptables -F  systemctl stop firewalld  setenforce 0    cat << EOF >> /etc/yum.repos.d/gfs.repo   [gfs]  name=gfs  baseurl=file:///gfs  gpgcheck=0  enabled=1  EOF    yum clean all && yum makecache  yum -y install glusterfs glusterfs-server glusterfs-fuse glusterfs-rdma  systemctl start glusterd  systemctl enable glusterd  EOF

sh install.sh //執行腳本 netstat -lnpt //查看gluster服務端口是否開啟
腳本簡單理解

  • 再node1上執行如下命令構建gluster集群
[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. 

[root@node1 ~]# gluster peer status //在每個節點上執行查看集群狀態;正常時為(Connected)

二、創建卷

1.創建分布式卷(擴大磁盤空間,讀寫速度快,沒有容錯能力)

[root@node1 ~]# gluster volume create dis-volume node1:/sde6 node2:/sde6 force //dis-volume為卷名稱,未指定創建卷類型,默認為分布式卷 volume create: dis-volume: success: please start the volume to access data [root@node1 ~]# gluster volume start dis-volume volume start: dis-volume: success [root@node1 ~]# gluster volume info dis-volume //查看該卷的相關信息

2.創建條帶卷(以數據塊為單位存儲,沒有容錯性)

[root@node1 ~]# gluster volume create stripe-volume stripe 2 node1:/sdd5 node2:/sdd5 force [root@node1 ~]# gluster volume start stripe-volume volume start: stripe-volume: success //stripe表示卷類型條帶卷,后面的數量表示條帶數

3.創建復制卷(磁盤空間為總空間一半,具備容錯性,讀快,寫慢)

[root@node1 ~]# gluster volume create rep-volume replica 2 node3:/sdd5 node4:/sdd5 force [root@node1 ~]# gluster volume start rep-volume volume start: rep-volume: success

4.創建分布式條帶卷(加大容量,讀取快,沒有容錯性)

[root@node1 ~]# gluster volume create dis-stripe stripe 2 node1:/sdb3 node2:/sdb3 node3:/sdb3 node4:/sdb3 force //指定類型為Distributed-Stripe,數值為2,而且后面跟了4個Brick Server,是2的2倍,所以創建的是分布式條帶卷。 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:/sdc4 node2:/sdc4 node3:/sdc4 node4:/sdc4/ force //指定類型為Distributed-Replicate,數值為2,而且后面跟了4個Brick Server,是2的2倍,所以創建的是分布式復制卷。 volume create: dis-rep: success: please start the volume to access data [root@node1 ~]# gluster volume start dis-rep volume start: dis-rep: success

三、部署Gluster客戶端

1.安裝客戶端軟件
  • 將軟件包放至/gfs文件夾
  • 修改前面提到的hostname以及hosts
  • 運行如下腳本
vim in_cl.sh  #!/bin/bash    cat << EOF >> /etc/yum.repos.d/gfs.repo   [gfs]  name=gfs  baseurl=file:///gfs  gpgcheck=0  enabled=1  EOF    yum clean all && yum makecache  yum -y install glusterfs glusterfs-server glusterfs-fuse glusterfs-rdma  systemctl start glusterd  systemctl enable glusterd

sh in_cl.sh netstat -lnpt | grep glu //可以看到服務已經啟動
[root@client ~]# mkdir -pv /test/{dis,stripe,rep,dis_stripe,dis_rep} //創建掛載目錄 [root@client ~]# mount -t glusterfs node1:dis-volume /test/dis [root@client ~]# mount -t glusterfs node1:stripe-volume /test/stripe/ [root@client ~]# mount -t glusterfs node1:rep-volume /test/rep/ [root@client ~]# mount -t glusterfs node1:dis-stripe /test/dis_stripe/ [root@client ~]# mount -t glusterfs node1:dis-rep /test/dis_rep/ //掛載glusterfs文件系統到本地客戶端,所制定的node1節點只是為了獲取配置信息,不代表只和他進行數據傳輸,會根據配置針對集群來進行數據的存放

  • 修改fstab文件實現永久掛載
  • 添加如下文件

    vim /etc/fstab

node1:dis-volume        /test/dis               glusterfs defaults,_netdev 0 0  node1:stripe-volume     /test/stripe            glusterfs defaults,_netdev 0 0  node1:rep-volume        /test/rep               glusterfs defaults,_netdev 0 0  node1:dis-rep           /test/dis_rep   glusterfs defaults,_netdev 0 0  node1:dis-stripe        /test/dis_stripe        glusterfs defaults,_netdev 0 0

四、測試

  • 生成測試文件(該文件雖沒有數據,但是可以進行測試用途)

    [root@client ~]# for i in {1..5};do dd if=/dev/zero of=/root/demon$i.log bs=1M count=43;done [root@client ~]# cp demon* /test/dis && cp demon* /test/dis_rep/ && cp demon* /test/dis_stripe/ && cp demon* /test/rep/ && cp demon* /test/stripe/

  • 查看文件分布狀態
  • 分布式卷(node1和node2的/sde6目錄查看,可以看到文件被分散開存放)
[root@node1 ~]# ll -h /sde6/  總用量 130M  -rw-r--r--. 2 root root 43M 4月   2 21:32 demon1.log  -rw-r--r--. 2 root root 43M 4月   2 21:32 demon3.log  -rw-r--r--. 2 root root 43M 4月   2 21:32 demon4.log  drwx------. 2 root root 16K 4月   3 2019 lost+found  [root@node2 ~]# ll -h /sde6/  總用量 87M  -rw-r--r--. 2 root root 43M 4月   3 05:32 demon2.log  -rw-r--r--. 2 root root 43M 4月   3 05:32 demon5.log  drwx------. 2 root root 16K 4月   3 03:01 lost+found
  • 條帶卷(node1和node2的/sdd5目錄查看,清晰看到是以數據塊為單位存儲的)
[root@node1 ~]# ls -lh /sdd5/  總用量 108M  -rw-r--r--. 2 root root 22M 4月   2 21:31 demon1.log  -rw-r--r--. 2 root root 22M 4月   2 21:31 demon2.log  -rw-r--r--. 2 root root 22M 4月   2 21:31 demon3.log  -rw-r--r--. 2 root root 22M 4月   2 21:31 demon4.log  -rw-r--r--. 2 root root 22M 4月   2 21:31 demon5.log  [root@node2 ~]# ls -lh /sdd5/  總用量 108M  -rw-r--r--. 2 root root 22M 4月   3 05:31 demon1.log  -rw-r--r--. 2 root root 22M 4月   3 05:31 demon2.log  -rw-r--r--. 2 root root 22M 4月   3 05:31 demon3.log  -rw-r--r--. 2 root root 22M 4月   3 05:31 demon4.log  -rw-r--r--. 2 root root 22M 4月   3 05:31 demon5.log
  • 復制卷(node3和node4的/sdd5目錄,數據有備份)
[root@node3 ~]# ls -lh /sdd5/  總用量 216M  -rw-r--r--. 2 root root 43M 4月   3 05:32 demon1.log  -rw-r--r--. 2 root root 43M 4月   3 05:32 demon2.log  -rw-r--r--. 2 root root 43M 4月   3 05:33 demon3.log  -rw-r--r--. 2 root root 43M 4月   3 05:33 demon4.log  -rw-r--r--. 2 root root 43M 4月   3 05:33 demon5.log  drwx------. 2 root root 16K 4月   3 03:03 lost+found  [root@node4 ~]# ls -lh /sdd5/  總用量 216M  -rw-r--r--. 2 root root 43M 4月   3 05:32 demon1.log  -rw-r--r--. 2 root root 43M 4月   3 05:32 demon2.log  -rw-r--r--. 2 root root 43M 4月   3 05:33 demon3.log  -rw-r--r--. 2 root root 43M 4月   3 05:33 demon4.log  -rw-r--r--. 2 root root 43M 4月   3 05:33 demon5.log  drwx------. 2 root root 16K 4月   3 02:55 lost+found
  • 分布式條帶卷(節點1、2、3、4的/sdb3目錄,我日期沒有調整,海涵)
[root@node1 ~]# ls -lh /sdb3/  總用量 65M  -rw-r--r--. 2 root root 22M 4月   2 21:32 demon1.log  -rw-r--r--. 2 root root 22M 4月   2 21:32 demon3.log  -rw-r--r--. 2 root root 22M 4月   2 21:32 demon4.log  drwx------. 2 root root 16K 4月   2 18:37 lost+found  [root@node2 ~]# ls -lh /sdb3/  總用量 65M  -rw-r--r--. 2 root root 22M 4月   3 05:32 demon1.log  -rw-r--r--. 2 root root 22M 4月   3 05:32 demon3.log  -rw-r--r--. 2 root root 22M 4月   3 05:32 demon4.log  drwx------. 2 root root 16K 4月   3 03:01 lost+found  [root@node3 ~]# ls -lh /sdb3/  總用量 44M  -rw-r--r--. 2 root root 22M 4月   3 05:32 demon2.log  -rw-r--r--. 2 root root 22M 4月   3 05:32 demon5.log  drwx------. 2 root root 16K 4月   3 03:03 lost+found  [root@node4 ~]# ls -lh /sdb3/  總用量 44M  -rw-r--r--. 2 root root 22M 4月   3 05:32 demon2.log  -rw-r--r--. 2 root root 22M 4月   3 05:32 demon5.log  drwx------. 2 root root 16K 4月   3 02:55 lost+found
  • 分布式復制卷(節點1、2、3、4的/sdc4目錄,可看到文件沒有被分片,但是是分布開來存放的)
[root@node1 ~]# ls -lh /sdc4/  總用量 130M  -rw-r--r--. 2 root root 43M 4月   2 21:32 demon1.log  -rw-r--r--. 2 root root 43M 4月   2 21:32 demon3.log  -rw-r--r--. 2 root root 43M 4月   2 21:32 demon4.log  drwx------. 2 root root 16K 4月   3 2019 lost+found  [root@node2 ~]# ls -lh /sdc4/  總用量 130M  -rw-r--r--. 2 root root 43M 4月   3 05:32 demon1.log  -rw-r--r--. 2 root root 43M 4月   3 05:32 demon3.log  -rw-r--r--. 2 root root 43M 4月   3 05:32 demon4.log  drwx------. 2 root root 16K 4月   3 03:01 lost+found  [root@node3 ~]# ls -lh /sdc4/  總用量 87M  -rw-r--r--. 2 root root 43M 4月   3 05:32 demon2.log  -rw-r--r--. 2 root root 43M 4月   3 05:32 demon5.log  drwx------. 2 root root 16K 4月   3 03:01 lost+found  [root@node4 ~]# ls -lh /sdc4/  總用量 87M  -rw-r--r--. 2 root root 43M 4月   3 05:32 demon2.log  -rw-r--r--. 2 root root 43M 4月   3 05:32 demon5.log  drwx------. 2 root root 16K 4月   3 03:01 lost+found
破壞測試
  • 直接點關閉node2節點。關機操作。
  • 客戶端操作
[root@client ~]# ls /test/dis/  demon1.log  demon3.log  demon4.log  lost+found  //可以看到另外兩個文件直接找不到了  [root@client ~]# ls /test/stripe/  [root@client ~]#   //條帶卷因為文件都是分散開放,所以都沒有了  [root@client ~]# ls /test/dis_stripe/  demon2.log  demon5.log  lost+found  //分布式條帶卷,因為是分布式存儲node2宕機導致數據不完整不會顯示,1,3,4號文件丟失  [root@client ~]# ls /test/dis_rep/  demon1.log  demon2.log  demon3.log  demon4.log  demon5.log  lost+found  //分布式復制卷完全不受任何影響  //總而言之,了解各卷的特點,再細心觀察以下文件分布的具體位置,才能盡可能保證數據可靠性

五、維護命令

[root@node3 ~]# gluster volume list  dis-rep  dis-stripe  dis-volume  rep-volume  stripe-volume  //任何一個節點都可以查看集群列表  [root@node1 ~]# gluster volume info   //查看所有卷的信息  [root@node1 ~]# gluster volume status         //查看卷的狀態  [root@node3 ~]# gluster volume stop dis-stripe  Stopping volume will make its data inaccessible. Do you want to continue? (y/n) y  volume stop: dis-stripe: success  //停止卷  [root@node3 ~]# gluster volume start dis-stripe  //啟動卷  [root@node3 ~]# gluster volume delete dis-stripe  //刪除卷
贊(0)
分享到: 更多 (0)
網站地圖   滬ICP備18035694號-2    滬公網安備31011702889846號
91精品福利一区二区三区野战| 国产美女亚洲精品久久久综合 | 少妇人妻精品一区二区| 国产精品伦子一区二区三区| 真实国产乱子伦精品免费| 国产精品久久久久国产A级| 亚洲日韩精品无码专区网址| 精品日产卡一卡二卡三入口| 国产成人精品免费午夜app| 99精品国产在这里白浆| 亚洲国产精品无码专区影院| 国产成人麻豆亚洲综合无码精品| 国产精品亚洲αv天堂无码| 无码日韩精品一区二区人妻 | 婷婷成人国产精品| 日韩精品一区二区三区毛片| 日韩精品在线视频| AV在线播放日韩亚洲欧| 国产99视频免费精品是看6| 69国产成人综合久久精品91| 久九九久福利精品视频视频| 久久99国产精品久久| 亚洲精品亚洲人成在线观看| 国内精品久久久久久麻豆| 久热这里只有精品99国产6| 亚洲а∨精品天堂在线| 国产精品久久久久影视不卡| 亚洲精品视频在线观看视频| 亚洲精品视频在线观看视频| 18精品久久久无码午夜福利| 亚洲麻豆精品果冻传媒| 亚洲福利一区二区精品秒拍| 亚洲精品资源在线| 国产精品中文字幕在线观看| 无码国产精品一区二区免费式直播 | 国产精品免费小视频| 国产精品盗摄一区二区在线| 国产精品久久久久久久久齐齐| 国产成人精品视频午夜| 日韩精品无码免费专区午夜 | 国产精品免费久久久久电影网|