3.3 Configuring MySQL on a OES 2 SP1 Linux Cluster

MySQL on OES 2 SP1 Linux can be configured to run on cluster enabled Linux file system partitions and also on NSS file system partitions.

3.3.1 Configuring MySQL for NSS File System

To configure MySQL to use the cluster enabled NSS file system partition, do the following

  1. Create a NSS shared pool and volume on one of the nodes in the cluster, then specify the shared IP address where MySQL service will run.

    By default, this shared volume is now mounted and available at the server where it was created at /media/nss/NSSVOL where NSSVOL is the shared volume.

  2. Create an eDirectory™ user named mysql1 by executing the following command:

    namuseradd -x o=user_context -g cn=admingroup,o=user_context mysql1

  3. Prepare MySQL service to use the shared volume.

    1. Create the required directories in the NSS volume by executing the following commands:

      mkdir /media/nss/NSSVOL/mysql

      mkdir /media/nss/NSSVOL/mysql/data

    2. Copy the \etc\my.cnf configuration file to /media/nss/NSSVOL/mysql.

    3. Edit the /media/nss/NSSVOL/mysql/my.cnf file and comment out the following entry:

      
      datadir=
      
      
    4. Make the my.cnf read-only file using the following command:

      attrib -s=ro,ex /media/nss/NSSVOL/mysql/my.cnf

    5. Assign appropriate rights to the mysql folder by executing the following command:

      rights -f /media/nss/NSSVOL/mysql -r rwcf trustee mysql1.user_context.treename

    6. Execute the following commands as a root user:

      chown -R mysql1 /usr/share/mysql

      chown -R mysql1 /var/lib/mysql

  4. (Optional) If migrating datadir, skip this step and go to Step 5, otherwise, execute the following:

    mysql_install_db --datadir=/media/nss/NSSVOL/mysql/data --user=mysql1

  5. Go to iManager > Cluster > Cluster Config, then edit the load and unload script for the following cluster volume resource object.

    Load Script :

    The load script specifies the commands to start the MySQL service with the datadir on the shared volume. For example, the modified load script will be similar to the following sample:

    
    #!/bin/bash
    . /opt/novell/ncs/lib/ncsfuncs
    # mount the NSS volume and add secondary IP address
    exit_on_error nss /poolact=NSSPOOL
    exit_on_error ncpcon mount NSSVOL=254
    exit_on_error add_secondary_ipaddress a.b.c.d
    exit_on_error ncpcon bind --ncpservername=TESTCLUST_IPOOL_SERVER --ipaddress=a.b.c.d
    # start the service
    echo "Starting MySQL server ..."
    exit_on_error startproc -v /usr/bin/mysqld_safe --defaults-file=/media
    /nss/NSSVOL/mysql/my.cnf --datadir=/media/nss/NSSVOL/mysql/data --bind-address=a.b.c.d --user=mysql1 > /dev/null 2>&1
    echo "Sucessfully started MySQL server"
    # return status
    exit 0
    
    

    Unload Script :

    The unload script specifies how the application or resource should terminate. For example, the modified unload script will be similar to the following sample

    
    #!/bin/bash
    . /opt/novell/ncs/lib/ncsfuncs
    # stop service
    ignore_error /usr/bin/mysqladmin shutdown --bind-address=a.b.c.d
    -u root -ppassword
    echo "Stopped MySQL server"
    sleep 5
    # delete the IP address and deactivate NSS volume
    ignore_error ncpcon unbind --ncpservername=TESTCLUST_IPOOL_SERVER --ipaddress=a.b.c.d
    ignore_error del_secondary_ipaddress a.b.c.d
    ignore_error nss /pooldeact=IPOOL
    # return status
    exit 0
    
    

    where a.b.c.d = clustered POOL IP address

  6. Bring the resource offline and then bring it online.

MySQL for Linux is now configured to work in the active/passive clustering mode on Linux with its data directory present on a cluster-enabled NSS volume.

3.3.2 Configuring MySQL for Traditional Linux File Systems

The following procedure describes cluster enabling for the REISERFS file system.

You can use the same procedure for EXT2 and EXT3 file systems by replacing the word reiserfs with either ext2 or ext3, as applicable.

  1. Create an REISERFS file system partition of the required size. Do not configure the mount point; leave it blank.If you configure the mount point, an entry is created in fstab and the partition is mounted automatically after the system reboots.

    Use fdisk -l to view the newly created partition. For example, it might be listed as /dev/sdc1.

  2. Execute the following commands on the server where you created the partition:

    mkdir /mnt/mysql

    mount -t reiserfs /dev/sdc1 /mnt/mysql

    cp /etc/my.cnf /mnt/mysql

    mkdir /mnt/mysql/data

  3. Edit the /mnt/mysql/my.cnf file and comment out the following entry:

    
    datadir=
    
    
  4. Execute the following commands:

    chmod 555 /mnt/mysql/my.cnf

    chown -R mysql /mnt/mysql

    mysql_install_db --datadir=/mnt/mysql/data --user=mysql

    chown -R mysql /mnt/mysql/data

  5. Go to iManager > Cluster > Cluster Config and create a cluster resource.

    Edit the load/unload script of the newly created resource object.

    Load Script :

    
    #!/bin/bash
    . /opt/novell/ncs/lib/ncsfuncs
    # mount the file system
    ignore_error mkdir -p /mnt/mysql
    exit_on_error mount -t reiserfs /dev/sdc1 /mnt/mysql
    # add the IP address
    exit_on_error add_secondary_ipaddress a.b.c.d
    # start the service
    chown -R mysql /mnt/mysql
    echo "Starting MySQL server ..."
    exit_on_error startproc -v /usr/bin/mysqld_safe --defaults-file=/mnt/mysql/my.cnf --datadir=/mnt/mysql/data --bind-address=a.b.c.d --socket=/mnt/mysql/mysql.sock --user=mysql > /dev/null 2>&1
    echo "Sucessfully started MySQL server"
    # return status
    exit 0
    
    

    Unload Script :

    
    #!/bin/bash
    . /opt/novell/ncs/lib/ncsfuncs
    # request service stop
    ignore_error /usr/bin/mysqladmin shutdown --socket=/mnt/mysql/mysql.sock
    echo "Stopped MySQL server"
    sleep 5
    # del the IP address
    ignore_error del_secondary_ipaddress a.b.c.d
    # umount the file system
    exit_on_error umount /mnt/mysql
    # return status
    exit 0
    
    

    MySQL for Linux is now configured to work in the active/passive clustering mode on Linux with its data directory present on a cluster-enabled traditional Linux file system.