Redhat のマニュアルを参考にして、CentOS6.7 に Pacemaker( Corosync )をインストールします。
参考にした Redhat のマニュアルは以下のとおり。
Redhat6 付属の Pacemaker(Corosync)は、CMAN によって管理されるようになっているので、Redhat7 付属の Pacemaker(Corosync) とは設定方法が少し異なります。(CentOSも同じ)
/etc/corosync/corosync.conf は使用せず、/etc/cluster/cluster.conf で管理します。
下記のページが参考になります。
インストールした環境は以下のとおり。
- サーバ1
- OS: CentOS6.7
- IPアドレス: 10.1.0.91
- ホスト名: pm21
- サーバ2
- OS: CentOS6.7
- IPアドレス: 10.1.0.92
- ホスト名: pm22
1.Pacemakerのインストール
CentOS6.7の標準レポジトリから yum でpacemaker、cman、pcs をインストールします。
「サーバ1」と「サーバ2」にインストールします。
# yum install -y pacemaker cman pcspcs はクラスタ管理用のCLIツールです。
pcsを使用したクラスタ操作は、クラスタメンバのサーバであれば、どれか1サーバで実行すれば良いので、ここでは、基本的に「サーバ1」で pcs コマンドを実行するようにしています。
インストールしたら corosync が cman がない場合は起動しないよう「サーバ1」と「サーバ2」で次のコマンドを実行します。
# chkconfig corosync off必ず cman を起動させたいので「サーバ1」と「サーバ2」で次のコマンドを実行します。
# sed -i.sed "s/.*CMAN_QUORUM_TIMEOUT=.*/CMAN_QUORUM_TIMEOUT=0/g" /etc/sysconfig/cman
2.OS設定
「サーバ1」と「サーバ2」でSELinuxとファイヤーウォールが無効になっていることを確認します。
# getenforce Disabled # chkconfig --list | grep tables ip6tables 0:off 1:off 2:off 3:off 4:off 5:off 6:off iptables 0:off 1:off 2:off 3:off 4:off 5:off 6:off # iptables -L -n Chain INPUT (policy ACCEPT) target prot opt source destination Chain FORWARD (policy ACCEPT) target prot opt source destination Chain OUTPUT (policy ACCEPT) target prot opt source destinationクラスタ設定ではホスト名を使用したいので、「サーバ1」と「サーバ2」の /etc/hosts にホスト名を登録します。
10.1.0.91 pm21 10.1.0.92 pm22「サーバ1」と「サーバ2」の双方向で疎通を確認します。
# ping -c1 pm01(または、pm02)pcsでクラスタの設定を行うときに、ssh を使用します。「サーバ1」と「サーバ2」の双方向でsshでログインできることを確認します。下記例では root を使用していますが ユーザは何でもOKです。
# ssh -l root pm01(または、pm02)pcsでコマンドを実行するときに hacluster ユーザを使用しますが、初期状態ではパスワードが設定されていないので、パスワードを設定します。「サーバ1」と「サーバ2」で実施します。
# passwd hacluster ユーザー hacluster のパスワードを変更。 新しいパスワード: よくないパスワード: 辞書の単語に基づいています 新しいパスワードを再入力してください: passwd: 全ての認証トークンが正しく更新できました。
3.クラスタ設定
pcs でクラスタの設定を行います。
まず、「サーバ1」と「サーバ2」で pcsd を起動し、自動起動を有効にします。
# service pcsd start pcsd を起動中: [ OK ] # chkconfig pcsd on「サーバ1」と「サーバ2」の信頼関係を設定します。hacluster ユーザで認証できるようにし、上記2で設定したパスワードを指定します。「サーバ1」だけで実行します。
[root@pm21 ~]# pcs cluster auth pm21 pm22 -u hacluster -p p@ssw0rd pm21: Authorized pm22: Authorizedクラスタ名を "my_cluster20" としてクラスタをセットアップし、「サーバ1」と「サーバ2」でクラスタ・サービスを起動します。
「サーバ1」だけで実行します。
[root@pm21 ~]# pcs cluster setup --start --name my_cluster20 pm21 pm22 pm21: Updated cluster.conf... pm22: Updated cluster.conf... Starting cluster on nodes: pm21, pm22... pm21: Starting Cluster... pm22: Starting Cluster...「サーバ1」と「サーバ2」でクラスタ・サービスが自動起動するように設定します。
[root@pm21 ~]# pcs cluster enable --all pm21: Cluster Enabled pm22: Cluster Enabled「サーバ1」と「サーバ2」に作成された /etc/cluster/cluster.conf の内容は、以下のとおり。
[root@pm21 ~]# cat /etc/cluster/cluster.conf <cluster config_version="9" name="my_cluster20"> <fence_daemon/> <clusternodes> <clusternode name="pm21" nodeid="1"> <fence> <method name="pcmk-method"> <device name="pcmk-redirect" port="pm21"/> </method> </fence> </clusternode> <clusternode name="pm22" nodeid="2"> <fence> <method name="pcmk-method"> <device name="pcmk-redirect" port="pm22"/> </method> </fence> </clusternode> </clusternodes> <cman broadcast="no" expected_votes="1" transport="udp" two_node="1"/> <fencedevices> <fencedevice agent="fence_pcmk" name="pcmk-redirect"/> </fencedevices> <rm> <failoverdomains/> <resources/> </rm> </cluster>この設定だとPacemakerのログは /var/log/messages に出力されます。
/var/log/messagesに出さないようにsyslogを無効にし、AWS用に udpユニキャストに変更したい場合は以下のようにします。
[root@pm21 cluster]# cat /etc/cluster/cluster.conf <cluster config_version="9" name="my_cluster20"> <fence_daemon/> <clusternodes> <clusternode name="pm21" nodeid="1"> <fence> <method name="pcmk-method"> <device name="pcmk-redirect" port="pm21"/> </method> </fence> </clusternode> <clusternode name="pm22" nodeid="2"> <fence> <method name="pcmk-method"> <device name="pcmk-redirect" port="pm22"/> </method> </fence> </clusternode> </clusternodes> <cman broadcast="no" expected_votes="1" transport="udpu" two_node="1"/> <fencedevices> <fencedevice agent="fence_pcmk" name="pcmk-redirect"/> </fencedevices> <rm> <failoverdomains/> <resources/> </rm> <logging to_syslog="no" to_logfile="yes" logfile_priority="info" debug="off"/> </cluster>変更後は、クラスタサービスを再起動します。
[root@pm21 cluster]# pcs cluster stop --all pm22: Stopping Cluster (pacemaker)... pm21: Stopping Cluster (pacemaker)... pm22: Stopping Cluster (cman)... pm21: Stopping Cluster (cman)... [root@pm21 cluster]# pcs cluster start --all pm22: Starting Cluster... pm21: Starting Cluster...
4.クラスタ起動と状態確認
クラスタサービスのプロセスは以下のとおり
[root@pm21 cluster]# ps -ef UID PID PPID C STIME TTY TIME CMD ~ 省略 ~ root 2085 1 0 21:03 ? 00:00:00 corosync -f root 2149 1 0 21:03 ? 00:00:00 fenced root 2164 1 0 21:03 ? 00:00:00 dlm_controld root 2226 1 0 21:03 ? 00:00:00 gfs_controld root 2361 1 0 21:03 ? 00:00:00 pacemakerd 189 2367 2361 0 21:03 ? 00:00:00 /usr/libexec/pacemaker/cib root 2368 2361 0 21:03 ? 00:00:00 /usr/libexec/pacemaker/stonithd root 2369 2361 0 21:03 ? 00:00:00 /usr/libexec/pacemaker/lrmd 189 2370 2361 0 21:03 ? 00:00:00 /usr/libexec/pacemaker/attrd 189 2371 2361 0 21:03 ? 00:00:00 /usr/libexec/pacemaker/pengine root 2372 2361 0 21:03 ? 00:00:00 /usr/libexec/pacemaker/crmdクラスタの状態を確認します。「サーバ1」で実行します。
[root@pm21 cluster]# pcs status cluster Cluster Status: Last updated: Sat Mar 5 23:04:44 2016 Last change: Sat Mar 5 21:31:24 2016 Stack: cman Current DC: pm21 - partition with quorum Version: 1.1.11-97629de 2 Nodes configured 0 Resources configuredクラスタメンバ(ノード)の状態を確認します。「サーバ1」で実行します。
[root@pm21 cluster]# pcs status nodes Pacemaker Nodes: Online: pm21 pm22 Standby: Offline: [root@pm21 cluster]# pcs status corosync Nodeid Name 1 pm21 2 pm22クラスタ、ノード、リソース、デーモンの状態を確認します。「サーバ1」で実行します。
[root@pm21 cluster]# pcs status Cluster name: my_cluster20 WARNING: no stonith devices and stonith-enabled is not false Last updated: Sat Mar 5 23:05:23 2016 Last change: Sat Mar 5 21:31:24 2016 Stack: cman Current DC: pm21 - partition with quorum Version: 1.1.11-97629de 2 Nodes configured 0 Resources configured Online: [ pm21 pm22 ] Full list of resources:
5.クラスタ設定のチェック
クラスタ設定をチェックします。「サーバ1」で実行します。
[root@pm21 cluster]# crm_verify -L -V error: unpack_resources: Resource start-up disabled since no STONITH resources have been defined error: unpack_resources: Either configure some or disable STONITH with the stonith-enabled option error: unpack_resources: NOTE: Clusters with shared data need STONITH to ensure data integrity Errors found during check: config not validSTONITHの設定をしていないのでエラーになっています。STONITHは、Pacemakerがスプリットブレインを検知したときに強制的にH/Wを電源OFF/ONする機能だそうです。STONISHについては、以下のページが詳しいです。
STONISH はデフォルトで有効になっていますが、検証用の仮想化環境では使用しないので無効にします。
[root@pm21 cluster]# pcs property set stonith-enabled=falseエラーにはなっていませんが、クォーラムの設定も変更します。クォーラムについては、以下が詳しいです。
今回は2台構成なので、スプリットブレインが発生しても quorum が特別な動作を行わないように無効にします。
[root@pm21 cluster]# pcs property set no-quorum-policy=ignoreパラメータを確認します。
[root@pm21 cluster]# pcs property Cluster Properties: cluster-infrastructure: cman dc-version: 1.1.11-97629de no-quorum-policy: ignore stonith-enabled: falseクラスタの再起動は不要です。変更は即時反映されます。
6.クラスタ操作
pcsコマンドでクラスタを操作してみます。ここでは、「サーバ1」でpcsコマンドを実行します。
クラスタを停止する場合は、以下のようにします。
[root@pm21 cluster]# pcs cluster stop --all pm22: Stopping Cluster (pacemaker)... pm21: Stopping Cluster (pacemaker)... pm22: Stopping Cluster (cman)... pm21: Stopping Cluster (cman)...クラスタを再起動したい場合は、stop してから start します。
[root@pm21 cluster]# pcs cluster stop --all && pcs cluster start --all「サーバ1」 をスタンバイにして、状態を確認してみます。
[root@pm21 cluster]# pcs cluster standby pm21 [root@pm21 cluster]# pcs status nodes Pacemaker Nodes: Online: pm22 Standby: pm21 Offline:「サーバ1」 をオンラインに戻します。
[root@pm21 cluster]# pcs cluster unstandby pm21 [root@pm21 cluster]# pcs status nodes Pacemaker Nodes: Online: pm21 pm22 Standby: Offline:「サーバ2」 だけ停止します。
[root@pm21 cluster]# pcs cluster stop pm22 pm22: Stopping Cluster (pacemaker)... pm22: Stopping Cluster (cman)... [root@pm21 cluster]# pcs status nodes Pacemaker Nodes: Online: pm21 Standby: Offline: pm22