【RHEL 7】High Availability アドオンのリソースの設定

インフラサーバ

ここでは Red Hat Enterprise Linux 7 における HA アドオンを使用したクラスタ構築について、リソースの設定に関する内容を記載します。
こちらの記事の続きの位置付けです

リソースの作成と削除

■参考ページ

第6章 クラスターリソースの設定 Red Hat Enterprise Linux 7 | Red Hat Customer Portal
Access Red Hat’s knowledge, guidance, and support through your subscription.

リソースの作成

pcs resource create "resource_id" ["各種オプション"]

リソースに関しては以下のような要素がある。

  • プロパティ
  • 固有パラメータ
  • メタオプション
  • 動作
  • その他の高度な設定

■リソース作成例

pcs resource create VirtualIP ocf:heartbeat:IPaddr2 ip=192.168.0.120 cidr_netmask=24 op monitor interval=30s

リソースの表示

pcs resource show                #リソース一覧を表示
pcs resource show --full         #すべてのリソースのパラメータを表示
pcs resource show "resource_id"  #指定リソースのパラメータを表示

使用例

# pcs resource show VirtualIP
 Resource: VirtualIP (class=ocf provider=heartbeat type=IPaddr2)
  Attributes: cidr_netmask=24 ip=192.168.0.120
  Operations: monitor interval=30s (VirtualIP-monitor-interval-30s)
              start interval=0s timeout=20s (VirtualIP-start-interval-0s)
              stop interval=0s timeout=20s (VirtualIP-stop-interval-0s)

リソースの削除

pcs resource delete "resource_id"

リソースのプロパティ

■参考ページ

6.2. リソースのプロパティー Red Hat Enterprise Linux 7 | Red Hat Customer Portal
Access Red Hat’s knowledge, guidance, and support through your subscription.
項目説明
resource_idリソースの名前
standardスクリプトが準拠する標準
使用できる値: ocf、service、upstart、systemd、lsb、stonith
type使用するリソースエージェントの名前
例: IPaddr、Filesystem など
providerリソースエージェントのプロバイダ
Red Hat ではほとんどが heartbeat を使用している

■リソース作成構文に上記のリソースプロパティを組み込んで表記してみる

pcs resource create "resource_id" [standard:[provider:]]type ["各種オプション"]

■利用できる全リソースの一覧を表示

pcs resource list

■利用できるリソースエージェントの標準を表示

pcs resource standards

■利用できるリソースエージェントのプロバイダーを表示

pcs resource providers

リソース固有のパラメータ

■参考ページ

6.3. リソース固有のパラメーター Red Hat Enterprise Linux 7 | Red Hat Customer Portal
Access Red Hat’s knowledge, guidance, and support through your subscription.

以下のコマンドを使用すると、そのリソースに設定できるパラメータが表示される。

pcs resource describe "standard:provider:type"|"type"

リソース IPaddr について表示する例:

# pcs resource describe IPaddr
Assumed agent name 'ocf:heartbeat:IPaddr' (deduced from 'IPaddr')
ocf:heartbeat:IPaddr - Manages virtual IPv4 and IPv6 addresses (Linux specific version)
#(略)
Resource options:
  ip (required) (unique): The IPv4 (dotted quad notation) or IPv6 address (colon hexadecimal notation) example IPv4
                          "192.168.1.1". example IPv6 "2001:db8:DC28:0:0:FC57:D4C8:1FFF".
  nic: The base network interface on which the IP address will be brought online. If left empty, the script will try
       and determine this from the routing table. Do NOT specify an alias interface in the form eth0:1 or anything
       here; rather, specify the base interface only. If you want a label, see the iflabel parameter. Prerequisite:
       There must be at least one static IP address, which is not managed by the cluster, assigned to the network
       interface. If you can not assign any static IP address on the interface, modify this kernel parameter: sysctl
       -w net.ipv4.conf.all.promote_secondaries=1 # (or per device)
  cidr_netmask: The netmask for the interface in CIDR format (e.g., 24 and not 255.255.255.0) If unspecified, the
                script will also try to determine this from the routing table.
  broadcast: Broadcast address associated with the IP. It is possible to use the special symbols '+' and '-' instead
             of the broadcast address. In this case, the broadcast address is derived by setting/resetting the host
             bits of the interface prefix.
#(略)

リソースのメタオプション

リソース固有のパラメータの他にも追加のリソースオプションを設定することができる。

6.4. リソースのメタオプション Red Hat Enterprise Linux 7 | Red Hat Customer Portal
Access Red Hat’s knowledge, guidance, and support through your subscription.
項目デフォルト説明
priority0他のリソースと競合する場合の起動優先度
target-roleStartedリソースの状態
Stopped ⇒ 強制停止
Started ⇒ 起動を許可 (マルチステートリソースの場合マスタへ昇格されない)
Master ⇒ 起動を許可 (適切な場合マスタへ昇格される)
is-managedtrueクラスタによるリソースの起動と停止を
true ⇒ 許可
false ⇒ 許可しない
resource-stickiness0リソースをそのノードに留まらせる優先度
requires場合によって変化リソースの起動を許可する条件
nothing ⇒ クラスタによるリソースの起動を常に許可
quorum ⇒ 設定されているノードの過半数がアクティブな場合にのみクラスタはこのリソースを起動可能
fencing ⇒ 設定されているノードの過半数がアクティブで、かつ障害が発生しているノードや不明なノードの電源がすべてオフになっている場合にのみ、クラスタによるこのリソースの起動を許可
unfencing ⇒ 設定されているノードの過半数がアクティブで、かつ障害が発生しているノードや不明なノードの電源がすべてオフになっている場合にのみ、アンフェンスが行われたノードに限定してこのリソースの起動を許可
migration-thresholdINFINITY各ノードについてリソースが失敗した回数の上限
この回数を超えると、そのノードはそのリソースのホストとして不適格とマーキングされる
0 ⇒ この機能は無効になる
INFINITY ⇒ 非常に大きい有限数として扱われる
この機能が有効化される条件は以下2点
・失敗した操作の on-fail が restart
・失敗した起動操作に対してクラスタプロパティ start-failure-is-fatal が false
failure-timeout 0 (無効)migration-threshold オプションと併用して、障害は発生していなかったとして動作するまでに待機させる秒数
multiple-activestop_startリソースが複数のノードで実行していることが検出された場合にクラスタに行わせる動作
block ⇒ リソースに unmanaged のマークを付ける
stop_only ⇒ 実行しているインスタンスをすべて停止する (これ以上の動作は行わない)
stop_start ⇒ 実行中のインスタンスをすべて停止してから一ヶ所でのみ起動する

※詳細は公式ドキュメント参照

リソースオプションのデフォルト値の変更

pcs resource defaults "options"

使用例

# pcs resource defaults resource-stickiness=100
Warning: Defaults do not apply to resources which override them with their own defined values

設定したデフォルト値の表示

# pcs resource defaults
resource-stickiness=100

設定したデフォルト値のクリア(値を空白としてデフォルト値を設定する)

# pcs resource defaults resource-stickiness=
Warning: Defaults do not apply to resources which override them with their own defined values
# pcs resource defaults
No defaults set

既存リソースのメタオプションの変更

pcs resource meta "resource_id" | "group_id" | "clone_id" | "master_id"  "meta_options"

使用例:既存リソース dummy_resource の failure-timeout を 20 秒とする場合

pcs resource meta dummy_resource failure-timeout=20s 

リソースグループの作成

■参考ページ

6.5. リソースグループ Red Hat Enterprise Linux 7 | Red Hat Customer Portal
Access Red Hat’s knowledge, guidance, and support through your subscription.

リソースグループとは複数のリソースのセットであり以下の性質を持ちます。

  • グループ内のリソースはすべて同じノードに配置される
  • 起動時は各リソースが一定順序で起動される
  • 停止時は各リソースが起動時と逆順で停止される
  • グループ内のリソース数に制限はない
  • グループ内のリソースの 1 つを実行できない場合、そのリソースの後に指定されたリソースは実行できない

リソースグループの作成とリソース追加

リソースグループの作成は以下コマンドで行う。

pcs resource group add "group_name" "resource_id" ["resource_id"] ... ["resource_id"] [--before "resource_id" | --after "resource_id"]

既存のリソースグループへのリソースの追加についても上のコマンドを使用する。その際、--before/--after オプションを使用してリソースの追加位置を指定する。

リソース作成時にリソースグループに追加する

以下のように --group オプションを使用することでリソース作成と同時に作成したリソースをグループ group_name に追加することができる。

pcs resource create "resource_id" ["各種オプション"] --group "group_name"

リソースグループを表示

以下のコマンドですべてのリソースグループを表示する。

pcs resource group list

リソースグループからリソースを削除する

以下のコマンドで指定したリソースグループから指定したリソースを削除できる。

pcs resource group remove "group_name" "resource_id"...

グループ名だけを指定しリソースを指定しない場合、グループ自体を削除する。

リソースグループの操作例

操作内容:

  • リソースグループ VIPs の作成
  • リソースグループの表示
  • リソースグループ VIPs からリソース VirtualIP2 を削除
  • リソースグループの表示
  • リソースグループ VIPs の削除
  • リソースグループの表示
# pcs resource group add VIPs VirtualIP VirtualIP2

# pcs resource group list
VIPs: VirtualIP VirtualIP2

# pcs resource group remove VIPs VirtualIP2

# pcs resource group list
VIPs: VirtualIP

# pcs resource group remove VIPs

# pcs resource group list
#

リソースグループのオプションについて

  • 以下のオプションについては、リソースグループ内のリソースから継承する。
    • priority オプション
    • target-role オプション
    • is-managed オプション
  • resource-stickiness については、リソースグループ内のアクティブなリソースの resource-stickiness 値の合計となる

リソースモニタリング

■参考ページ

6.6. リソースの動作 Red Hat Enterprise Linux 7 | Red Hat Customer Portal
Access Red Hat’s knowledge, guidance, and support through your subscription.
  • リソースの定義にモニタリングの動作を追加することができる
  • モニタリングの動作を指定しない場合はデフォルトのモニタリング動作が設定される
  • デフォルトのモニタリング間隔はリソースエージェントによって決まるが、リソースエージェントから提供されない場合は 60 秒になる

モニタリング動作のプロパティは以下の通り。

項目デフォルト説明
id動作設定時にシステムによって割り当てられる固有名
name実行する動作
monitor
start
stop
interval00 以外の値 ⇒ 秒単位で繰り返しを行う繰り返し操作が作成される
 ※name=monitor である必要がある
0 ⇒ クラスタによって作成された操作に使用される値を指定することになる(?)
timeout20秒操作がエラーとみなされるまでの時間
この時間までに操作が完了しないとエラーと判定される

on-failfence
※name=stop かつ

STONITH が有効の場合

block
※name=stop かつ

STONITH が無効の場合

restert
※上記以外の場合
その動作が失敗した場合に実行する動作
ignore ⇒ リソースが失敗していなかったように振る舞う
block ⇒ リソースでこれ以上、一切の動作を行わない
stop ⇒ リソースを停止して別の場所で起動しない
restart ⇒ リソースを停止してから再起動する (おそらく別の場所で)
fence ⇒ 失敗したリソースがあるノードを STONITH する
standby ⇒ 失敗したリソースがあるノード上のすべてのリソースを移動させる
enabledtrue
false ⇒ その動作はないものとして処理される

モニタリング動作の設定

リソース作成時に設定する

以下のようにリソース作成コマンドに動作オプションを付けることでモニタリング動作の設定をすることができる。

pcs resource create "resource_id" "standard:provider:type"|"type" ["resource_options"] [op "operation_action" "operation_options" ["operation_type" "operation_options"]...]

設定例:30 秒ごとにモニタリングする動作を設定した IPaddr2 リソースを作成する場合

pcs resource create VirtualIP ocf:heartbeat:IPaddr2 ip=192.168.0.99 cidr_netmask=24 nic=eth2 op monitor interval=30s

既存リソースに動作を追加する

以下のコマンドで既存のリソースにモニタリング動作を追加することができる。

pcs resource op add "resource_id" "operation_action" ["operation_properties"]

リソースの動作の削除

pcs resource op remove "resource_id" "operation_name" "operation_properties"

既存リソースの動作を変更する

モニタリングオプションの値を変更するには、以下コマンドでリソースを更新します。

pcs resource update "resource_id" "operation_action" ["operation_properties"]

pcs resource update コマンドでリソースの動作を更新すると、具体的に呼び出されていないオプションは、デフォルト値にリセットされます。

モニタリング動作のグローバルデフォルト値の設定

以下のコマンドでモニタリング動作のグローバルデフォルト値を設定できる。

pcs resource op defaults ["options"]

使用例:timeout のデフォルト値を 240s にする場合

pcs resource op defaults timeout=240s

リソースパラメータの変更

■参考ページ

6.8. リソースパラメーターの変更 Red Hat Enterprise Linux 7 | Red Hat Customer Portal
Access Red Hat’s knowledge, guidance, and support through your subscription.

既存リソースのパラメータを変更する場合は以下コマンドを使用する。

pcs resource update "resource_id" ["resource_options"]

使用例:既存リソース VirtualIP の IP アドレスを変更する場合

# pcs resource show --full
 Resource: VirtualIP (class=ocf provider=heartbeat type=IPaddr2)
  Attributes: cidr_netmask=24 ip=192.168.139.200
  Operations: monitor interval=30s (VirtualIP-monitor-interval-30s)
              start interval=0s timeout=20s (VirtualIP-start-interval-0s)
              stop interval=0s timeout=20s (VirtualIP-stop-interval-0s)

# pcs resource update VirtualIP ip=192.168.139.210

# pcs resource show VirtualIP
 Resource: VirtualIP (class=ocf provider=heartbeat type=IPaddr2)
  Attributes: cidr_netmask=24 ip=192.168.139.210
  Operations: monitor interval=30s (VirtualIP-monitor-interval-30s)
              start interval=0s timeout=20s (VirtualIP-start-interval-0s)
              stop interval=0s timeout=20s (VirtualIP-stop-interval-0s)

クラスタリソースの有効化と無効化

■参考ページ

6.10. クラスターリソースの有効化と無効化 Red Hat Enterprise Linux 7 | Red Hat Customer Portal
Access Red Hat’s knowledge, guidance, and support through your subscription.
pcs resource enable "resource_id"     #指定リソースを有効化
pcs resource disable "resource_id"    #指定リソースを無効化

クラスタリソースのクリーンアップ

■参考ページ

6.11. クラスターリソースのクリーンアップ Red Hat Enterprise Linux 7 | Red Hat Customer Portal
Access Red Hat’s knowledge, guidance, and support through your subscription.
pcs resource cleanup "resource_id"

このコマンドによって、リソースの動作履歴を消去して現在の状態を再検出するようクラスタに指示することができる。

  • リソースの状態をリセットする
  • failcount をリセットする

resource_id を指定しない場合はすべてのリソースがクリーンアップ対象となる。

Red Hat Enterprise Linux 7.5 で全ノードの全リソースをクリーンアップするには、次のコマンドを使用する。

pcs resource refresh          #リソースの状態がわかっているノードだけを調べる
pcs resource refresh --full   #状態が分からないリソースもすべて調べる

参考ページ

第6章 クラスターリソースの設定 Red Hat Enterprise Linux 7 | Red Hat Customer Portal
Access Red Hat’s knowledge, guidance, and support through your subscription.

―――――――――――――

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