Red Hat Training

A Red Hat training course is available for Red Hat Enterprise Linux

7.5.2. クラスターへのクラスターサービスの追加

クラスターにクラスターサービスを追加するには、このセクション内の手順に従ってください。

注記

このセクションの例では、すべてのリソースが同一レベルにあるクラスターサービスを示しています。リソース階層に依存関係があるサービスの定義に関する情報および親と子のリソース動作を管理するルールについては、付録C HA リソースの動作 を参照してください。
  1. クラスター内のいずれかのノードで /etc/cluster/cluster.conf を開きます。
  2. 各サービス用の rm 要素内に service セクションを追加します。例えば:
    
        <rm>
            <service autostart="1" domain="" exclusive="0" name="" recovery="restart">
    
            </service>
        </rm>
    
    
  3. service 要素内で以下のパラメーター (属性) を設定します:
    • autostart — クラスターの開始時にサービスを自動起動するかどうかを指定します。有効にするには「1」を、無効にするには「0」を使用します。デフォルトは有効です。
    • domain — フェイルオーバードメイン(必要である場合)を指定します。
    • exclusive — 他のサービスが稼働していないノード上でのみサービスを稼働するポリシーを指定します。
    • recovery — サービスの回復ポリシーを指定します。オプションとしては、サービスの再配置、再起動、無効、再起動後に無効、があります。
  4. 使用したいリソースのタイプに応じて、サービスにグローバル又はサービス特有のリソースを入力します。
    例えば、グローバルリソースを使用する Apache サービスは以下のようになります:
    
        <rm>
            <resources>
                    <fs name="web_fs" device="/dev/sdd2" mountpoint="/var/www" fstype="ext3"/>
                    <ip address="127.143.131.100" monitor_link="yes" sleeptime="10"/>
                    <apache config_file="conf/httpd.conf" name="example_server" server_root="/etc/httpd" shutdown_wait="0"/>
            </resources>
            <service autostart="1" domain="example_pri" exclusive="0" name="example_apache" recovery="relocate">
                    <fs ref="web_fs"/>
                    <ip ref="127.143.131.100"/>
                    <apache ref="example_server"/>
            </service>
        </rm>
    
    
    例えば、サービス特有のリソースを使用する Apache サービスは以下のようになります:
    
        <rm>
            <service autostart="0" domain="example_pri" exclusive="0" name="example_apache2" recovery="relocate">
                    <fs name="web_fs2" device="/dev/sdd3" mountpoint="/var/www2" fstype="ext3"/>
                    <ip address="127.143.131.101" monitor_link="yes" sleeptime="10"/>
                    <apache config_file="conf/httpd.conf" name="example_server2" server_root="/etc/httpd" shutdown_wait="0"/>
            </service>
        </rm>
    
    
    • example_apache — このサービスはグローバルリソースである web_fs127.143.131.100 及び example_server を使用します。
    • example_apache2 — このサービスはサービス特有のリソースである web_fs2127.143.131.101、及び example_server2 を使用します。
  5. 値を増加することにより config_version 属性を更新します (例えば、config_version="2" から config_version="3"> へ変更)。
  6. /etc/cluster/cluster.conf を保存します。
  7. (オプション) ccs_config_validate コマンドを実行することでクラスタースキーマ (cluster.rng) に対して更新されたファイルを検証します。例えば:
    [root@example-01 ~]# ccs_config_validate 
    Configuration validates
    
  8. cman_tool version -r コマンドを実行して、設定をクラスターノードの残り部分へ伝播します。
  9. 更新した設定ファイルが伝播されたことを確認します。
  10. 「設定の確認」 へ進みます。

例7.10 サービスが追加された cluster.conf:1 つはグローバルリソースを使用、もう 1 つはサービス特有のリソースを使用


<cluster name="mycluster" config_version="3">
   <clusternodes>
     <clusternode name="node-01.example.com" nodeid="1">
         <fence>
            <method name="APC">
              <device name="apc" port="1"/>
             </method>
         </fence>
     </clusternode>
     <clusternode name="node-02.example.com" nodeid="2">
         <fence>
            <method name="APC">
              <device name="apc" port="2"/>
            </method>
         </fence>
     </clusternode>
     <clusternode name="node-03.example.com" nodeid="3">
         <fence>
            <method name="APC">
              <device name="apc" port="3"/>
            </method>
         </fence>
     </clusternode>
   </clusternodes>
   <fencedevices>
         <fencedevice agent="fence_apc" ipaddr="apc_ip_example" login="login_example" name="apc" passwd="password_example"/>
   </fencedevices>
   <rm>
       <failoverdomains>
           <failoverdomain name="example_pri" nofailback="0" ordered="1" restricted="0">
               <failoverdomainnode name="node-01.example.com" priority="1"/>
               <failoverdomainnode name="node-02.example.com" priority="2"/>
               <failoverdomainnode name="node-03.example.com" priority="3"/>
           </failoverdomain>
       </failoverdomains>
       <resources>
           <fs name="web_fs" device="/dev/sdd2" mountpoint="/var/www" fstype="ext3"/>
           <ip address="127.143.131.100" monitor_link="yes" sleeptime="10"/>
           <apache config_file="conf/httpd.conf" name="example_server" server_root="/etc/httpd" shutdown_wait="0"/>
       </resources>
       <service autostart="1" domain="example_pri" exclusive="0" name="example_apache" recovery="relocate">
           <fs ref="web_fs"/>
           <ip ref="127.143.131.100"/>
           <apache ref="example_server"/>
       </service>
       <service autostart="0" domain="example_pri" exclusive="0" name="example_apache2" recovery="relocate">
           <fs name="web_fs2" device="/dev/sdd3" mountpoint="/var/www2" fstype="ext3"/>
           <ip address="127.143.131.101" monitor_link="yes" sleeptime="10"/>
           <apache config_file="conf/httpd.conf" name="example_server2" server_root="/etc/httpd" shutdown_wait="0"/>
       </service>
   </rm>
</cluster>