8.5.2. Adding a Cluster Service to the Cluster

To add a cluster service to the cluster, follow the steps in this section.

Note

The examples provided in this section show a cluster service in which all of the resources are at the same level. For information on defining a service in which there is a dependency chain in a resource hierarchy, as well as the rules that govern the behavior of parent and child resources, see Appendix C, HA Resource Behavior.
  1. Open /etc/cluster/cluster.conf at any node in the cluster.
  2. Add a service section within the rm element for each service. For example:
    
        <rm>
            <service autostart="1" domain="" exclusive="0" name="" recovery="restart">
    
            </service>
        </rm>
    
  3. Configure the following parameters (attributes) in the service element:
    • autostart — Specifies whether to autostart the service when the cluster starts. Use '1' to enable and '0' to disable; the default is enabled.
    • domain — Specifies a failover domain (if required).
    • exclusive — Specifies a policy wherein the service only runs on nodes that have no other services running on them.
    • recovery — Specifies a recovery policy for the service. The options are to relocate, restart, disable, or restart-disable the service.
  4. Depending on the type of resources you want to use, populate the service with global or service-specific resources
    For example, here is an Apache service that uses global resources:
    
        <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>
    
    For example, here is an Apache service that uses service-specific resources:
    
        <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 — This service uses global resources web_fs, 127.143.131.100, and example_server.
    • example_apache2 — This service uses service-specific resources web_fs2, 127.143.131.101, and example_server2.
  5. Update the config_version attribute by incrementing its value (for example, changing from config_version="2" to config_version="3">).
  6. Save /etc/cluster/cluster.conf.
  7. (Optional) Validate the updated file against the cluster schema (cluster.rng) by running the ccs_config_validate command. For example:
    [root@example-01 ~]# ccs_config_validate 
    Configuration validates
    
  8. Run the cman_tool version -r command to propagate the configuration to the rest of the cluster nodes.
  9. Verify that the updated configuration file has been propagated.

Example 8.10. cluster.conf with Services Added: One Using Global Resources and One Using Service-Specific Resources


<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>
Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.