HighAvailability

HighAvailability/resource/NFS

仮想IP

ここでは作ったクラスターの仮想IP(リソース名:VIP)を「192.168.0.102/24」としている.
外から見てクラスターが提供するサービスの宛先IPって感じ

っで設定する.

[root@ha01 ~]# pcs resource create VIP ocf:heartbeat:IPaddr ip=192.168.0.102 cidr_netmask=24 op monitor interval=10s
 
(確認)
[root@ha01 ~]# pcs resource show
 VIP    (ocf::heartbeat:IPaddr):        Started ha01-1-heartbeat
 
[root@ha01 ~]#

「ocf:heartbeat:IPaddr」はリソースの枠組みの一つで、「/lib/ocf/resource.d/」に予め用意されている
コマンド「pcs resource agents ocf:heartbeat」「pcs resource agents ocf:pacemaker」でどのような枠組みがあるかが見れます

実際にipアドレスも付与された. 本体のIPアドレス[192.168.0.100]以外にクラスターの仮想IP[192.168.0.102]が付与されている

[root@ha01 ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
 (略
2: ens32: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:d5:dc:17 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.100/24 brd 192.168.0.255 scope global noprefixroute dynamic ens32
       valid_lft 38759sec preferred_lft 38759sec
    inet 192.168.0.102/24 brd 192.168.0.255 scope global secondary ens32             <---- 追加された仮想IP
       valid_lft forever preferred_lft forever
 (略
3: ens192: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:d5:dc:21 brd ff:ff:ff:ff:ff:ff
    inet 10.10.0.1/24 brd 10.10.0.255 scope global noprefixroute ens192
 (略
[root@ha01 ~]#

次にこのリソース「VIP」をha02側に渡してみる

[root@ha01 ~]# ip addr |grep 192.168.0.102
    inet 192.168.0.102/24 brd 192.168.0.255 scope global secondary ens32
 
[root@ha01 ~]# pcs resource move VIP ha02-1-heartbeat
 
(確認)
[root@ha01 ~]# ip addr |grep 192.168.0.102 | wc -l
0
[root@ha01 ~]#

ha02側でip addrコマンドを実行して 192.168.0.102 が移ったことを確認します

そしてまた元に戻す

[root@ha01 ~]# pcs resource move VIP ha01-1-heartbeat

次に一応手動で片方のマシンをクラスター構成として止めてみる. フェイルオーバーを起こさせてipが移るかのテストになる

[root@ha01 ~]# pcs cluster status
Cluster Status:
 Stack: corosync
 Current DC: ha01-1-heartbeat (version 1.1.21-4.el7-f14e36fd43) - partition with quorum
 Last updated: Mon Jun  1 05:08:02 2020
 Last change: Mon Jun  1 04:51:20 2020 by root via cibadmin on ha01-1-heartbeat
 2 nodes configured
 1 resource configured
 
PCSD Status:
  ha02-1-heartbeat: Online
  ha01-1-heartbeat: Online
 
[root@ha01 ~]# pcs cluster stop ha01-1-heartbeat    <--- これで ha01側を停止
ha01-1-heartbeat: Stopping Cluster (pacemaker)...
ha01-1-heartbeat: Stopping Cluster (corosync)...
 
[root@ha01 ~]# pcs cluster status
Error: cluster is not currently running on this node
 
[root@ha01 ~]# ip addr |grep 192.168.0.102 | wc -l
0
[root@ha01 ~]#

そしてha02側では

[root@ha02 ~]# ip addr |grep 192.168.0.102
    inet 192.168.0.102/24 brd 192.168.0.255 scope global secondary ens32
[root@ha02 ~]#

とipが継承された
戻すにはha01のクラスターを起動させる. すると自動的にVIPが戻るみたい

[root@ha01 ~]# pcs cluster start ha01-1-heartbeat
ha01-1-heartbeat: Starting Cluster (corosync)...
ha01-1-heartbeat: Starting Cluster (pacemaker)...
[root@ha01 ~]# ip addr |grep 192.168.0.102 | wc -l
1
[root@ha01 ~]#
最新の60件
2025-03-23 2025-03-22 2025-03-20 2025-03-17 2025-03-16 2025-03-15 2025-03-10 2025-03-08 2025-03-06 2025-03-03 2025-03-02 2025-03-01 2025-02-23 2025-02-18 2025-02-17 2025-02-14 2025-02-12 2025-02-03 2025-02-02 2025-01-27 2025-01-26 2025-01-25 2025-01-24 2025-01-23 2025-01-20 2025-01-13 2025-01-12 2025-01-08 2024-12-30 2024-12-29 2024-12-22 2024-12-20 2024-12-17 2024-12-15 2024-12-14 2024-12-12 2024-12-11 2024-12-10 2024-12-09 2024-11-28 2024-11-22 2024-11-15 2024-11-14 2024-11-12 2024-11-06 2024-11-05

edit


トップ   編集 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2020-06-05 (金) 01:15:46