LoginSignup
2
3

More than 5 years have passed since last update.

pacemaker_remoteについて(その3) KVM環境

Last updated at Posted at 2015-11-02

最後にKVM環境(KVM )でpacemaker_remoteを使ってみます。

KVM(VirtualDomain)でのクラスタ構成

ゲスト(VirtualDomain)で起動したpacemaker_remoteと通信を行って、Pacemakerを起動するノードからの指示に従ってゲスト内でリソースを起動する構成です。
pacemakerホスト1台(sl7-01)とあらかじめpacemakerリモートをインストールしているゲスト(remote1,remote2)で構成してみます。
リソースは簡易にDummyのみとしています。
以下はstonith無の例ですが、実際にはstonith構成を組むことをお勧めします。
また、pacemakerホストでは、リソースを起動しないことがわかっている為、discovery設定も行っています。
配置先はlocationで設定しています。

primitive dummy-remote Dummy \
        op start interval=0s timeout=60s on-fail="restart"  \
        op monitor interval=5s timeout=60s on-fail="restart" \
        op stop interval=0s timeout=60s on-fail="block"

primitive guest1 VirtualDomain \
        meta remote-node=remote1 \
        params hypervisor="qemu:///system" config="/tmp/remote1.xml" \
        op start interval=0s timeout=90s \
        op monitor interval=10s timeout=60s \
        op stop interval=0s timeout=90s

primitive guest2 VirtualDomain \
        meta remote-node=remote2 \
        params hypervisor="qemu:///system" config="/tmp/remote2.xml" \
        op start interval=0s timeout=90s \
        op monitor interval=10s timeout=60s \
        op stop interval=0s timeout=90s

location loc1 dummy-remote \
        rule 300: #uname eq remote1 \
        rule 200: #uname eq remote2

location loc2 dummy-remote resource-discovery="never" \
        rule -inf: #uname eq sl7-01

order rsc-order-1 0: guest1 dummy-remote
order rsc-order-2 0: guest2 dummy-remote

rsc_defaults resource-stickiness="INFINITY" \
  migration-threshold="1"

property cib-bootstrap-options: \
        stonith-enabled=false \
        no-quorum-policy=ignore

動作について

pacemaker_remoteは、Pacemakerからの接続ホストの形で動作し、Pacemakerから接続を行います。
KVM環境ではpacemaker_remote側と通信しています。

1) Pacemakerを起動して、CLIファイルを投入します。WARNINGが出ますが、問題はありません。

[root@sl7-01 ~]# crm configure load update test-remote-virtual-non-stonith.crm 
WARNING: loc1: referenced node remote1 does not exist
WARNING: loc1: referenced node remote2 does not exist

2) crm_monコマンドで確認します。

[root@sl7-01 ~]# crm_mon -1 -Af
Last updated: Mon Nov  2 09:40:31 2015          Last change: Mon Nov  2 09:39:40 2015 by hacluster via crmd on sl7-01
Stack: corosync
Current DC: sl7-01 (version 1.1.13-4e6f6d6) - partition WITHOUT quorum
3 nodes and 5 resources configured

Online: [ sl7-01 ]
GuestOnline: [ remote1@sl7-01 remote2@sl7-01 ]

 dummy-remote   (ocf::heartbeat:Dummy): Started remote1
 guest1 (ocf::heartbeat:VirtualDomain): Started sl7-01
 guest2 (ocf::heartbeat:VirtualDomain): Started sl7-01

Node Attributes:
* Node remote1@sl7-01:
* Node remote2@sl7-01:
* Node sl7-01:

Migration Summary:
* Node sl7-01:
* Node remote2@sl7-01:
* Node remote1@sl7-01:

3) 念の為、virshコマンドでゲストを確認しておきます。

[root@sl7-01 ~]# virsh list
 Id    名前                         状態
----------------------------------------------------
 7     remote2                        実行中
 9     remote1                        実行中

4) remote1で稼働しているリソースをremote2に移動します。

crm_resource -M -r dummy-remote -H remote-node2 -f


[root@cent7-host ~]# crm_mon -1 -Af
Last updated: Wed Oct 28 18:00:56 2015          Last change: Wed Oct 28 18:00:54 2015 by root via crm_resource on cent7-host
Stack: corosync
Current DC: cent7-host (version 1.1.13-4e6f6d6) - partition WITHOUT quorum
3 nodes and 5 resources configured

Online: [ cent7-host ]
GuestOnline: [ remote-node1@cent7-host remote-node2@cent7-host ]

 container1     (ocf::heartbeat:docker):        Started cent7-host
 container2     (ocf::heartbeat:docker):        Started cent7-host
 dummy-remote   (ocf::heartbeat:Dummy): Started remote-node2

Node Attributes:
* Node cent7-host:
* Node remote-node1@cent7-host:
* Node remote-node2@cent7-host:

Migration Summary:
* Node cent7-host:
* Node remote-node2@cent7-host:
* Node remote-node1@cent7-host:
crm_resource -M -r dummy-remote -H remote-node2 -f


[root@cent7-host ~]# crm_mon -1 -Af
Last updated: Wed Oct 28 18:00:56 2015          Last change: Wed Oct 28 18:00:54 2015 by root via crm_resource on cent7-host
Stack: corosync
Current DC: cent7-host (version 1.1.13-4e6f6d6) - partition WITHOUT quorum
3 nodes and 5 resources configured

Online: [ cent7-host ]
GuestOnline: [ remote-node1@cent7-host remote-node2@cent7-host ]

 container1     (ocf::heartbeat:docker):        Started cent7-host
 container2     (ocf::heartbeat:docker):        Started cent7-host
 dummy-remote   (ocf::heartbeat:Dummy): Started remote-node2

Node Attributes:
* Node cent7-host:
* Node remote-node1@cent7-host:
* Node remote-node2@cent7-host:

Migration Summary:
* Node cent7-host:
* Node remote-node2@cent7-host:
* Node remote-node1@cent7-host:


[root@sl7-01 ~]# crm_resource -U -r dummy-remote

5) remote2でリソースのモニターエラーを起こしてみます。migration-threshold="1"なので、リソースがremote1にフェイルオーバーします。

[root@sl7-01 ~]# ssh 192.168.40.180
root@192.168.40.180's password: 
Last login: Mon Nov  2 09:43:30 2015 from 192.168.40.1
[root@remote2 ~]# rm -rf /var/run/resource-agents/Dummy-dummy-remote.state 
[root@remote2 ~]# 

[root@sl7-01 ~]# crm_mon -1 -Af
Last updated: Mon Nov  2 09:44:24 2015          Last change: Mon Nov  2 09:42:34 2015 by root via crm_resource on sl7-01
Stack: corosync
Current DC: sl7-01 (version 1.1.13-4e6f6d6) - partition WITHOUT quorum
3 nodes and 5 resources configured

Online: [ sl7-01 ]
GuestOnline: [ remote1@sl7-01 remote2@sl7-01 ]

 dummy-remote   (ocf::heartbeat:Dummy): Started remote1
 guest1 (ocf::heartbeat:VirtualDomain): Started sl7-01
 guest2 (ocf::heartbeat:VirtualDomain): Started sl7-01

Node Attributes:
* Node remote1@sl7-01:
* Node remote2@sl7-01:
* Node sl7-01:

Migration Summary:
* Node sl7-01:
* Node remote2@sl7-01:
   dummy-remote: migration-threshold=1 fail-count=1 last-failure='Mon Nov  2 09:44:06 2015'
* Node remote1@sl7-01:

Failed Actions:
* dummy-remote_monitor_5000 on remote2 'not running' (7): call=16, status=complete, exitreason='No process state file found',
    last-rc-change='Mon Nov  2 09:44:06 2015', queued=0ms, exec=0ms

6) 停止します

[root@sl7-01 ~]# systemctl stop pacemaker
[root@sl7-01 ~]# virsh list
 Id    名前                         状態
----------------------------------------------------

[root@sl7-01 ~]# 
2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3