MySQL databases are usually located in a subdirectory of the /var/lib/mysql/ directory. If you create a database named test, the database files are located in the /var/lib/mysql/test directory.
In order for MySQL to take advantage of the benefits provided by Novell Cluster Services, you must make some configuration changes to MySQL. On the first server, you copy the default MySQL configuration file (/etc/my.cnf) to the LVM logical volume, modify /mnt/mysql/var/lib/mysql/my.cnf file so that all datadir entries are commented out, then create a MySQL database on the LVM Logical volume.
The following instructions assume that you have not created a database on the server at this time. If a MySQL database currently exists in the default /var/lib/mysql location, the database’s directory and its contents must be relocated to the new /mnt/mysql/var/lib/mysql path, rather than creating it as described in Step 6 of the following procedure. Afterwards, ensure that you modify the ownership of the folder and files to the mysql user and group by using the chown command as illustrated in Step 13 of Section 14.3, Creating an LVM Volume Group and Logical Volume.
IMPORTANT:After you have modified the MySQL configuration file to use the LVM logical volume path, you should always exclusively activate the volume group on the server before attempting to start the MySQL daemon. The cluster resource does this automatically in the load script.
To configure a MySQL database on the LVM logical volume:
Log in as the Linux root user on the first node, then open a file browser or terminal console.
Copy the default /etc/my.cnf configuration file to the /mnt/mysql/var/lib/mysql directory:
cp /etc/my.cnf /mnt/mysql/var/lib/mysql
In a text editor, modify the /mnt/mysql/var/lib/mysql/my.cnf file and comment out any data directory entries, then save your changes. For example:
Change the permissions on the /mnt/mysql/var/lib/mysql/my.cnf file to Read and Execute for each permission level, and change the ownership to the mysql user and group:
chmod 555 /mnt/mysql/var/lib/mysql/my.cnf
chown mysql:mysql /mnt/mysql/var/lib/mysql/my.cnf
You can view these settings by using the ll <filepath> command. For example:
ll /mnt/mysql/var/lib/mysql/my.cnf -r-xr-xr-x 1 mysql mysql 6297 2011-07-08 14:19 /mnt/mysql/var/lib/mysql/my.cnf
Open a terminal console as the Linux root user, then start MySQL:
Another option is to use the rcmysql start command.
Create a database named data on the LVM logical volume:
mysql_install_db --datadir=/mnt/mysql/var/lib/mysql/data --user=mysql
Set the ownership of the data database to be the mysql user and group:
chown -R mysql:mysql /mnt/mysql/var/lib/mysql/data
Stop the MySQL daemon from running:
Another option is to use the rcmysql stop command.
Deactivate the LVM volume group:
vgchange -a n <vg_name>
vgchange -a n mysqlvg
Continue with Section 14.5, Cluster-Enabling MySQL on the Logical Volume.