Pacemaker : クラスターリソースを設定する (Apache2)2024/07/23 |
|
クラスターリソースに Apache httpd を設定して、アクティブ/パッシブ 構成の Web サーバーを構築します。
当例では以下のような環境で設定します。事前に下記の項目を設定済みであることが前提です。
+--------------------+
| [ ISCSI Target ] |
| dlp.srv.world |
+----------+---------+
10.0.0.30|
|
+----------------------+ | +----------------------+
| [ Cluster Node#1 ] |10.0.0.51 | 10.0.0.52| [ Cluster Node#2 ] |
| node01.srv.world +----------+----------+ node02.srv.world |
| Apache httpd | | | Apache httpd |
+----------------------+ | +----------------------+
vip:10.0.0.60
|
+----------+---------+
| [ Clients ] |
| |
+--------------------+
|
| [1] | クラスターを構成する全ノードで、Apache2 をインストールしておきます。 |
|
root@node01:~#
apt -y install apache2
root@node01:~#
vi /etc/apache2/conf-available/server-status.conf # 新規作成 (サーバーステータスを有効化)
<Location /server-status>
SetHandler server-status
Require local
</Location>
a2enconf server-status
|
| [2] | LVM 共有ストレージがアクティブとなっているノード上で、httpd に必要なファイルをコピーして、動作確認用のテストページを作成しておきます。 以下で Filesystem に設定しているデバイス [/dev/vg_ha/lv_ha] は事前に作成した LVM 共有ストレージです。 |
|
root@node01:~# mount /dev/vg_ha/lv_ha /mnt root@node01:~# cp -pR /var/www/* /mnt/ root@node01:~# echo "High Availability Test Page" > /mnt/html/index.html root@node01:~# umount /mnt |
| [3] | LVM 共有ストレージがアクティブとなっているノード上で、httpd リソースを追加します。 以下で Filesystem に設定しているデバイス [/dev/vg_ha/lv_ha] は事前に作成した LVM 共有ストレージです。 |
|
root@node01:~# pcs status
Cluster name: ha_cluster
Cluster Summary:
* Stack: corosync (Pacemaker is running)
* Current DC: node01.srv.world (version 2.1.6-6fdc9deea29) - partition with quorum
* Last updated: Tue Jul 23 04:19:20 2024 on node01.srv.world
* Last change: Tue Jul 23 04:15:34 2024 by root via cibadmin on node01.srv.world
* 2 nodes configured
* 2 resource instances configured
Node List:
* Online: [ node01.srv.world node02.srv.world ]
Full List of Resources:
* scsi-shooter (stonith:fence_scsi): Started node01.srv.world
* Resource Group: ha_group:
* lvm_ha (ocf:heartbeat:LVM-activate): Started node01.srv.world
Daemon Status:
corosync: active/enabled
pacemaker: active/enabled
pcsd: active/enabled
# ファイルシステムリソース作成 root@node01:~# pcs resource create httpd_fs ocf:heartbeat:Filesystem device=/dev/vg_ha/lv_ha directory=/var/www fstype=ext4 group ha_group --future
# 仮想 IP アドレスリソース作成 root@node01:~# pcs resource create httpd_vip ocf:heartbeat:IPaddr2 ip=10.0.0.60 cidr_netmask=24 group ha_group --future
# Apache リソース作成 root@node01:~# pcs resource create website ocf:heartbeat:apache configfile=/etc/apache2/apache2.conf statusurl=http://127.0.0.1/server-status group ha_group --future
pcs status
Cluster name: ha_cluster
Cluster Summary:
* Stack: corosync (Pacemaker is running)
* Current DC: node01.srv.world (version 2.1.6-6fdc9deea29) - partition with quorum
* Last updated: Tue Jul 23 04:21:57 2024 on node01.srv.world
* Last change: Tue Jul 23 04:21:51 2024 by root via cibadmin on node01.srv.world
* 2 nodes configured
* 5 resource instances configured
Node List:
* Online: [ node01.srv.world node02.srv.world ]
Full List of Resources:
* scsi-shooter (stonith:fence_scsi): Started node01.srv.world
* Resource Group: ha_group:
* lvm_ha (ocf:heartbeat:LVM-activate): Started node01.srv.world
* httpd_fs (ocf:heartbeat:Filesystem): Started node01.srv.world
* httpd_vip (ocf:heartbeat:IPaddr2): Started node01.srv.world
* website (ocf:heartbeat:apache): Started node01.srv.world
Daemon Status:
corosync: active/enabled
pacemaker: active/enabled
pcsd: active/enabled
# 設定した 仮想 IP アドレス宛てに HTTP アクセスして動作確認 root@node01:~# curl http://10.0.0.60/index.html High Availability Test Page |
| Sponsored Link |
|
|