天天看點

gluster

關于glusterfs 配置叢集的過程總結:

首先使用幹淨的centos 7 2台伺服器示範 ,新安裝的進行試驗:

1 防火牆 iptables -F

2 時鐘保持一緻 NTP

3 注意關閉selinux setenforce 0

4 設定好主機名和IP的對應關系,/etc/hosts 或者使用DNS

5 添加獨立的磁盤分區

用到的指令fdisk -l 檢視未使用的磁盤

使用fdisk /dev/sdb 對其進行分區,n建立主分區即可

再次進行檢視fdisk -l , 由于我分了一個區是以看到的是/dev/sdb1

然後進行xfS 的格式化操作

mkfs.xfs -i size=512 /dev/sdb1 也或者使用mkfs.xfs -f /dev/sdb1

6 安裝glusterfs 伺服器:

yum install epel-release

yum install centos-release-gluster -y

yum install glusterfs-server glusterfs glusterfs-fuse -y

rpm -ql glusterfs-server 可以看下gluster的檔案安裝的位置

7 service glusterd start 啟動成功

service glusterd status 檢視狀态

8 ps -ef |grep gluster

9 chkconfig glusterd on 開機啟動

10 mkdir -p /data/brick1 建立準備挂載的目錄

11 echo '/dev/sdb1 /data/brick1 xfs defaults 1 2' >> /etc/fstab

12 mount -a && mount&&df -h 挂載并進行檢視,這個是解除安裝的指令umount /data/brick1/

13 gluster peer probe 172.17.0.6 依次添加存儲節點即可\加入可信任存儲池

13 gluster peer status 檢視狀态

14 gluster volume create gv0 replica 2 172.17.0.5:/data/brick1 172.17.0.6:/data/brick1 force 添加各個節點伺服器卷資訊

15 gluster volume start gv0 啟動存儲

16 gluster volume info 檢視卷資訊

17 gluster volume list 檢視創造的卷名稱

18 用戶端安裝 :yum install glusterfs glusterfs-fuse attr -y

或者yum -y install glusterfs glusterfs-fuse安裝:

用戶端挂載:mount -t gluster 172.17.0.5:/gv0 /mnt

https://blog.csdn.net/sj349781478/article/details/73732746

這個值得借鑒的地方是主備挂載自動切換

遇到的情況:理論上是說不需要force的。一個是列腦的情況建議用3副本。

[root@gluster1 brick1]# gluster volume create gv0 replica 2 172.17.0.5:/gluster/data 172.17.0.6:/gluster/data

Replica 2 volumes are prone to split-brain. Use Arbiter or Replica 3 to avoid this. See: http://docs.gluster.org/en/latest/Administrator%20Guide/Split%20brain%20and%20ways%20to%20deal%20with%20it/.

Do you still want to continue?

(y/n) y

volume create: gv0: failed: The brick 172.17.0.5:/gluster/data is a mount point. Please create a sub-directory under the mount point and use that as the brick directory. Or use 'force' at the end of the command if you want to override this behavior.

[root@gluster1 brick1]# gluster volume create gv0 replica 2 172.17.0.5:/gluster/data 172.17.0.6:/gluster/data force

volume create: gv0: success: please start the volume to access data

Replica 2 volumes are prone to split-brain. Use Arbiter or Replica 3 to avoid this 遇到的這種情況

注意單獨使用的分區空間大小要一緻,避免這一坑。

繼續閱讀