您好,登錄后才能下訂單哦!
這期內(nèi)容當(dāng)中小編將會(huì)給大家?guī)碛嘘P(guān)Centos7中怎么安裝Glusterfs集群,文章內(nèi)容豐富且以專業(yè)的角度為大家分析和敘述,閱讀完這篇文章希望大家可以有所收獲。
如下List-1所示三臺(tái)機(jī)器,hostname分別是node1/node2/node3,之后將List-1的內(nèi)容寫入/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(三臺(tái)都要執(zhí)行)
List-2
#安裝glusterfs yum install centos-release-gluster yum install -y glusterfs glusterfs-server glusterfs-fuse glusterfs-rdma #啟動(dòng)gluster服務(wù) systemctl start glusterd.service systemctl enable glusterd.service #關(guān)閉防火墻 systemctl stop firewalld.service systemctl disable firewalld.service
在node1上執(zhí)行如下List-3,將node2、node3加入集群
List-3
gluster peer probe node2 gluster peer probe node3
在node1上看集群狀態(tài),如下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)
到這里,我們可以直接創(chuàng)建卷來使用,但是我們想將卷掛載到分區(qū)中,所以還需要額外的操作。如下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的,所以我申請(qǐng)2G,每個(gè)節(jié)點(diǎn)都要執(zhí)行
List-8
vgcreate vg_gluster /dev/sdb lvcreate -n lv_gluster -L 2G vg_gluster #格式化 mkfs.ext4 /dev/vg_gluster/lv_gluster
將/data_gluster掛載到我們創(chuàng)建的盤,如下List-9,每個(gè)節(jié)點(diǎn)都要執(zhí)行
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上手動(dòng)創(chuàng)建目錄/data_gluster。
在node1上,用如下List-5命令創(chuàng)建卷,卷名稱是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
注意不一定要選裸磁盤作為存儲(chǔ)數(shù)據(jù)的目錄
比如Linux上有/opt/data目錄,且該目錄有足夠的存儲(chǔ),可以直接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里面寫數(shù)據(jù),不能直接操作/data_gluster,這個(gè)步驟在node1上執(zhí)行。后面不想掛載/mnt/gluster/db時(shí)可以用"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集群了,如果剛好有類似的疑惑,不妨參照上述分析進(jìn)行理解。如果想知道更多相關(guān)知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。