Show Table of Contents
6.10. Adding a Cluster Service to the Cluster
To configure a cluster service in a cluster, perform the following steps:
- Add a service to the cluster with the following command:
ccs -h host --addservice servicename [service options]
Note
Use a descriptive name that clearly distinguishes the service from other services in the cluster.When you add a service to the cluster configuration, you configure the following attributes: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. The restart recovery policy indicates that the system should attempt to restart the failed service before trying to relocate the service to another node. The relocate policy indicates that the system should try to restart the service in a different node. The disable policy indicates that the system should disable the resource group if any component fails. The restart-disable policy indicates that the system should attempt to restart the service in place if it fails, but if restarting the service fails the service will be disabled instead of being moved to another host in the cluster.If you select or as the recovery policy for the service, you can specify the maximum number of restart failures before relocating or disabling the service, and you can specify the length of time in seconds after which to forget a restart.
For example, to add a service to the configuration file on the cluster nodenode-01.example.comnamedexample_apachethat uses the failover domainexample_pri, and that has recovery policy ofrelocate, execute the following command:ccs -h node-01.example.com --addservice example_apache domain=example_pri recovery=relocate
When configuring services for a cluster, you may find it useful to see a listing of available services for your cluster and the options available for each service. For information on using theccscommand to print a list of available services and their options, see Section 6.11, “Listing Available Cluster Services and Resources”. - Add resources to the service with the following command:
ccs -h host --addsubservice servicename subservice [service options]
Depending on the type of resources you want to use, populate the service with global or service-specific resources. To add a global resource, use the--addsubserviceoption of theccsto add a resource. For example, to add the global file system resource namedweb_fsto the service namedexample_apacheon the cluster configuration file onnode-01.example.com, execute the following command:ccs -h node01.example.com --addsubservice example_apache fs ref=web_fs
To add a service-specific resource to the service, you need to specify all of the service options. For example, if you had not previously definedweb_fsas a global service, you could add it as a service-specific resource with the following command:ccs -h node01.example.com --addsubservice example_apache fs name=web_fs device=/dev/sdd2 mountpoint=/var/www fstype=ext3
- To add a child service to the service, you also use the
--addsubserviceoption of theccscommand, specifying the service options.If you need to add services within a tree structure of dependencies, use a colon (":") to separate elements and brackets to identify subservices of the same type. The following example adds a thirdnfsclientservice as a subservice of annfsclientservice which is in itself a subservice of annfsclientservice which is a subservice of a service namedservice_a:ccs -h node01.example.com --addsubservice service_a nfsclient[1]:nfsclient[2]:nfsclient
Note
If you are adding a Samba-service resource, add it directly to the service, not as a child of another resource.Note
When configuring a dependency tree for a cluster service that includes a floating IP address resource, you must configure the IP resource as the first entry.
Note
To verify the existence of the IP service resource used in a cluster service, you can use the
/sbin/ip addr show command on a cluster node (rather than the obsoleted ifconfig command). The following output shows the /sbin/ip addr show command executed on a node running a cluster service:
1: lo: <LOOPBACK,UP> mtu 16436 qdisc noqueue
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP> mtu 1356 qdisc pfifo_fast qlen 1000
link/ether 00:05:5d:9a:d8:91 brd ff:ff:ff:ff:ff:ff
inet 10.11.4.31/22 brd 10.11.7.255 scope global eth0
inet6 fe80::205:5dff:fe9a:d891/64 scope link
inet 10.11.4.240/22 scope global secondary eth0
valid_lft forever preferred_lft forever
To remove a service and all of its subservices, execute the following command:
ccs -h host --rmservice servicename
To remove a subservice, execute the following command:
ccs -h host --rmsubservice servicename subservice [service options]
Note that when you have finished configuring all of the components of your cluster, you will need to sync the cluster configuration file to all of the nodes, as described in Section 6.15, “Propagating the Configuration File to the Cluster Nodes”.

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.