Linux-HA Logo

crm_resource は、GUI(GuiGuide[1]参照)に代わる優れた選択肢です。スクリプティング作業等において、有用で頼れる味方になってくれますが、現時点(2.0.7)では、manページは用意されていませんので、以下、いくつかヒントを挙げておきます。

crm_resource
usage: crm_resource [-?VS] -(L|Q|W|D|C|P|p) [options]
        --help (-?)     : this help message
        --verbose (-V)  : turn on debug info. additional instances increase verbosity
        --quiet (-Q)    : Print only the value on stdout (for use with -W)

Commands
        --list (-L)     : List all resources
        --query-xml (-x)        : Query a resource
                          Requires: -r
        --locate (-W)   : Locate a resource
                          Requires: -r
        --migrate (-M)  : Migrate a resource from it current location.  Use -H to specify a destination
                If -H is not specified, we will force the resource to move by creating a rule for the current location and a score of -INFINITY
                NOTE: This will prevent the resource from running on this node until the constraint is removed with -U
                          Requires: -r, Optional: -H, -f
        --un-migrate (-U)       : Remove all constraints created by -M
                          Requires: -r
        --delete (-D)   : Delete a resource from the CIB
                          Requires: -r, -t
        --cleanup (-C)  : Delete a resource from the LRM
                          Requires: -r.  Optional: -H
        --reprobe (-P)  : Recheck for resources started outside of the CRM
                          Optional: -H
        --refresh (-R)  : Refresh the CIB from the LRM
                          Optional: -H
        --set-parameter (-p) <string>   : Set the named parameter for a resource
                          Requires: -r, -v.  Optional: -i, -s
        --get-parameter (-g) <string>   : Get the named parameter for a resource
                          Requires: -r.  Optional: -i, -s
        --delete-parameter (-d) <string>: Delete the named parameter for a resource
                          Requires: -r.  Optional: -i
        --get-property (-G) <string>    : Get the named property (eg. class, type, is_managed) a resource
                          Requires: -r
        --set-property (-S) <string>    : Set the named property (not parameter) for a resource
                          Requires: -r, -t, -v
Options
        --resource (-r) <string>        : Resource ID
        --resource-type (-t) <string>   : Resource type (primitive, clone, group, ...)
        --property-value (-v) <string>  : Property value
        --host-uname (-H) <string>      : Host name
        --force-relocation (-f) : Force the resource to move by creating a rule for the current location and a score of -INFINITY
                This should be used if the resource's stickiness and constraint scores total more than INFINITY (Currently 10,000)
                NOTE: This will prevent the resource from running on this node until the constraint is removed with -U
        -s <string>     : (Advanced Use Only) ID of the instance_attributes object to change
        -i <string>     : (Advanced Use Only) ID of the nvpair object to change/delete

  1. 全リソースのリストアップ

    •   crm_resource -L
  2. リソースがどこで実行されているか(および確実に実行されているか)のチェック

    •   crm_resource -W -r my_first_ip
        resource my_first_ip is running on: server1
      
        crm_resource -W -r my_first_ip
        resource my_first_ip is NOT running
  3. リソースのスタート/ストップ

    •   crm_resource -r my_first_ip -p target_role -v started
        crm_resource -r my_first_ip -p target_role -v stopped
  4. リソース定義の問い合わせ

    •   crm_resource -x -r my_first_ip
  5. リソースを現在位置(ロケーション)から移行(退避)させる

    •   crm_resource -M -r my_first_ip
  6. リソースを特定の位置に移行(退避)させる

    •   crm_resource -M -r my_first_ip -H c001n02
  7. リソースが通常の位置に戻るのを許可する

    •   crm_resource -U -r my_first_ip

      注記: resource_stickinessとdefault_resource_stickinessの値が、リソースが戻らないことを意味する場合があります。リソースを戻すには-Mを使ってから、このコマンドを実行してください。
  8. CRMからリソースを削除

    •   crm_resource -D -r my_first_ip -t primitive
  9. CRMからリソースグループを削除

    •   crm_resource -D -r my_first_group -t group
  10. CRMのリソースに関するリソース管理を無効にする

    •   crm_resource -p is_managed -r my_first_ip -t primitive -v off
  11. CRMのリソースに関するリソース管理を有効にする

    •   crm_resource -p is_managed -r my_first_ip -t primitive -v on
  12. 手動でクリーンアップし、障害を起こしたリソースをリセット

    •   crm_resource -C -H c001n02 -r my_first_ip
  13. CRM外でスタートしたリソースに関する全てのノードを再チェック

    •   crm_resource -P
  14. CRM外でスタートしたリソースに関するノードを再チェック

    •   crm_resource -P -H c001n02
  15. リソースのパラメータの問い合わせ。例えば、リソースが以下の状態だったとします。
    • <primitive id="example_mail" class="ocf" type="MailTo" provider="heartbeat">
        <instance_attributes id="example_mail_inst">
          <attributes>
            <nvpair id="example_mail_inst_attr0" name="email" value="root"/>
            <nvpair id="example_mail_inst_attr1" name="subject" value="Example Failover"/>
          </attributes>
        </instance_attributes>
      </primitive>
      次のように、電子メールアドレスを問い合わせることができます。
        crm_resource -r example_mail -g email
  16. リソースのパラメータの設定。上記と同じ例に続けて
    •   crm_resource -r example_mail -p email -v "myemailaddress@somedomain.com"

References

[1]http://www.linux-ha.org/ja/GuiGuide_ja


This information provided courtesy of the Linux-HA project at http://linux-ha.org/