MCSG: Creating packages checklist

Title:

MCSG: Creating packages checklist

Author:

Douglas O’Leary <dkoleary@olearycomputers.com>

Description:

MCSG: Creating packages checklist

Date created:

06/2007

Date updated:

10/02/2015

Disclaimer:

Standard: Use the information that follows at your own risk. If you screw up a system, don’t blame it on me…

Creating complex packages will take a lot of planning, time, and debugging effort. The checklist below describes the general process and commands needed to develop a package. The devil, as they say, is in the details.

  1. Create a package directory on all primary and adoptive nodes:

    mkdir /etc/cmcluster/${pkg}
    
  2. Create a package configuration file:

    cmmakepkg -p ${config}.
    
  3. Edit the package configuration file, supplying:

    1. Package name.

    2. Primary and adoptive nodes.

    3. Run/halt script names.

    4. Service names (NOTE: Ensure service names are single words without enclosing quotes!)

  4. Create the run/halt script as ID’ed within the configuration script:

    cmmakepkg -s ${script}
    
  5. Edit the run/halt script supplying:

    1. Volume groups which need to be activated.

    2. Filesystem information

      1. Logical volume device file

      2. Mount point

      3. Filesystem mount options

    3. Relocatable IP address information.

    4. Commands needed to start the application in customer_defined_run_cmds

    5. Commands needed to stop the application in customer_defined_halt_cmds

    6. Service information

  6. Copy the config and run/halt script to all adoptive nodes.

  7. Check the package configuration:

    cmcheckconf -P ${config}
    
  8. Apply the configuration:

    cmapplyconf -P ${config}
    

The above is for legacy packages. As of MCSG 11.18, the paradigm is to use modular packages. For me, those take a little getting used to. I’ve set up so many legacy packages that I can literaly do it in my sleep. That being said, having done a few of the modular ones now, I can see where it could be a little easier, particularly for people that don’t do a lot of scripting.

Down and dirty: more details to follow. To create the package template:

cd /etc/cmcluster/${pkg}
cmmakepkg \
        -m sg/failover \
        -m sg/package_ip \
        -m sg/volume_group \
        -m sg/external \
        -m sg/pev ${pkg}.conf

That creates the package template for a failover package with IP, volume group, external and pev modules. Notice no filesystem module. I still think package fstab files are the way to go even with the modular packages - although some of the more heinous formatting has been eliminated with the new style. In your external script, add two functions as follows:

NOTE: (10/02/2015) Not 100% sure this works… I worked an modular MCSG install for a client a few years back and wasn’t able to get the package fstab file working. Had to revert back to the normal style. Package fstab files, on the surface, really should be the way to go, though.

function mount_filesystems
{

   grep -v ^# ${Fstab} | sort -k 2 | while read lv mp type args a b
   do
      sg_log 0 "Mounting ${lv} @ ${mp}"
      mount -F ${type} -o ${args} ${lv} ${mp}
   done
}

function umount_filesystems
{
   grep -v ^# ${Fstab} | sort -r -k 2 | while read lv mp type args a b
   do
      sg_log 0 "Umounting ${lv} from ${mp}"
      umount ${mp}
   done
}

Then, in your [start|stop]_command, just call the function.

function start_command
{

    sg_log 5 "start_command"

   Debug=/etc/cmcluster/sbox/Debug
   Fstab=/etc/cmcluster/sbox/fstab_sbox
   [[ ! -f ${Fstab} ]] && return 1


   mount_filesystems ${Fstab}

And:

function stop_command
{

   Fstab=/etc/cmcluster/sbox/fstab_sbox
   sg_log 5 "stop_command"

[[ snip ]]

   umount_filesystems ${Fstab}
   return 0
}

This still leaves any filesystem manipulation outside of the package script which means no package failure if there’s a typo and, certainly, more SA familiaritity with the fstab format than are familiar with the package template - particularly these modular ones…