在AARCH64上的CentOS 7中安装和配置Glusterfs

时间:2020-03-05 15:27:48  来源:igfitidea点击:

本文介绍了在AARCH64上使用Glusterfs安装和配置CentOS 7的过程。
Glusterfs是一个开源和扩展文件系统,它使用Infiband或者TCP组合了多个存储服务器,并制作一个大型网络文件系统。

要求

要配置Glusterfs,我们需要两个或者多个服务器(AARCH64),安装了CentOS 7.

服务器可以是物理或者虚拟的。
我在这里使用两个虚拟服务器并将主机名设置为"GFS1"和"GFS2"。
网络连接应该在两个中都处于活动状态。
每个节点应具有存储设备。
在本文中使用的示例中,使用节点上的具有2 GB的虚拟存储磁盘。

将服务器的IP地址和主机名添加到节点中的/etc/hosts。

45.79.161.123     gfs1
45.79.174.123     gfs2

Glusterfs安装

在继续安装之前,我们需要在服务器上启用EPEL(EXTA Package for Enterprise Linux)和Glusterfs存储库,以便在安装时解析外部依赖项。
如果我们只启用了Glusterfs存储库而不启用EPEL存储库,则可能在安装GlusterFS-Server时,我们可能会在以下错误消息中达到以下错误消息:

Error: Package: glusterfs-server-3.7.0-2.el7.x86_64 (glusterfs-epel)
Requires: liburcu-cds.so.1()(64bit)
Error: Package: glusterfs-server-3.7.0-2.el7.x86_64 (glusterfs-epel)
Requires: liburcu-bp.so.1()(64bit)

在CentOS中启用EPEL Reops因素:使用WGET获取所需文件并使用RPM安装它。

[root@gfs1 ~]# wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
--2014-05-26 10:35:33-- http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
Resolving dl.fedoraproject.org (dl.fedoraproject.org)... 209.132.181.24, 209.132.181.25, 209.132.181.23, ...
Connecting to dl.fedoraproject.org (dl.fedoraproject.org)|209.132.181.24|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 14524 (14K) [application/x-rpm]
Saving to:  epel-release-7-5.noarch.rpm
100%[======================================>] 14,524 --.-K/s in 0.06s
2014-05-26 10:35:33 (239 KB/s) - ˜epel-release-7-5.noarch.rpm saved [14524/14524]
[root@localhost ~]# rpm -ivh epel-release-7-5.noarch.rpm
warning: epel-release-7-5.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
Preparing... ################################# [100%]
Updating/installing...
1:epel-release-7-5 ################################# [100%]

启用Glusterfs存储库:

[root@gfs1 ~]# wget -P /etc/yum.repos.d http://download.gluster.org/pub/gluster/glusterfs/LATEST/EPEL.repo/glusterfs-epel.repo
--2014-05-26 10:37:49-- http://download.gluster.org/pub/gluster/glusterfs/LATEST/EPEL.repo/glusterfs-epel.repo
Resolving download.gluster.org (download.gluster.org)... 50.57.69.89
Connecting to download.gluster.org (download.gluster.org)|50.57.69.89|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1055 (1.0K) [text/plain]
Saving to: /etc/yum.repos.d/glusterfs-epel.repo
100%[======================================>] 1,055 --.-K/s in 0s
2014-05-26 10:37:49 (81.2 MB/s) - /etc/yum.repos.d/glusterfs-epel.repo saved [1055/1055]

按照服务器上的以下步骤操作:在两者上安装Glusterfs:

[root@gfs1 ~]# yum install glusterfs-server

现在,启动Glusterfs守护程序:

root@gfs1 ~]# service glusterd start
Redirecting to /bin/systemctl start glusterd.service

验证服务是否已成功启动:

[root@gfs1 ~]# service glusterd status
Redirecting to /bin/systemctl status glusterd.service
glusterd.service - GlusterFS, a clustered file-system server
Loaded: loaded (/usr/lib/systemd/system/glusterd.service; disabled)
Active: active (running) since Tue 2014-05-26 10:42:08 UTC; 38s ago
Process: 13418 ExecStart=/usr/sbin/glusterd -p /var/run/glusterd.pid (code=exited, status=0/SUCCESS)
Main PID: 13419 (glusterd)
CGroup: /system.slice/glusterd.service
13419 /usr/sbin/glusterd -p /var/run/glusterd.pid
Jan 26 10:42:08 localhost.localdomain systemd[1]: Started GlusterFS, a cluste...
Hint: Some lines were ellipsized, use -l to show in full.

禁用selinux,以防它通过在文件/etc/sysconfig/selinux中更改"selinux = disabled"或者"selinux = permissive"来启用它。
接下来,冲洗iptables。

[root@gfs1 ~]# iptables -F

现在,在两个节点上创建相同的分区。
我正在使用分区/dev/xvdc,在这里使用2GB大小。

fdisk /dev/xvdc

使用"n"创建新分区。
为主分区选择"p",然后按照默认选项。
完成后,选择"W"以将数据保存到磁盘并退出。
在新创建的分区上创建文件系统:

mkfs.ext4 /dev/xvdc1

将其安装在名为/数据/砖的目录上:

[root@gfs1 ~]# mkdir -p /data/brick
[root@gfs1 ~]# mount /dev/xvdc1 /data/brick

将此添加到fstab条目以在重新引导后保留安装。

[root@gfs1 ~]# echo "/dev/xvdc1 /data/brick ext4 defaults 0 0" >> /etc/fstab

现在,我们需要配置可信池。

配置

我们需要从推出卷为卷的推动者服务器创建可信存储池。

在第一台服务器上执行以下命令:

[root@gfs1 ~]# gluster peer probe gfs2
peer probe: success.

在第二个服务器上执行:

[root@gfs2 ~]# gluster peer probe gfs1
peer probe: success.

验证存储池:

[root@gfs1 ~]# gluster pool list
UUID Hostname State
4d1d974d-4c75-424c-a788-7f0e71002e02 gfs2 Connected
473b1bc5-b8c0-4cea-ac86-568a77d0edf0 localhost Connected

设置Glusterfs卷:

为了设置卷,只需执行下面的一个服务器就足够了。
我正在使用第一个服务器(GFS1)。

[root@gfs1 ~]# gluster volume status
No volumes present

在此示例中,我在创建复制卷。
它提供了高可用性和可靠性。
有关不同类型卷的更多详细信息,请参阅Gluster社区页面。

[root@gfs1 ~]# mkdir /data/brick/gvol0
[root@gfs1 ~]# gluster volume create gvol0 replica 2 gfs1:/data/brick/gvol0 gfs2:/data/brick/gvol0
volume create: gvol0: success: please start the volume to access data.

开始新创建的卷

[root@localhost ~]# gluster volume start gvol0
volume start: gvol0: success

验证详细信息:

[root@localhost ~]# gluster volume info
Volume Name: gvol0
Type: Replicate
Volume ID: 4a61822d-75cf-402b-bad4-19ae57626673
Status: Started
Number of Bricks: 1 x 2 = 2
Transport-type: tcp
Bricks:
Brick1: gfs1:/data/brick/gvol0
Brick2: gfs2:/data/brick/gvol0
Options Reconfigured:
performance.readdir-ahead: on

是的,你几乎在那里!我们只需将新创建的卷装入任何挂载点并开始使用它。

[root@gfs1 ~]# mount -t glusterfs gfs1:/gvol0 /mnt
[root@gfs2 ~]# mount -t glusterfs gfs1:/gvol0 /mnt

将一些数据从任何服务器复制到已挂载的卷,并验证是否可以从其他服务器访问它。

[root@gfs1 ~]# cp /var/log/yum.log /mnt
[root@gfs2 mnt]# ls
yum.log