Sun Cluster Data Service for Solaris Containers Guide

Registering and Configuring Sun Cluster HA for Solaris Containers

Before you perform this procedure, ensure that the Sun Cluster HA for Solaris Containers data service packages are installed.

Use the configuration and registration files in the following directories to register the Sun Cluster HA for Solaris Containers resources:

The files define the dependencies that are required between the Sun Cluster HA for Solaris Containers components. For information about these dependencies, see Dependencies Between Sun Cluster HA for Solaris Containers Components

Registering and configuring Sun Cluster HA for Solaris Containers involves the tasks that are explained in the following sections:

  1. Specifying Configuration Parameters for the Zone Boot Resource

  2. Writing Scripts for the Zone Script Resource

  3. Specifying Configuration Parameters for the Zone Script Resource

  4. Writing a Service Probe for the Zone SMF Resource

  5. Specifying Configuration Parameters for the Zone SMF Resource

  6. How to Create and Enable Resources for the Zone Boot Component

  7. How to Create and Enable Resources for the Zone Script Component

  8. How to Create and Enable Resources for the Zone SMF Component

Specifying Configuration Parameters for the Zone Boot Resource

Sun Cluster HA for Solaris Containers provides the script sczbt_register, which automates the process of configuring the zone boot resource. By default this script obtains configuration parameters from the sczbt_config file in the /opt/SUNWsczone/sczbt/util directory. To specify configuration parameters for the zone boot resource, copy the sczbt_config file to a different filename and amend it as described below. It is recommended to keep this file as a future reference. The register script provides option -f to specify the fully qualified filename to the copied configuration file.

Each configuration parameter in the sczbt_config file is defined as a keyword-value pair. The sczbt_config file already contains the required keywords and equals signs. For more information, see Listing of sczbt_config. When you edit the sczbt_config file, add the required value to each keyword.

The keyword-value pairs in the sczbt_config file are as follows:

RS=sczbt-rs
RG=sczbt-rg
PARAMETERDIR=sczbt-parameter-directory
SC_NETWORK=true|false
SC_LH=sczbt-lh-rs
FAILOVER=true|false
HAS_RS=sczbt-has-rs
Zonename=zone-name
Zonebootopt=zone-boot-options
Milestone=zone-boot-milestone
Mounts=list-of-mountpoints

The meaning and permitted values of the keywords in the sczbt_config file are as follows:

RS=sczbt-rs

Specifies the name that you are assigning to the zone boot resource. You must specify a value for this keyword.

RG=sczbt-rg

Specifies the name of the resource group the zone boot resource will reside in. You must specify a value for this keyword.

PARAMETERDIR=sczbt parameter directory

Specifies the directory name that you are assigning to the parameter directory where some variables and their values will be stored. You must specify a value for this keyword.

SC_NETWORK=true|false

Specifies whether the zone boot resource is network aware with a SUNW.LogicalHostName resource. You must specify a value for this keyword.

  • If HA for the zone's addresses is not required, then configure the zone`s addresses by using the zonecfg utility.


    SC_NETWORK=false
    SC_LH=
  • If only HA through IPMP protection is required, then configure the zone`s addresses by using the zonecfg utility and then place the zone's addresses on an adapter within an IPMP group.


    SC_NETWORK=false
    SC_LH=
  • If HA through IPMP protection and protection against the failure of all physical interfaces by triggering a failover is required, choose one option from the following list:

    • If you require the SUNW.LogicalHostName resource type to manage one or a subset of the zone's addresses, configure a SUNW.LogicalHostName resource for those zone's addresses and not by using the zonecfg utility. Use the zonecfg utility to configure only the zones's addresses that are not to be under the control of the SUNW.LogicalHostName resource.


      SC_NETWORK=true
      SC_LH=Name of the SUNW.LogicalHostName resource
      
    • If you require the SUNW.LogicalHostName resource type to manage all the zone's addresses, configure a SUNW.LogicalHostName resource with a list of the zone`s addresses and do not configure them by using the zonecfg utility.


      SC_NETWORK=true
      SC_LH=Name of the SUNW.LogicalHostName resources
      
    • Otherwise, configure the zone's addresses by using the zonecfg utility and configure a separate redundant IP address for use by a SUNW.LogicalHostName resource, which must not be configured using the zonecfg utility.


      SC_NETWORK=false
      SC_LH=Name of the SUNW.LogicalHostName resource
      
SC_LH=sczbt-lh-rs

Specifies the name of the SUNW.LogicalHostName resource for the zone boot resource. Refer to Restrictions for Zone Network Addresses for a description of when to set this variable. This name must be the SUNW.LogicalHostname resource name you assigned when you created the resource in Step 4.

FAILOVER=true|false

Specifies whether the zone`s zone path is on a highly available file system.

HAS_RS=sczbt-has-rs

Specifies the name of the SUNW.HAStoragePlus resource for the zone boot resource. This name must be the SUNW.HAStoragePlus resource name you assigned when you created the resource in How to Enable a Zone to Run in a Failover Configuration. You must specify a value for this keyword if FAILOVER=true is set.

Zonename=zone-name

Specifies the zone name. You must specify a value for this keyword.

Zonebootopt=zone-boot-options

Specifies the zone boot option to use. Only -s is supported. Leaving this variable blank will cause the zone to boot to the multi-user-server milestone.

Milestone=zone-boot-milestone

Specifies the milestone the zone must reach to be considered as successfully booted. You must specify a value for this keyword.

Mounts=list-of-mountpoints

Specifies a space separated list of directories with their mount options, which will automatically get lofs mounted from the global zone into the booted zone. The mount point used in the global zone can be different to the mount point in the booted zone. Specifying a value for this keyword is optional.

The Mounts keyword format is as follows:


Mounts="/global-zone-dir:/local-zone-dir:mount-options <next entry>"

While mount-options can be a comma separated list of file system mount options.

The only required entry when setting this keyword is the /global-zone-dir part of the colon separated variable. The /local-zone-dir and mount-options part can be omitted.

Omitting the /local-zone-dir part will make the zone`s mount point the same as the global zone directory.

Omitting the mount-options part will not provide any mount options except the default options from the mount command.


Note –

You must manually create any mount point directories within the booted zone that will be used within the Mounts keyword, before registering this resource within Sun Cluster.



Note –

If the file system of the source mount point in the global zone is mounted by a SUNW.HAStoragePlus resource, you must specify a strong resource dependency from the sczbt resource to this SUNW.HAStoragePlus resource.



Example 1 Sample sczbt_config File

This example shows an sczbt_config file in which configuration parameters are set as follows:

RS=zone1-rs
RG=zone1-rg
PARAMETERDIR=/global/zones/pfiles
SC_NETWORK=true
SC_LH=zone1-lh
FAILOVER=true
HAS_RS=zone1-has
Zonename=zone1
Zonebootopt=
Milestone=multi-user-server
Mounts="/global/app/bin:/app/bin:ro /app/data:rw /logs"

Writing Scripts for the Zone Script Resource

The zone script resource provides the ability to run commands or scripts to start, stop and probe an application within a zone. The zone script resource depends on the zone boot resource. The command or script names are passed to the zone script resource when the resource is registered and must meet with the following requirements.

Table 3 Return codes

Successful completion 

>0  

An error has occurred 

201 

(Probe only) — An error has occurred that requires an immediate failover of the resource group 

>0 & !=201 

(Probe only) — An error has occurred that requires a resource restart 


Note –

For an immediate failover of the zone script resource, you must configure the resource properties Failover_mode and Failover_enabled to meet the required behavior. Refer to the r_properties(5) man page when setting the Failover_mode property and SUNW.gds(5) man page when setting the Failover_enabled property.



Example 2 Zone Probe Script for Apache2

This example shows a simple script to test that the Apache2 service is running, beyond the process tree existing. The script /var/tmp/probe-apache2 must exist and being executable within the zone.


# cat /var/tmp/probe-apache2
#!/usr/bin/ksh
if echo "GET; exit" | mconnect -p 80 > /dev/null 2>&1
then
	exit 0
else
	exit 100
fi

# chmod 755 /var/tmp/probe-apache2

Specifying Configuration Parameters for the Zone Script Resource

Sun Cluster HA for Solaris Containers provides the script sczsh_register, which automates the process of configuring zone script resource. By default this script obtains configuration parameters from the sczsh_config file in the /opt/SUNWsczone/sczsh/util directory. To specify configuration parameters for the zone script resource, copy the sczsh_config file to a different filename and amend it as desribed below. It is recommended to keep this file as a future reference. The register script provides option -f to specify the fully qualified filename to the copied configuration file.

Each configuration parameter in the sczsh_config file is defined as a keyword-value pair. The sczsh_config file already contains the required keywords and equals signs. For more information, see Listing of sczsh_config. When you edit the sczsh_config file, add the required value to each keyword.

The keyword-value pairs in the sczsh_config file are as follows:

RS=sczsh-rs
RG=sczbt-rg
SCZBT_RS=sczbt-rs
PARAMETERDIR=sczsh-parameter-directory
Zonename=sczbt-zone-name
ServiceStartCommand=sczsh-start-command
ServiceStopCommand=sczsh-stop-command
ServiceProbeCommand=sczsh-probe-command

The meaning and permitted values of the keywords in the sczsh_config file are as follows:

RS=sczsh-rs

Specifies the name that you are assigning to the zone script resource. You must specify a value for this keyword.

RG=sczbt-rg

Specifies the name of the resource group the zone boot resource resides in. You must specify a value for this keyword.

SCZBT_RS=sczbt-rs

Specifies the name of the zone boot resource. You must specify a value for this keyword.

PARAMETERDIR=sczsh parameter directory

Specifies the directory name that you are assigning to the parameter directory where the following variables and their values will be stored. You must specify a value for this keyword.

Zonename=sczbt-zone-name

Specifies the zone name. You must specify a value for this keyword.

ServiceStartCommand=sczsh-start-command

Specifies the zone start command or script to run. You must specify a value for this keyword.

ServiceStopCommand=sczsh-stop-command

Specifies the zone stop command or script to run. You must specify a value for this keyword

ServiceProbeCommand=sczsh-probe-command

Specifies the zone probe command or script to run. You must specify a value for this keyword


Example 3 Sample sczsh_config File

In this example the zone script resource uses the Apache2 scripts that are available in Solaris 10. Before this example can be used the Apache2 configuration file http.conf needs to be configured. For the purpose of this example, the delivered http.conf-example can be used. Copy the file as follows:


# zlogin zone1
# cd /etc/apache2
# cp http.conf-example http.conf
# exit

This example shows an sczsh_config file in which configuration parameters are set as follows:

RS="zone1-script-rs"
RG="zone1-rg"
SCZBT_RS="zone1-rs"
PARAMETERDIR="/global/zones/pfiles"
Zonename="zone1"
ServiceStartCommand="/lib/svc/method/http-apache2 start"
ServiceStopCommand="/lib/svc/method/http-apache2 stop"
ServiceProbeCommand="/var/tmp/probe-apache2"

Writing a Service Probe for the Zone SMF Resource

The zone SMF resource provides the ability to enable, disable and probe a SMF service within a zone. The zone SMF resource depends on the zone boot resource. Probing the SMF service is performed by running a command or script against the SMF service. The SMF service and probe command or script names are passed to the zone SMF resource when the resource is registered. The probe command or script must meet to the following requirements.

Table 4 Return codes

Successful completion 

100  

An error occurred that requires a resource restart 

201 

An error has occurred that requires an immediate failover of the resource group 


Note –

For an immediate failover of the zone SMF resource, you must configure the resource properties Failover_mode and Failover_enabled to meet the required behavior. Refer to the r_properties(5) man page when setting the Failover_mode property and SUNW.gds(5) man page when setting the Failover_enabled property.



Example 4 Zone SMF Probe Script for Apache2

This example shows a simple script to test that the SMF Apache2 service is running, beyond the process tree existing. The script /var/tmp/probe-apache2 must exist and being executable within the zone.


# cat /var/tmp/probe-apache2
#!/usr/bin/ksh
if echo "GET; exit" | mconnect -p 80 > /dev/null 2>&1
then
	exit 0
else
	exit 100
fi

# chmod 755 /var/tmp/probe-apache2

Specifying Configuration Parameters for the Zone SMF Resource

Sun Cluster HA for Solaris Containers provides the script sczsmf_register, which automates the process of configuring the zone SMF resource. By default this script obtains configuration parameters from the sczsmf_config file in the /opt/SUNWsczone/sczsmf/util directory. To specify configuration parameters for the zone SMF resource, copy the sczsmf_config file to a different filename and amend it as described below. It is recommended to keep this file as a future reference. The register script provides option -f to specify the fully qualified filename to the copied configuration file.

Each configuration parameter in the sczmf_config file is defined as a keyword-value pair. The sczsmf_config file already contains the required keywords and equals signs. For more information, see Listing of sczsmf_config. When you edit the sczsmf_config file, add the required value to each keyword.

The keyword-value pairs in the sczsmf_config file are as follows:

RS=sczsmf-rs
RG=sczbt-rg
SCZBT_RS=sczbt-rs
ZONE=sczbt-zone-name
SERVICE=smf-service
RECURSIVE=true|false
STATE=true|false
SERVICE_PROBE=sczsmf-service-probe

The meaning and permitted values of the keywords in the sczsmf_config file are as follows:

RS=sczsmf-rs

Specifies the name that you are assigning to the zone SMF resource. This must be defined.

RG=sczbt-rg

Specifies the name of the resource group the zone boot resource resides in. This must be defined.

SCZBT_RS=sczbt-rs

Specifies the name of the zone boot resource. You must specify a value for this keyword.

ZONE=sczbt-zone-name

Specifies the zone name. This must be defined.

SERVICE=smf-service

Specifies the SMF service to enable/disable. This must be defined.

RECURSIVE=true|false

Specifies true to enable the service recursively or false to just enable the service and no dependents. This must be defined.

STATE=true|false

Specifies true to wait until the service state is reached or false to not wait until the service state is reached. This must be defined.

SERVICE_PROBE=sczsmf-service-probe

Specify the script to check the SMF service. Specifying a value for this keyword is optional.


Example 5 Sample sczsmf_config File

In this example the zone SMF resource uses the Apache2 SMF service that is available in Solaris 10. Before this example can be used the Apache2 configuration file http.conf needs to be configured. For the purpose of this example, the delivered http.conf-example can be used. Copy the file as follows:


# zlogin zone1
# cd /etc/apache2
# cp http.conf-example http.conf
# exit

This example shows an sczsmf_config file in which configuration parameters are set as follows:

RS=zone1-smf-rs
RG=zone1-rg
SCZBT_RS=zone1-rs
ZONE=zone1
SERVICE=apache2
RECURSIVE=true
STATE=true
SERVICE_PROBE=/var/tmp/probe-apache2

ProcedureHow to Create and Enable Resources for the Zone Boot Component

Before You Begin

Ensure you have edited the sczbt_config file or a copy of it to specify configuration parameters for the Sun Cluster HA for Solaris Containers zone boot component. For more information, see Specifying Configuration Parameters for the Zone Boot Resource.

  1. Become superuser on one of the nodes in the cluster that will host the zone.

  2. Register the SUNW.gds resource type.


    # clresourcetype register SUNW.gds
    
  3. Go to the directory that contains the script for creating the Sun Cluster HA for Solaris Containers boot resource.


    # cd /opt/SUNWsczone/sczbt/util
    
  4. Run the script that creates the zone boot resource.


    # ./sczbt_register -f /mypath/sczbt_config
    
  5. Bring online the zone boot resource.


    # clresource enable sczbt-rs
    

ProcedureHow to Create and Enable Resources for the Zone Script Component

Before You Begin

Ensure you have edited the sczsh_config file or a copy of it to specify configuration parameters for the Sun Cluster HA for Solaris Containers zone script component. For more information, see Specifying Configuration Parameters for the Zone Script Resource.

  1. Go to the directory that contains the script for creating the Sun Cluster HA for Solaris Containers script resource.


    # cd /opt/SUNWsczone/sczsh/util
    
  2. Run the script that creates the zone script resource.


    # ./sczsh_register -f /mypath/sczsh_config
    
  3. Bring online the zone script resource.


    # clresource enable sczsh-rs
    

ProcedureHow to Create and Enable Resources for the Zone SMF Component

Before You Begin

Ensure you have edited the sczsmf_config file or a copy of it to specify configuration parameters for the Sun Cluster HA for Solaris Containers zone SMF component. For more information, see Specifying Configuration Parameters for the Zone SMF Resource.

  1. Go to the directory that contains the script for creating the Sun Cluster HA for Solaris Containers SMF resource.


    # cd /opt/SUNWsczone/sczsmf/util
    
  2. Run the script that creates the zone SMF resource.


    # ./sczsmf_register -f /mypath/sczsmf_config
    
  3. Bring online the zone SMF resource.


    # clresource enable sczsmf-rs