Use this procedure to configure Sun Cluster HA for MySQL as a failover data service. This procedure assumes that you installed the data service packages during your initial Sun Cluster installation.
If you did not install the Sun Cluster HA for MySQL packages as part of your initial Sun Cluster installation, go to How to Install the Sun Cluster HA for MySQL Packages by Using the scsintall Utility.
Otherwise, use this procedure to configure the Sun Cluster HA for MySQL data service as a failover service.
Become superuser on one of the nodes in the cluster that will host MySQL.
Register the SUNW.gds resource type.
# scrgadm -a -t SUNW.gds |
Register the SUNW.HAStoragePlus resource type.
# scrgadm -a -t SUNW.HAStoragePlus |
Create a failover resource group .
# scrgadm -a -g MySQL-failover-resource-group |
Create a resource for the MySQL Disk Storage.
# scrgadm -a -j MySQL-has-resource \ -g MySQL-failover-resource-group \ -t SUNW.HAStoragePlus \ -x FilesystemMountPoints=MySQL- instance-mount-points |
Create a resource for the MySQL Logical Hostname.
# scrgadm -a -L -j MySQL-lh-resource \ -g MySQL-failover-resource-group \ -l MySQL-logical-hostname |
Enable the failover resource group that now includes the MySQL Disk Storage and Logical Hostname resources.
# scswitch -Z -g MySQL-failover-resource-group |
Make sure that the resourcegroup is enabled on the same node as what was used when mysql_install_db was executed.
Start the MySQL Server instance manually
#cd <MySQL Basedirectory> |
# ./bin/mysqld --defaults-file=<MySQL Databasedirectry>/my.cnf \ --basedir=<MySQL Basedirectory>\ --datadir=<MySQL Databasedirectory>\ --user=mysql\ --pid-file=<MySQL Databasedirectory>/mysqld.pid & |
Configure the admin password for the adminuser
# <MySQL Databasedirectry>/bin/mysqladmin -S /tmp/<Logical host>.sock password 'admin password' |
Create faultmonitor-user and a test-database for the MySQL instance
# cd /opt/SUNWscmys/util |
Edit the mysql_config file and follow the comments within that file, ie
# Where is mysql installed (BASEDIR) MYSQL_BASE= # Mysql admin-user for localhost (Should be root) MYSQL_USER= # Password for mysql admin user MYSQL_PASSWD= # Configured logicalhost MYSQL_HOST= # Specify a username for a faultmonitor user FMUSER= # Pick a password for that faultmonitor user FMPASS= # Socket name for mysqld ( Should be /tmp/<Logical host>.sock ) MYSQL_SOCK= # FOR SC3.1 ONLY, Specify the physical hostname for the # physical NIC that this logicalhostname belongs to for every node in th e # cluster this Resourcegroup can located on. # IE: The logicalhost lh1 belongs to hme1 for physical-node phys-1 and # hme3 for physical-node phys-2. The hostname for hme1 is phys-1-hme1 a nd # for hme3 on phys-2 it is phys-2-hme3. # IE: MYSQL_NIC_HOSTNAME="phys-1-hme1 phys-2-hme3" MYSQL_NIC_HOSTNAME="" |
The following is an example for MySQL instance on SC3.1.
MYSQL_BASE=/global/mysql MYSQL_USER=root MYSQL_PASSWD=root MYSQL_HOST=hahostix1 FMUSER=fmuser FMPASS=fmuser MYSQL_SOCK=/tmp/hahostix1.sock MYSQL_NIC_HOSTNAME="clusterix1 clusterix2" |
If SC3.0U3 is being used the MYSQL_NIC_HOSTNAME parameter can be omitted.
After editing mysql_config you must now run the mysql_register script.
# ./mysql_register |
Stop the MySQL Server instance manually
# kill -TERM `cat <MySQL Databasedirectry>/mysqld.pid |
Create and register MySQL as a failover data service
# cd /opt/SUNWscmys/util |
Edit the ha_mysql_config file and follow the comments within that file, i.e.
These parameters can be customized in (key=value) form # # RS - name of the resource for the application # RG - name of the resource group containing RS # BASEDIR - name of the Mysql bin directory # DATADIR - name of the Mysql Data directory # MYSQLUSER - name of the user Mysql should be started with # LH - name of the LogicalHostname SC resource # FMUSER - name of the Mysql fault monitor user # FMPASS - name of the Mysql fault monitor user password # LOGDIR - name of the directory mysqld should store it's logfile. # CHECK - should HA-MySQL check MyISAM index files before start YES/ NO. # HAS_RS - name of the MySQL HAStoragePlus SC resource # |
The following is an example for MySQL instance.
RS=mysql-res RG=mysql-rg BASEDIR=/global/mysql DATADIR=/global/mysql-data MYSQLUSER=mysql LH=hahostix1 FMUSER=fmuser FMPASS=fmuser LOGDIR=/global/mysql-data/logs CHECK=YES HAS_RS=mysql-has-res |
Enable each MySQL resource.
Repeat this step for each MySQL instance, if multiple instances were created.
# scstat -g # scswitch -e -j MySQL-resource |
Add adminuser for accessing locally a MySQL instance with a MySQL Logicalhost.
If you only want to access the MySQL instance through the socket (localhost) this step can be omitted.
When bootstraping MySQL the command mysql_install_db will create two adminusers, one belonging to localhost and one belonging to the node which mysql_install_db was executed on.
If SC3.0U3 is being used you should delete the root user belonging to the physical node and add a adminuser belonging to the logicalhost
The following is an example for MySQL instance on SC3.0U3
# mysql -S /tmp/hahostix1.sock -uroot mysql> use mysql; mysql> DELETE FROM user where User='root' AND Host='clusterix1'; mysql> GRANT ALL ON *.* TO 'root'@'hahostix1' IDENTIFIED BY 'rootpasswd'; mysql> exit; |
If SC3.1 is being used you should add a adminuser for every physical-node in the cluster that will run this MySQL instance.
If the nodename and the hostname for the physical insterface is different then the hostname for the physical interface should be used.
The following is an example for MySQL instance on SC3.1.
# mysql -S /tmp/hahostix1.sock -uroot mysql> use mysql; mysql> mysql> GRANT ALL ON *.* TO 'root'@'clusterix2' IDENTIFIED BY 'rootpasswd'; mysql> mysql> GRANT ALL ON *.* TO 'root'@'clusterix1' IDENTIFIED BY 'rootpasswd'; mysql> exit; |
You have to manually add the Grant_priv to the admin users, See MySQL Administration documentation.