CentOS7にGFSクラスターをデプロイする

CentOS7にGFSクラスターをデプロイする

準備オーケー

GFSの知識を理解する(精通している必要があります!)

この記事で言及されているGFSは、GoogleのGoogleファイルシステムではなく、Redhatのグローバルファイルシステムです。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

クラスタ内の各ホストのホスト名とhostsファイルの設定

クラスタ内の各ホストで、ホスト名ファイルを変更し、ホスト名がクラスタ内で一意であることを確認します。クラスタ内のすべてのホストのホスト名とIPアドレスをhostsファイルにリストします。例は次のとおりです。

[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 /詳細/ 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:はい:dlmサービスが必要です。そうでない場合、開始できません。
クォーラム{}モジュール:クラスター選挙の投票設定。構成する必要があります。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を参照して
ください。

よくある間違い

  • clvmdが
    正しく起動しないため、次の例の接続()エラーが発生したときに、pvs、vgcreate、およびその他の関連するlvmコマンドプロンプトを実行します。

    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関連のコマンドを実行すると、フィルターによって除外されたクラスター化ボリュームグループXXXまたはデバイスXXXのスキップを求めるプロンプトが表示されます。
    これは通常、vgremoveなどの操作、またはブロックデバイス上の古いボリュームグループ情報の存在が原因で発生します。再フォーマット可能ブロックデバイスを解決する方法。コマンドの例は次のとおりです。

    mkfs.xfs /dev/mapper/mpatha

おすすめ

転載: blog.csdn.net/huzhenwei/article/details/80708592