您好,登录后才能下订单哦!
这期内容当中小编将会给大家带来有关Centos7中怎么安装Glusterfs集群,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。
如下List-1所示三台机器,hostname分别是node1/node2/node3,之后将List-1的内容写入/etc/hosts
List-1
192.168.33.20 node1 192.168.33.21 node2 192.168.33.22 node3
加入glusterfs的源
wget -P /etc/yum.repos.d https://download.gluster.org/pub/gluster/glusterfs/LATEST/RHEL/glusterfs-rhel8.repo
yum makecache
安装glusterfs(三台都要执行)
List-2
#安装glusterfs yum install centos-release-gluster yum install -y glusterfs glusterfs-server glusterfs-fuse glusterfs-rdma #启动gluster服务 systemctl start glusterd.service systemctl enable glusterd.service #关闭防火墙 systemctl stop firewalld.service systemctl disable firewalld.service
在node1上执行如下List-3,将node2、node3加入集群
List-3
gluster peer probe node2 gluster peer probe node3
在node1上看集群状态,如下List-4
List-4
[root@node1 db]# gluster peer status Number of Peers: 2 Hostname: node2 Uuid: ab8dac2f-e5fb-4752-b70d-b0103a40f8ea State: Peer in Cluster (Connected) Hostname: node3 Uuid: f13b4732-ae12-4b6c-b4eb-65fd7886588c State: Peer in Cluster (Connected)
到这里,我们可以直接创建卷来使用,但是我们想将卷挂载到分区中,所以还需要额外的操作。如下List-7,卷/dev/sdb是我新增的裸磁盘——virtualbox上通过UI新增的。
List-7
[root@node1 db]# fdisk -l Disk /dev/sda: 10.5 GB, 10485760000 bytes, 20480000 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x000927b6 Device Boot Start End Blocks Id System /dev/sda1 * 2048 1026047 512000 83 Linux /dev/sda2 1026048 20479999 9726976 8e Linux LVM Disk /dev/sdb: 3221 MB, 3221225472 bytes, 6291456 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes ...
如下List-8,由于/dev/sdb是3G的,所以我申请2G,每个节点都要执行
List-8
vgcreate vg_gluster /dev/sdb lvcreate -n lv_gluster -L 2G vg_gluster #格式化 mkfs.ext4 /dev/vg_gluster/lv_gluster
将/data_gluster挂载到我们创建的盘,如下List-9,每个节点都要执行
List-9
echo "/dev/vg_gluster/lv_gluster /data_gluster ext4 defaults 0 0" >> /etc/fstab mount -a mount -l | grep gluster
之后在node1/node2/node3上手动创建目录/data_gluster。
在node1上,用如下List-5命令创建卷,卷名称是db_volume
List-5
gluster volume create db_volume \ replica 3 node1:/data_gluster/db node2:/data_gluster/db node3:/data_gluster/db force
激活卷,如下List-6
注意不一定要选裸磁盘作为存储数据的目录
比如Linux上有/opt/data目录,且该目录有足够的存储,可以直接gluster volume create db_volume
replica 3 node1:/opt/data/db node2:/opt/data/db node3:/opt/data/db force
List-6
gluster start db_volume #高版本中使用下面的命令 gluster volume start db_volume
到这里,我们虽然激活了卷,但是还不能直接使用,要将其挂载出来,如下List-10,将卷db_volume挂载到/mnt/gluster/db目录下,我们只能往/mnt/gluster/db里面写数据,不能直接操作/data_gluster,这个步骤在node1上执行。后面不想挂载/mnt/gluster/db时可以用"umount -l /mnt/gluster/db"
List-10
mkdir -p /mnt/gluster/db mount -t glusterfs node1:/db_volume /mnt/gluster/db
查看glusterfs安装的版本
List-11
[root@node1 vagrant]# glusterfs --version glusterfs 6.6 Repository revision: git://git.gluster.org/glusterfs.git Copyright (c) 2006-2016 Red Hat, Inc. <https://www.gluster.org/> GlusterFS comes with ABSOLUTELY NO WARRANTY. It is licensed to you under your choice of the GNU Lesser General Public License, version 3 or any later version (LGPLv3 or later), or the GNU General Public License, version 2 (GPLv2), in all cases as published by the Free Software Foundation.
查看glusterfs的pool情况
List-12
[root@master k8s]# gluster pool list UUID Hostname State f1ae2684-7055-41d4-9269-669c0539b236 node1 Connected 2bf45852-d873-4910-ba20-9f8c8e68a8f6 node2 Connected bb551fbf-7dff-4c9e-9295-1d0138b84ed8 localhost Connected
上述就是小编为大家分享的Centos7中怎么安装Glusterfs集群了,如果刚好有类似的疑惑,不妨参照上述分析进行理解。如果想知道更多相关知识,欢迎关注亿速云行业资讯频道。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。