天天看点

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 遇到的这种情况

注意单独使用的分区空间大小要一致,避免这一坑。

继续阅读