VMware アフィニティルールの設定

スポンサーリンク

VMware ESXiには仮想マシンを同一筐体で動かすか否かのアフィニティルールと呼ばる設定があります。例えば、WebサーバとAPサーバを同一筐体に配置してレイテンシを下げたい時は同一筐体に配置するアフィニティルールを定義し、別筐体に配置して可用性を高めたい時は非アフィニティルールを定義します。このページではアフィニティルールの操作方法をまとめます。

アフィニティルールと非アフィニティルール

設定の概要

以下のようなルールを投入します。

仮想マシン ルール
centos50, centos51, centos52 別筐体
centos60, centos61 別筐体
centos70, centos71 別筐体

ルール投入前の仮想マシンの配置は以下の通りです。

仮想マシンの初期配置

非アフィニティルール(別筐体)

vCenterの管理画面にて、「対象クラスタ」「仮想マシン/ホスト ルール」「追加」の順に押下します。

非アフィニティルールの設定 01

ルール名を入力し、タイプは「仮想マシンを個別に保存」を選びます。その後、「追加」を押下します。

非アフィニティルールの設定 02

別筐体に配置する仮想マシンにチェックを入れ、「OK」を押下します。

非アフィニティルールの設定 03

「OK」を押下します。

非アフィニティルールの設定 04

ルール「rule01」が作成された事を確認します。また、しばらく待つとルールに従ったvMotionが自動的に実行された旨のログが出力されます。

非アフィニティルールの設定 05

アフィニティルール(同一筐体)

vCenterの管理画面にて、「対象クラスタ」「仮想マシン/ホスト ルール」「追加」の順に押下します。

アフィニティルールの設定 01

ルール名を入力し、タイプは「仮想マシンを一緒に保存」を選びます。その後、「追加」を押下します。

アフィニティルールの設定 02

別筐体に配置する仮想マシンにチェックを入れ、「OK」を押下します。

アフィニティルールの設定 03

「OK」を押下します。

アフィニティルールの設定 04

ルール「rule02」が作成された事を確認します。また、しばらく待つとルールに従ったvMotionが自動的に実行された旨のログが出力されます。

アフィニティルールの設定 05

同様の手順を繰り返し、centos70, centos71を同一筐体に配置されるように設定します。

アフィニティルールの設定 06

設定後の配置確認

アフィニティルール設定後の仮想マシンの配置を確認します。centos50, centos51, centos52は別筐体に配置され、centos60, centos61とcentos70, centos71は同一筐体に配置されています。

[root@esxi142:~] vim-cmd vmsvc/getallvms
Vmid     Name                  File                     Guest OS         Version                                                                                                                                                                                                                                        Annotation                                                                                                                                                                                                                                      
11     centos60   [nfs141] centos60/centos60.vmx   centos8_64Guest       vmx-14                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
13     centos50   [nfs141] centos50/centos50.vmx   centos8_64Guest       vmx-14                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
15     centos61   [nfs141] centos61/centos61.vmx   centos8_64Guest       vmx-14                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
16     centos71   [nfs141] centos72/centos72.vmx   centos8_64Guest       vmx-14                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
3      vCLS (1)   [nfs141] vCLS (1)/vCLS (1).vmx   other3xLinux64Guest   vmx-11    vSphere Cluster Service VM is deployed from an OVA with a minimal installed profile of PhotonOS. vSphere Cluster Service manages the resources, power state and availability of these VMs. vSphere Cluster Service VMs are required for maintaining the health and availability of vSphere Cluster Service. Any impact on the power state or resources of these VMs might degrade the health of the vSphere Cluster Service and cause vSphere DRS to cease operation for the cluster.
7      centos70   [nfs141] centos70/centos70.vmx   centos8_64Guest       vmx-14                                                                                                                                                                                                                                                                                                                                                         


[root@esxi143:~] vim-cmd vmsvc/getallvms
Vmid     Name                  File                     Guest OS         Version                                                                                                                                                                                                                                        Annotation                                                                                                                                                                                                                                      
1      vCLS (2)   [nfs141] vCLS (2)/vCLS (2).vmx   other3xLinux64Guest   vmx-11    vSphere Cluster Service VM is deployed from an OVA with a minimal installed profile of PhotonOS. vSphere Cluster Service manages the resources, power state and availability of these VMs. vSphere Cluster Service VMs are required for maintaining the health and availability of vSphere Cluster Service. Any impact on the power state or resources of these VMs might degrade the health of the vSphere Cluster Service and cause vSphere DRS to cease operation for the cluster.
6      centos51   [nfs141] centos51/centos51.vmx   centos8_64Guest       vmx-14                                                                                                                                                                                                             


[root@esxi144:~] vim-cmd vmsvc/getallvms
Vmid     Name                  File                     Guest OS         Version                                                                                                                                                                                                                                        Annotation                                                                                                                                                                                                                                      
1      vCLS (3)   [nfs141] vCLS (3)/vCLS (3).vmx   other3xLinux64Guest   vmx-11    vSphere Cluster Service VM is deployed from an OVA with a minimal installed profile of PhotonOS. vSphere Cluster Service manages the resources, power state and availability of these VMs. vSphere Cluster Service VMs are required for maintaining the health and availability of vSphere Cluster Service. Any impact on the power state or resources of these VMs might degrade the health of the vSphere Cluster Service and cause vSphere DRS to cease operation for the cluster.
6      centos52   [nfs141] centos52/centos52.vmx   centos8_64Guest       vmx-14 

障害発生時の挙動

ESXiホスト192.168.1.142を再起動させます。

[root@esxi142:~] reboot
[root@esxi142:~] 

再起動直後の仮想マシンの配置は以下の通りです。着目すべきは、centos50, centos51, centos52は別筐体というルールがあるので、centos50が停止状態になっている事です。

[root@esxi143:~] vim-cmd vmsvc/getallvms
Vmid     Name                  File                     Guest OS         Version                                                                                                                                                                                                                                        Annotation                                                                                                                                                                                                                                      
1      vCLS (2)   [nfs141] vCLS (2)/vCLS (2).vmx   other3xLinux64Guest   vmx-11    vSphere Cluster Service VM is deployed from an OVA with a minimal installed profile of PhotonOS. vSphere Cluster Service manages the resources, power state and availability of these VMs. vSphere Cluster Service VMs are required for maintaining the health and availability of vSphere Cluster Service. Any impact on the power state or resources of these VMs might degrade the health of the vSphere Cluster Service and cause vSphere DRS to cease operation for the cluster.
6      centos51   [nfs141] centos51/centos51.vmx   centos8_64Guest       vmx-14                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
7      vCLS (1)   [nfs141] vCLS (1)/vCLS (1).vmx   other3xLinux64Guest   vmx-11    vSphere Cluster Service VM is deployed from an OVA with a minimal installed profile of PhotonOS. vSphere Cluster Service manages the resources, power state and availability of these VMs. vSphere Cluster Service VMs are required for maintaining the health and availability of vSphere Cluster Service. Any impact on the power state or resources of these VMs might degrade the health of the vSphere Cluster Service and cause vSphere DRS to cease operation for the cluster.
8      centos60   [nfs141] centos60/centos60.vmx   centos8_64Guest       vmx-14                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
9      centos61   [nfs141] centos61/centos61.vmx   centos8_64Guest       vmx-14                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         


[root@esxi144:~] vim-cmd vmsvc/getallvms
Vmid     Name                  File                     Guest OS         Version                                                                                                                                                                                                                                        Annotation                                                                                                                                                                                                                                      
1      vCLS (3)   [nfs141] vCLS (3)/vCLS (3).vmx   other3xLinux64Guest   vmx-11    vSphere Cluster Service VM is deployed from an OVA with a minimal installed profile of PhotonOS. vSphere Cluster Service manages the resources, power state and availability of these VMs. vSphere Cluster Service VMs are required for maintaining the health and availability of vSphere Cluster Service. Any impact on the power state or resources of these VMs might degrade the health of the vSphere Cluster Service and cause vSphere DRS to cease operation for the cluster.
6      centos52   [nfs141] centos52/centos52.vmx   centos8_64Guest       vmx-14                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
7      centos71   [nfs141] centos72/centos72.vmx   centos8_64Guest       vmx-14                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
8      centos70   [nfs141] centos70/centos70.vmx   centos8_64Guest       vmx-14                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
[root@esxi144:~] 

障害発生時の仮想マシンの配置

特定ESXiホスト内での実行

物理CPU課金となるソフトウェアのライセンス費を抑制するため、クラスタの一部ホスト内でのみESXiを動作させたい要件があるかもしれません。このような場合も「仮想マシン/ホストのルール」で対応できます。

「仮想マシン/ホストのルール」を使ったからと言って必ずしもライセンス費を抑制できるとは限りません。ライセンス条項は時事刻々と変わりますし、ベンダーとの交渉が必要な分野です。この設定は交渉材料のひとつであり、必ずしもライセンス費の抑制になるとは限らない事をご理解ください。

設定の概要

192.168.1.144のESXiのみライセンス費を支払っているホストのようなシナリオを想定し、以下のようなルールを投入します。

仮想マシン ルール
centos50, centos51, centos52 特になし
centos60, centos61 192.168.1.144で実行(must)
centos70, centos71 192.168.1.144で実行(should)

ホストグループ

設定対象とするホスト(ESXi)群に対して名前をつけます。

vCenterの管理画面にて、「対象クラスタ」「仮想マシン/ホスト グループ」「追加」の順に押下します。

ホストグループ名の設定 01

名前を入力し、タイプは「ホストグループ」を選びます。その後、「追加」を押下します。

ホストグループ名の設定 02

対象とするホストにチェックを入れ、「OK」を押下します。

ホストグループ名の設定 03

「OK」を押下します。

ホストグループ名の設定 04

ホストグループが追加された事を確認します。

ホストグループ名の設定 05

仮想マシングループ

設定対象とする仮想マシン群に対して以下のような名前をつけます。

仮想マシン グループ名
centos50, centos51, centos52 vm_group01
centos60, centos61 vm_group02
centos70, centos71 vm_group03

vCenterの管理画面にて、「対象クラスタ」「仮想マシン/ホスト グループ」「追加」の順に押下します。

仮想マシングループ名の設定 01

名前を入力し、タイプは「仮想マシングループ」を選びます。その後、「追加」を押下します。

仮想マシングループ名の設定 02

対象とする仮想マシンにチェックを入れ、「OK」を押下します。

仮想マシングループ名の設定 03

「OK」を押下します。

仮想マシングループ名の設定 04

ホストグループが追加された事を確認します。

仮想マシングループ名の設定 05

centos60, centos61にも同様の操作をして、グループ名「vm_group02」を付与します。

仮想マシングループ名の設定 06

centos70, centos71にも同様の操作をして、グループ名「vm_group03」を付与します。

仮想マシングループ名の設定 07

仮想マシンからホストへ (仕様説明)

仮想マシンが特定のESXiホストで動作するように設定します。

どのような動作にするかは以下のプルダウンメニューで表示される4つから選ぶ事ができます。

グループ実行の設定(日本語)

この表記は日本語では分かりづらいのですが、これを英語にすると意味は明確です。mustかshouldかの違いで「絶対」か「努力目標」かのような違いです。

グループ実行の設定(英語)

仮想マシンからホストへ (仕様説明)

vCenterの管理画面にて、「対象クラスタ」「仮想マシン/ホスト ルール」「追加」の順に押下します。

仮想マシンからホストへ 01

ルール名を入力し、タイプは「仮想マシンからホストへ」を選びます。「vm_group02」を「license_esxi」で実行させるよう「グループ内のホストで実行する必要があります」を選びます。この設定の意味は「must」です。

仮想マシンからホストへ 02

アフィェニティルールが追加された事を確認します。

仮想マシンからホストへ 03

もう1度「追加」を押下します。

仮想マシンからホストへ 04

ルール名を入力し、タイプは「仮想マシンからホストへ」を選びます。「vm_group03」を「license_esxi」で実行させるよう「グループ内のホストで実行します」を選びます。この設定の意味は「should」です。

仮想マシンからホストへ 05

アフィニティルールが追加された事を確認します。

仮想マシンからホストへ 06

障害発生時の挙動

障害発生前は192.168.1.144にcentos60, centos61, centos70, centos71が格納されています。

障害発生時の挙動 01

ESXiホスト192.168.1.144を再起動させます。

[root@esxi144:~] reboot

障害発生時の挙動 02

しばらく経つと、「グループ内のホストで実行します(should)」の設定がされているcentos70, centos71は192.168.143へvMotionされサービスが継続されている事が読み取れます。一方、「グループ内のホストで実行する必要があります(must)」の設定がされているcentos60, centos61は停止中のままです。

障害発生時の挙動 03

さらに時間経過し、ESXiホスト192.168.1.144の再起動が完了すると、centos70, centos71が192.168.1.143から192.168.1.144へ戻る挙動が確認できます。

障害発生時の挙動 04

タイトルとURLをコピーしました