您好,登錄后才能下訂單哦!
這期內容當中小編將會給大家帶來有關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進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。