环境信息
操作系统:centos7
内存:2G
数据盘:20G(/dev/sdb1)
192.168.61.142 glusterfs-node1
192.168.61.141 glusterfs-node2
192.168.61.128 glusterfs-node3
安装步骤
-
环境准备
# 关闭防火墙,3台主机都需要执行 [root@glusterfs-node1 ~]# systemctl stop firewalld 设置host信息,3台主机都需要执行 [root@glusterfs-node1 ~]# vim /etc/hosts 192.168.61.142 glusterfs-node1 192.168.61.141 glusterfs-node2 192.168.61.128 glusterfs-node3 修改每台主机的主机名分别为: glusterfs-node1 glusterfs-node2 glusterfs-node3 #格式化数据分区,3台主机都需要执行 [root@glusterfs-node1 ~]# mkfs.xfs -i size=512 /dev/sdb1 [root@glusterfs-node1 ~]# mkdir -p /data/brick1 [root@glusterfs-node1 ~]# echo '/dev/sdb1 /data/brick1 xfs defaults 1 2' >> /etc/fstab [root@glusterfs-node1 ~]# mount -a && mount
-
安装与部署
[root@glusterfs-node1 ~]# yum search centos-release-gluster Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.cn99.com * centos-gluster6: mirrors.cn99.com * extras: mirrors.cqu.edu.cn * updates: mirrors.cqu.edu.cn ===================================== N/S matched: centos-release-gluster ====================================== centos-release-gluster-legacy.noarch : Disable unmaintained Gluster repositories from the CentOS Storage SIG centos-release-gluster40.x86_64 : Gluster 4.0 (Short Term Stable) packages from the CentOS Storage SIG : repository centos-release-gluster41.noarch : Gluster 4.1 (Long Term Stable) packages from the CentOS Storage SIG repository centos-release-gluster5.noarch : Gluster 5 packages from the CentOS Storage SIG repository centos-release-gluster6.noarch : Gluster 6 packages from the CentOS Storage SIG repository Name and summary matches only, use "search all" for everything. # 3台服务器上都需要安装 [root@glusterfs-node1 ~]# yum install centos-release-gluster6.noarch [root@glusterfs-node1 ~]# yum install glusterfs-server
-
配置可信池
[root@glusterfs-node1 ~]# gluster peer probe glusterfs-node2 [root@glusterfs-node1 ~]# gluster peer probe glusterfs-node2
-
查看可信池
[root@glusterfs-node1 ~]# gluster peer status Number of Peers: 2 Hostname: glusterfs-node2 Uuid: 8011d12d-ab1c-46d1-b333-2fa2bf03bd83 State: Peer in Cluster (Connected) Hostname: glusterfs-node3 Uuid: f0be6a1b-8d1e-40b9-8716-1864f63e36bd State: Peer in Cluster (Connected)
-
创建GlusterFS卷
# 3台主机都需要执行 [root@glusterfs-node1 ~]# mkdir -p /data/brick1/gv0 # 下面两条命令,随机一台主机执行即可 [root@glusterfs-node1 ~]#gluster volume create gv0 replica 3 glusterfs-node1:/data/brick1/gv0 glusterfs-node2:/data/brick1/gv0 glusterfs-node3:/data/brick1/gv0 [root@glusterfs-node1 ~]# gluster volume start gv0 # 查看glusterfs volume 信息 [root@glusterfs-node1 ~]# gluster volume info Volume Name: gv0 Type: Replicate Volume ID: 3754948c-c4f7-4017-8410-31ae6e304106 Status: Started Snapshot Count: 0 Number of Bricks: 1 x 3 = 3 Transport-type: tcp Bricks: Brick1: glusterfs-node1:/data/brick1/gv0 Brick2: glusterfs-node2:/data/brick1/gv0 Brick3: glusterfs-node3:/data/brick1/gv0 Options Reconfigured: transport.address-family: inet nfs.disable: on performance.client-io-threads: off
验证GlusterFS卷
# 挂载卷到本地
[root@glusterfs-node1 ~]# mount -t glusterfs glusterfs-node1:/gv0 /mnt
[root@glusterfs-node1 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 899M 0 899M 0% /dev
tmpfs 910M 0 910M 0% /dev/shm
tmpfs 910M 9.6M 901M 2% /run
tmpfs 910M 0 910M 0% /sys/fs/cgroup
/dev/mapper/centos-root 39G 3.5G 35G 10% /
/dev/mapper/centos-home 19G 33M 19G 1% /home
/dev/sda1 1014M 193M 822M 19% /boot
tmpfs 182M 0 182M 0% /run/user/0
/dev/sdb1 40G 33M 40G 1% /data/brick1
glusterfs-node1:/gv0 40G 442M 40G 2% /mnt
#向卷中写入数据
[root@glusterfs-node1 ~]# for i in `seq -w 1 100`; do cp -rp /var/log/messages /mnt/copy-test-$i; done
# 查看客户端挂载点
[root@glusterfs-node1 ~]# ls -lA /mnt/copy* | wc -l
100
# 查看每台主机GlusterFS brick挂载点
[root@glusterfs-node1 ~]# ls -lA /data/brick1/gv0/copy*
参考
https://docs.gluster.org/en/latest/Quick-Start-Guide/Quickstart/