22.2. グローバルリソース操作のデフォルトの設定
pcs resource op defaults update
コマンドを使用すると、すべてのリソースでリソースオペレーションのデフォルト値を変更できます。
たとえば、次のコマンドは、すべての監視操作に対して、timeout
値のグローバルデフォルトを 240 秒に設定します。
pcs resource op defaults update timeout=240s
# pcs resource op defaults update timeout=240s
以前のリリースのすべてのリソース操作のデフォルトを設定する元の pcs resource defaults name=value
コマンドは、複数のデフォルトが設定されない限りサポートされます。ただし、pcs resource op defaults update
が、コマンドの推奨されるバージョンになりました。
22.2.1. リソース固有の操作の値の上書き
クラスターリソース定義でオプションが指定されていない場合に限り、クラスターリソースがグローバルデフォルトを使用することに注意してください。デフォルトでは、リソースエージェントがすべての操作の timeout
オプションを定義します。グローバル操作のタイムアウト値を有効にするには、timeout
オプションを明示的に指定せずにクラスターリソースを作成するか、次のコマンドのように、クラスターリソースを更新して timeout
オプションを削除する必要があります。
pcs resource update VirtualIP op monitor interval=10s
# pcs resource update VirtualIP op monitor interval=10s
たとえば、すべての監視操作に、グローバルデフォルトの timeout
値 240 秒を設定し、クラスターリソース VirtualIP
を更新して、monitor
操作のタイムアウト値を削除すると、リソース VirtualIP
には、start
、stop
、および monitor
の操作のタイムアウト値が、それぞれ 20 秒、40 秒、240 秒に設定されます。タイムアウト操作のグローバルなデフォルト値は、ここでは monitor
にのみ適用されます。ここでは、前のコマンドにより、デフォルトの timeout
オプションが削除されています。
pcs resource config VirtualIP
# pcs resource config VirtualIP
Resource: VirtualIP (class=ocf provider=heartbeat type=IPaddr2)
Attributes: ip=192.168.0.99 cidr_netmask=24 nic=eth2
Operations: start interval=0s timeout=20s (VirtualIP-start-timeout-20s)
monitor interval=10s (VirtualIP-monitor-interval-10s)
stop interval=0s timeout=40s (VirtualIP-name-stop-interval-0s-timeout-40s)
22.2.2. リソースセットのリソース操作のデフォルト値の変更
pcs resource op defaults set create
コマンドを使用して、複数のリソース操作のデフォルトセットを作成できます。これにより、resource
式および操作式を含むルールを指定できます。Pacemaker が対応しているルール式はすべて使用できます。
このコマンドを使用すると、特定タイプのすべてのリソースに、デフォルトのリソース操作値を設定できます。たとえば、バンドルが使用されている場合に Pacemaker が作成した暗黙的な podman
リソースを設定できるようになりました。
以下のコマンドは、すべての podman
リソースの全操作に、デフォルトのタイムアウト値 90s を設定します。この例では、::podman
は、クラスやプロバイダーは任意でタイプが podman
を指定します。
リソース操作のデフォルトセット名を指定する id
オプションは必須ではありません。このオプションを設定すると、pcs
が自動的に ID を生成します。この値を設定すると、より分かりやすい名前に設定できます。
pcs resource op defaults set create id=podman-timeout meta timeout=90s rule resource ::podman
# pcs resource op defaults set create id=podman-timeout meta timeout=90s rule resource ::podman
以下のコマンドは、すべてのリソースの stop
操作に、デフォルトのタイムアウト値 120s を設定します。
pcs resource op defaults set create id=stop-timeout meta timeout=120s rule op stop
# pcs resource op defaults set create id=stop-timeout meta timeout=120s rule op stop
特定タイプの全リソースの、特定の操作にデフォルトのタイムアウト値を設定できます。以下の例は、すべての podman
リソースの stop
操作に、デフォルトのタイムアウト値 120 を設定します。
pcs resource op defaults set create id=podman-stop-timeout meta timeout=120s rule resource ::podman and op stop
# pcs resource op defaults set create id=podman-stop-timeout meta timeout=120s rule resource ::podman and op stop
22.2.3. 現在設定されているリソース操作のデフォルト値の表示
pcs resource op defaults [config]
コマンドは、指定したルールなど、現在設定されているリソース操作のデフォルト値のリストを表示します。Red Hat Enterprise Linux 9.5 以降では、このコマンドの出力をテキスト、JSON、およびコマンド形式で表示できます。
-
--output-format=text
を指定すると、設定されているリソース操作のデフォルトがプレーンテキスト形式で表示されます。これはこのオプションのデフォルト値です。 -
--output-format=cmd
を指定すると、現在のクラスターのデフォルト設定から作成されたpcs resource op defaults
コマンドが表示されます。このコマンドを使用すると、別のシステムで設定されたリソース操作のデフォルトを再作成できます。 -
--output-format=json
を指定すると、設定されているリソース操作のデフォルトが、マシン解析に適した JSON 形式で表示されます。
以下に、pcs resource op defaults config
コマンドの 3 つの異なる出力形式の例を示します。まず、次の例のコマンドを使用して、ocf:pacemaker:podman
リソースのデフォルトのリソース操作値をリセットします。
pcs resource op defaults set create id=op-set-1 score=100 meta timeout=30s rule op monitor and resource ocf:pacemaker:podman
# pcs resource op defaults set create id=op-set-1 score=100 meta timeout=30s rule op monitor and resource ocf:pacemaker:podman
Warning: Defaults do not apply to resources which override them with their own defined values
この例では、設定されているリソース操作のデフォルト値をプレーンテキストで表示します。
pcs resource op defaults config
# pcs resource op defaults config
Meta Attrs: op-set-1 score=100
timeout=30s
Rule: boolean-op=and score=INFINITY
Expression: op monitor
Expression: resource ocf:pacemaker:podman
この例では、現在のクラスターのデフォルト設定から作成された pcs resource op defaults
コマンドを表示します。
pcs resource op defaults config --output-format=cmd
# pcs resource op defaults config --output-format=cmd
pcs -- resource op defaults set create id=op-set-1 score=100 \
meta timeout=30s \
rule 'op monitor and resource ocf:pacemaker:podman'
この例では、設定されているリソース操作のデフォルト値を JSON 形式で表示します。
pcs resource op defaults config --output-format=json
# pcs resource op defaults config --output-format=json
{"instance_attributes": [], "meta_attributes": [{"id": "op-set-1", "options": {"score": "100"}, "rule": {"id": "op-set-1-rule", "type": "RULE", "in_effect": "UNKNOWN", "options": {"boolean-op": "and", "score": "INFINITY"}, "date_spec": null, "duration": null, "expressions": [{"id": "op-set-1-rule-op-monitor", "type": "OP_EXPRESSION", "in_effect": "UNKNOWN", "options": {"name": "monitor"}, "date_spec": null, "duration": null, "expressions": [], "as_string": "op monitor"}, {"id": "op-set-1-rule-rsc-ocf-pacemaker-podman", "type": "RSC_EXPRESSION", "in_effect": "UNKNOWN", "options": {"class": "ocf", "provider": "pacemaker", "type": "podman"}, "date_spec": null, "duration": null, "expressions": [], "as_string": "resource ocf:pacemaker:podman"}], "as_string": "op monitor and resource ocf:pacemaker:podman"}, "nvpairs": [{"id": "op-set-1-timeout", "name": "timeout", "value": "30s"}]}]}