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]
ccs -h host --addservice servicename [service options]Copy to Clipboard Copied! Toggle word wrap Toggle overflow 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
ccs -h node-01.example.com --addservice example_apache domain=example_pri recovery=relocateCopy to Clipboard Copied! Toggle word wrap Toggle overflow 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]
ccs -h host --addsubservice servicename subservice [service options]Copy to Clipboard Copied! Toggle word wrap Toggle overflow 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
ccs -h node01.example.com --addsubservice example_apache fs ref=web_fsCopy to Clipboard Copied! Toggle word wrap Toggle overflow 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
ccs -h node01.example.com --addsubservice example_apache fs name=web_fs device=/dev/sdd2 mountpoint=/var/www fstype=ext3Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 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
ccs -h node01.example.com --addsubservice service_a nfsclient[1]:nfsclient[2]:nfsclientCopy to Clipboard Copied! Toggle word wrap Toggle overflow 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:
To remove a service and all of its subservices, execute the following command:
ccs -h host --rmservice servicename
ccs -h host --rmservice servicename
To remove a subservice, execute the following command:
ccs -h host --rmsubservice servicename subservice [service options]
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”.