GFS集群配置

SAN

存储区域网络(Storage Area Network,简称SAN)采用网状通道(Fibre Channel ,简称FC,区别与Fiber Channel光纤通道)技术,通过FC交换机连接存储阵列和服务器主机,建立专用于数据存储的区域网络。

SAN实际是一种专门为存储建立的独立于TCP/IP网络之外的专用网络。目前一般的SAN提供2Gb/S到4Gb/S的传输数率,同时SAN网络独立于数据网络存在,因此存取速度很快,另外SAN一般采用高端的RAID阵列,使SAN的性能在几种专业存储方案中傲视群雄。

GFS2

是一个基于GFS的先进的集群文件系统,能够同步每台主机的集群文件系统的metadata,能够进行文件锁的管理,并且必须要redhat cluster suite(RHCS)支持,GFS2可以grow,进行容量的调整,不过这是在LVM基础上。
GFS是Redhat公司开发的一款集群文件系统,目前的最新版本是GFS2,GFS文件系统允许多个服务同时读写一个磁盘分区,通过GFS可以实现数据的集中管理,免去了数据同步和拷贝的麻烦,但GFS并不能孤立的存在,安装GFS需要RHCS的底层组件支持

CLVM (Cluster Logical Volume Manager )

Cluster逻辑卷管理,即CLVM,是LVM的扩展,这种扩展允许cluster中的机器使用LVM来管理共享存储

iSCSI

 iSCSI是一种在Internet协议上,特别是以太网上进行数据块传输的标准,它是一种基于IP Storage理论的新型存储技术,RHCS可以通过ISCSI技术来导出和分配共享存储的使用。

CMAN (Cluster Manager,简称CMAN)

是一个分布式集群管理工具,它运行在集群的各个节点上,为RHCS提供集群管理任务。
CMAN用于管理集群成员、消息和通知。它通过监控每个节点的运行状态来了解节点成员之间的关系,当集群中某个节点出现故障,节点成员关系将发生改变,CMAN及时将这种改变通知底层,进而做出相应的调整。
CMAN通过监视集群节点提供一个法定节点数(quorum),当集群 中有多于一半的节点处于活跃状态时,此时符合法定节点数,集群继续可用,当只有有一半或少于一半的节点处于活跃状态是则已达到不到法定节点数,此时整个集 群变得不可用。CMAN通过监控集群中节点来确定各节点的成员关系,当集群中的成员关系发生改变,CMAN会通架构中其它组件来进行相应的调整

rgmanager

RHCS通过rgmanager来管理集群服务,rgmanager运行在每个集群节点上,在服务器上对应的进程为clurgmgrd。

 在一个RHCS集群中,高可用**包含集群服务和集群资源两个方面,集群服务其实就是应用服务,例如apache、mysql等,集群资源有很多种,例如一个IP地址、一个运行脚本、ext3/GFS文件系统等

虽然 GFS2 文件系统既可以作为独立系统部署,也可以作为集群配置的一部分,但在 Red Hat Enterprise Linux 6 发行本中,Red Hat 不支持将 GFS2 作为单节点文件系统使用。

在集群中进行配置时,可使用 High Availability Add-On 配置和管理工具对Red Hat GFS2 节点进行配置和管理。

Red Hat 只支持在 CLVM 逻辑卷中创建的 GFS2 文件系统。CLVM 包含在 Resilient Storage Add-On 中。这是在集群范围内部署 LVM,由在集群中管理 LVM 逻辑卷的 CLVM 守护进程 clvmd 启用。

安装 GFS2

除 Red Hat High Availability Add-On 所需软件包外,还必须为 GFS2 安装 gfs2-utils,为 Clustered Logical Volume Manager(CLVM)安装 lvm2-clusterlvm2-cluster 和 gfs2-utils 软件包是 ResilientStorage 频道的一部分,必须在安装这些软件包前启用该频道。

您可以使用以下 yum install 命令安装 Red Hat High Availability Add-On 软件包:

# yum install rgmanager lvm2-cluster gfs2-utils

GFS 和 GFS2 命令和功能

GFS 命令 GFS2 命令 描述
mount mount 挂载文件系统。系统可以确定文件系统的类型是 GFS 还是 GFS2。有关 GFS2 挂载选项的详情请参考 gfs2_mount(8) man page。
umount umount 卸载文件系统
fsck
gfs_fsck
fsck
fsck.gfs2
检查并修复卸载的文件系统。
gfs_grow gfs2_grow 增大挂载的文件系统。
gfs_jadd gfs2_jadd 在挂载的文件系统中添加日志。
gfs_mkfs
mkfs -t gfs
mkfs.gfs2
mkfs -t gfs2
在存储设备中创建文件系统。
gfs_quota gfs2_quota 在挂载的文件系统中管理配额。从 Red Hat Enterprise Linux 6.1 发行本开始,GFS2 支持标准 Linux 配额工具。有关在 GFS2 中进行配额管理的详情请参考 第 4.5 节 “GFS2 配额管理”
gfs_tool

tunegfs2

挂载参数

dmsetup suspend

配置、调整文件系统或者收集文件系统信息。从 Red Hat Enterprise Linux 6.2 开始支持 tunegfs2 命令。另外还有 gfs2_tool 命令。
gfs_edit gfs2_edit 显示、输出或者编辑文件系统内部结构。gfs2_edit 命令可用于 GFS 文件系统,也可用于 GFS2 文件系统。
gfs_tool setflag jdata/inherit_jdata chattr +j(preferred) 在文件或者目录中启用日志功能。
setfacl/getfacl setfacl/getfacl 为文件或者目录设置或者获得文件访问控制。
setfattr/getfattr setfattr/getfattr 设置或者获得文件的扩展属性。

在CentOS7上部署GFS集群

了解GFS的知识(一定要熟读!)

本文提到的GFS是Redhat的Global File System,不是Google的Google File System。GFS的官方文档链接如下: 
RHEL6版(中文)https://access.redhat.com/documentation/zh-cn/red_hat_enterprise_linux/6/html/global_file_system_2/ 
RHEL7版(英文)https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/global_file_system_2/index

集群各主机hostname和hosts文件设置

在集群的每个主机上,修改hostname文件并确保主机名在集群中独一无二,在hosts文件中列出集群所有主机的hostname和IP地址。示例如下:

[root@a01 ~]# cat /etc/hostname
a01

[root@a01 ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.100.201 a01
192.168.100.202 a02
192.168.100.203 a03
  •  

确保各主机已连接到SAN或IP-SAN

可参考我之前的一篇文章(但不要执行最后一步“在客户机上对ISCSI存储卷进行分区和挂载”,否则会遇到许多意料之外的问题): 
https://blog.csdn.net/huzhenwei/article/details/80690623

安装必要的软件包

yum -y install gfs2-utils  lvm2-cluster
yum install lvm2-sysvinit

配置corosync服务

新建/etc/corosync/corosync.conf文件,内容示例如下:

# Please read the corosync.conf.5 manual page
totem {
        version: 2
        cluster_name: cluster0
        # crypto_cipher and crypto_hash: Used for mutual node authentication.
        # If you choose to enable this, then do remember to create a shared
        # secret with "corosync-keygen".
        # enabling crypto_cipher, requires also enabling of crypto_hash.
        crypto_cipher: none
        crypto_hash: none
        clear_node_high_bit: yes

        # interface: define at least one interface to communicate
        # over. If you define more than one interface stanza, you must
        # also set rrp_mode.
        interface {
                # Rings must be consecutively numbered, starting at 0.
                ringnumber: 0
                # This is normally the *network* address of the
                # interface to bind to. This ensures that you can use
                # identical instances of this configuration file
                # across all your cluster nodes, without having to
                # modify this option.
                bindnetaddr: 192.168.100.0
                # However, if you have multiple physical network
                # interfaces configured for the same subnet, then the
                # network address alone is not sufficient to identify
                # the interface Corosync should bind to. In that case,
                # configure the *host* address of the interface
                # instead:
                # bindnetaddr: 192.168.1.1
                # When selecting a multicast address, consider RFC
                # 2365 (which, among other things, specifies that
                # 239.255.x.x addresses are left to the discretion of
                # the network administrator). Do not reuse multicast
                # addresses across multiple Corosync clusters sharing
                # the same network.
                mcastaddr: 239.255.1.1
                # Corosync uses the port you specify here for UDP
                # messaging, and also the immediately preceding
                # port. Thus if you set this to 5405, Corosync sends
                # messages over UDP ports 5405 and 5404.
                mcastport: 5405
                # Time-to-live for cluster communication packets. The
                # number of hops (routers) that this ring will allow
                # itself to pass. Note that multicast routing must be
                # specifically enabled on most network routers.
                ttl: 1
        }
}

logging {
        # Log the source file and line where messages are being
        # generated. When in doubt, leave off. Potentially useful for
        # debugging.
        fileline: off
        # Log to standard error. When in doubt, set to no. Useful when
        # running in the foreground (when invoking "corosync -f")
        to_stderr: no
        # Log to a log file. When set to "no", the "logfile" option
        # must not be set.
        to_logfile: yes
        logfile: /var/log/cluster/corosync.log
        # Log to the system log daemon. When in doubt, set to yes.
        to_syslog: yes
        # Log debug messages (very verbose). When in doubt, leave off.
        debug: on
        # Log messages with time stamps. When in doubt, set to on
        # (unless you are only logging to syslog, where double
        # timestamps can be annoying).
        timestamp: on
        logger_subsys {
                subsys: QUORUM
                debug: off
        }
}

quorum {
        # Enable and configure quorum subsystem (default: off)
        # see also corosync.conf.5 and votequorum.5
        provider: corosync_votequorum
        expected_votes: 3
        votes: 1
}

注意关键配置项: 
cluster_name: 此项设置的集群名,在之后格式化逻辑卷为gfs2类型时要用到。 
clear_node_high_bit: yes:dlm服务需要,否则无法启动。 
quorum {}模块:集群选举投票设置,必需配置。如果是2节点的集群,可参考如下配置:

quorum {
        # Enable and configure quorum subsystem (default: off)
        # see also corosync.conf.5 and votequorum.5
        provider: corosync_votequorum
        two_node: 1
        expected_votes: 2
        #votes: 1
}

配置lvm

# 开启lvm的集群模式。
# 这个命令会自动修改/etc/lvm/lvm.conf配置文件中的locking_type和use_lvmetad选项的值
[root@a01 ~]# lvmconf --enable-cluster

修改后区别如下:
[root@a01 ~]# diff /etc/lvm/lvm.conf /etc/lvm/lvm.conf.lvmconfold
771c771
<     locking_type = 3
---
>       locking_type = 3
940c940
<     use_lvmetad = 0
---
>       use_lvmetad = 1

启动相关服务

注意先后顺序,先在集群所有主机上启动corosync,集群状态正常之后,在各个主机上启动dlm、clvmd服务。

#在集群所有主机上启动corosync服务
systemctl enable corosync
systemctl start corosync

在corosync服务启动完成后,可以使用corosync-quorumtool -s查看集群的状态,确保状态中的Quorate为Yes。示例如下:

[root@a01 ~]# corosync-quorumtool -s
Quorum information
------------------
Date:             Fri Jun 15 16:56:07 2018
Quorum provider:  corosync_votequorum
Nodes:            3
Node ID:          1084777673
Ring ID:          1084777673/380
Quorate:          Yes

在集群各个主机上启动dlm、clvmd服务

systemctl enable dlm
systemctl start dlm

systemctl enable clvmd
systemctl start clvmd

设置集群卷组等并格式化gfs分区

在集群的一台主机上运行如下命令:

# 查看物理卷信息,如果没有列出存储服务器上的块设备,请确保各主机已连接到SAN或IP-SAN
pvscan
pvs

# 创建卷组、逻辑卷并将逻辑卷格式化为gfs2类型
vgcreate -Ay -cy gfsvg /dev/mapper/mpatha
lvcreate -L 800G -n gfsvol1 gfsvg 
lvs -o +devices gfsvg
# 下面命令中的-j 4参数是指日志区的数量为4,这个数量通常为集群主机数N+1,
# 集群规模扩大时,可以使用gfs2_jadd命令添加日志区。
# -t后的“cluster0”为集群名,确保它与corosync.conf中配置的cluster_name一致。
mkfs.gfs2 -p lock_dlm -t cluster0:gfsvolfs -j 4 /dev/gfsvg/gfsvol1

挂载gfs2逻辑卷

在集群的所有主机上运行如下命令:

# 创建挂载点目录
mkdir /mnt/iscsigfs
# 挂载gfs2分区
# 如果主机提示没有/dev/gfsvg/gfsvol1这个设备,原因是主机在创建此逻辑卷之前启动,将主机重新启动即可。
mount -t gfs2 /dev/gfsvg/gfsvol1 /mnt/iscsigfs -o noatime,nodiratime

设置开机自动挂载,请参考: 
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/storage_administration_guide/iscsi-api

常见错误

  • 运行pvs、vgcreate等lvm相关命令时提示connect()等错误 
    错误示例如下,原因是clvmd没有正常启动 

    connect() failed on local socket: 没有那个文件或目录 
    Internal cluster locking initialisation failed. 
    WARNING: Falling back to local file-based locking. 
    Volume Groups with the clustered attribute will be inaccessible. 
  • 运行pvs、vgcreate等lvm相关命令时提示Skipping clustered volume group XXX或者Device XXX excluded by a filter 
    这通常是做了vgremove等操作后、或块设备上存在旧的卷组信息导致的,可以通过重新格式化块设备的方式解决。命令示例如下: 

    mkfs.xfs /dev/mapper/mpatha 

转自:https://blog.csdn.net/huzhenwei/article/details/80708592

猜你喜欢

转载自blog.csdn.net/ltz150/article/details/80646128
GFS
今日推荐