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.
To configure MySQL to use the cluster enabled NSS file system partition, do the following
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.
Create an eDirectory™ user named mysql1 by executing the following command:
namuseradd -x o=user_context -g cn=admingroup,o=user_context mysql1
Prepare MySQL service to use the shared volume.
Create the required directories in the NSS volume by executing the following commands:
mkdir /media/nss/NSSVOL/mysql
mkdir /media/nss/NSSVOL/mysql/data
Copy the \etc\my.cnf configuration file to /media/nss/NSSVOL/mysql.
Edit the /media/nss/NSSVOL/mysql/my.cnf file and comment out the following entry:
datadir=
Make the my.cnf read-only file using the following command:
attrib -s=ro,ex /media/nss/NSSVOL/mysql/my.cnf
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
Execute the following commands as a root user:
chown -R mysql1 /usr/share/mysql
chown -R mysql1 /var/lib/mysql
(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
Go to
, 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
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.
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.
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.
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
Edit the /mnt/mysql/my.cnf file and comment out the following entry:
datadir=
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
Go to
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.