1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

fence_virshを使ってみる

Last updated at Posted at 2016-04-05

経緯

Pacemakerで利用可能なlibvirtのゲスト用のSTONITHにはglueに含まれるexternal/libvirtがありますが、今後は、fence_agentに含まれるfence_virshが主流となると思われる為、確認してみました。

環境

KVMホスト(SL7.0:アドレスxxx.xxx.xx.x)とKVMゲスト(CentOS7:ct72-01,ct72-02)。
それぞれのゲストにはPacemaker1.1系をインストールして、クラスタを構成可能なようにしておきます。
(fence_agentのインストールもお忘れなく...)

CLIファイルでの設定例

PacemakerでCLIファイルとして設定する場合には以下のような設定例になります。
pcmk_host_listで対象となるゲストを指定してipaddrで接続先KVMホスト(xxx.xxx.xx.x)を指定します。
また、今回は、KVMホストへの接続ユーザとパスワードをlogin/passwdパラメータで指定します。

property no-quorum-policy="ignore" \
        stonith-enabled="true" \
        startup-fencing="false"
(snip)

primitive prmStonith_libvirt01 stonith:fence_virsh \
        params pcmk_host_list="ct72-01 ct72-02" action=reboot ipaddr=xxx.xxx.xx.x login=XXXX passwd=XXXX \
        op start interval="0s" timeout="60s" on-fail="restart" \
        op monitor interval=60s \
        op stop interval="0s" timeout="60s" on-fail="ignore"
(snip)

単一動作の確認

fence_virshを直接実行して動作を確認することが出来ます。

## ゲストリストの取得
[root@ct72-01 ~]# fence_virsh -o list   -a "xxx.xxx.xx.x" -l "xxx" -p "xxx" 
ct72-01,
ct72-02,
(snip)

## ゲスト状態の取得
[root@ct72-01 ~]# fence_virsh -o status  -a "xxx.xxx.xx.x" -l "xxx" -p "xxx" -n ct72-02
Status: ON

## reboot(フェンシング)の実行
[root@ct72-01 ~]# fence_virsh -o reboot  -a "xxx.xxx.xx.x" -l "xxx" -p "xxx" -n ct72-02
Success: Rebooted

ゲストをUUID指定する場合

ゲストをuuid指定する場合は、fence_virshのコマンドラインでは、-nでuuidを指定するだけです。

[root@ct72-01]#  fence_virsh -o reboot  --a "xxx.xxx.xx.x" -l "xxx" -p "xxx" -n a63f823f-1f40-4da2-a0d9-2b3ede88de5d
Success: Rebooted

あらかじめ、KVMホスト側で対象ゲストのUUIDを確認しておいて指定してください。

[root@kvm-host ~]# virsh domuuid ct72-02
a63f823f-1f40-4da2-a0d9-2b3ede88de5d

CLIファイルで指定する場合は、pcmk_host_listではなく、pcmk_host_mapパラメータを利用して、"ゲスト名1:uuid;ゲスト名2:uuid"のように指定します。
以下に例を示します。

primitive prmStonith_libvirt01 stonith:fence_virsh \
        params pcmk_host_map="ct72-01:02c7772d-ed60-451f-b4dd-75dee575a170;ct72-02:a63f823f-1f40-4da2-a0d9-2b3ede88de5d" action=reboot ipaddr=192.168.40.1 login=root passwd=nttdata \
        op start interval="0s" timeout="60s" on-fail="restart" \
        op monitor interval=60s \
        op stop interval="0s" timeout="60s" on-fail="ignore"

以上です。

1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?