This procedure assumes that you installed the data service packages during your initial Oracle Solaris Cluster installation.
If you did not install the HA for MySQL packages as part of your initial Oracle Solaris Cluster installation, go to Installing the HA for MySQL Package.
# cd MySQL-Base- directory
# ./bin/mysqld --defaults-file=MySQL-Database-directory/my.cnf \ --basedir=MySQL-Base-directory \ --datadir=MySQL-Database-directory \ --user=mysql \ --pid-file=MySQL-Database-directory/mysqld.pid &
# MySQL-Database-directory/bin/mysqladmin \ -S /tmp/logical-host.sock password 'admin-password'
When bootstrapping MySQL the command mysqld --initialize creates two administrative users, one belonging to localhost and one belonging to the node on which mysqld --initialize was executed.
Add an administrative user for every global-cluster node that runs this MySQL instance.
The following is an example for a MySQL instance.
# mysql -S /tmp/hahostix1.sock -uroot -padmin-password mysql> use mysql; mysql> GRANT ALL ON *.* TO 'root'@'clusterix2' IDENTIFIED BY 'rootpasswd'; mysql> GRANT ALL ON *.* TO 'root'@'clusterix1' IDENTIFIED BY 'rootpasswd'; mysql> exit;
The following is an example for a MySQL 4.x instance.
# mysql -S /tmp/hahostix1.sock -uroot -padmin-password mysql> use mysql; mysql> UPDATE user SET Grant_priv='Y' WHERE User='root' AND Host='clusterix1'; mysql> UPDATE user SET Grant_priv='Y' WHERE User='root' AND Host='clusterix2'; mysql> exit;
The following is an example for a MySQL 5.x instance.
# mysql -S /tmp/hahostix1.sock -uroot -padmin-password mysql> use mysql; mysql> GRANT ALL ON *.* TO 'root'@'clusterix2' IDENTIFIED BY 'rootpasswd'; mysql> GRANT ALL ON *.* TO 'root'@'clusterix1' IDENTIFIED BY 'rootpasswd'; mysql> exit;
The following is an example for a MySQL 8.x instance.
# mysql -S /tmp/hahostix1.sock -uroot -padmin-password mysql> use mysql; mysql> CREATE USER 'root'@'clusterix2' IDENTIFIED BY 'rootpasswd'; mysql> CREATE USER 'root'@'clusterix1' IDENTIFIED BY 'rootpasswd'; mysql> GRANT ALL ON *.* TO 'root'@'clusterix2' IDENTIFIED BY 'rootpasswd'; mysql> GRANT ALL ON *.* TO 'root'@'clusterix1' IDENTIFIED BY 'rootpasswd'; mysql> UPDATE user SET Grant_priv='Y' WHERE User='root' AND Host='clusterix1'; mysql> UPDATE user SET Grant_priv='Y' WHERE User='root' AND Host='clusterix2'; mysql> exit;
# cp /opt/SUNWscmys/util/mysql_config /home-dir
# cd home-dir
Edit the mysql_config file and follow the comments within that file.
# # CDDL HEADER START # # The contents of this file are subject to the terms of the # Common Development and Distribution License (the License). # You may not use this file except in compliance with the License. # # You can obtain a copy of the license at usr/src/CDDL.txt # or http://www.opensolaris.org/os/licensing. # See the License for the specific language governing permissions # and limitations under the License. # # When distributing Covered Code, include this CDDL HEADER in each # file and include the License file at usr/src/CDDL.txt. # If applicable, add the following below this CDDL HEADER, with the # fields enclosed by brackets [] replaced with your own identifying # information: Portions Copyright [yyyy] [name of copyright owner] # # CDDL HEADER END # # # Copyright (c) 2006,2012, Oracle and/or its affiliates. All rights reserved. # #ident "@(#)mysql_config.ksh 1.11 12/08/20" # This file will be sourced in by mysql_register and the parameters # listed below will be used. # # Where is mysql installed (BASEDIR) MYSQL_BASE= # MySQL admin-user for localhost (Default is root) MYSQL_USER= # Password for mysql admin user, if you do not want to disclose this passowrd in # a file, leave the MYSQL_PASSWD variable empty, or take it out. MYSQL_PASSWD= # Configured logicalhost. For scalable or multiple-master resources, leave it empty. MYSQL_HOST= # Specify a username for a faultmonitor user FMUSER= # Pick a password for that faultmonitor user, if you do not want to disclose this # password in a file, leave the FMPASS variable empty, or take it out. FMPASS= # Socket name for mysqld ( Should be /tmp/<logical-host>.sock ) MYSQL_SOCK= # Specify the physical hostname for the physical NIC that this logical hostname # belongs to for every node in the cluster this resource group can be located on. # If you use the mysql_geocontrol features to implement the MySQL replication as # the replication protocol in Oracle Solaris Cluster geographic edition, specify all # physical nodes of all clusters. Specify at least all the nodes on both sites # where the MySQL databases can be hosted. # 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-hme0 and # for hme3 on phys-2 it is phys-2-hme3. # IE: MYSQL_NIC_HOSTNAME="phys-1-hme0 phys-2-hme3" # IE: If two clusters are tied together by the mysql_geocontrol features, assuming the # MySQL database on cluster one belongs to cl1-phys1-hme0 and cl1-phys2-hme3, the # MySQL database on cluster two belongs to cl2-phys1-hme2 and cl2-phys2-hme4. Then the # MYSQL_NIC_HOSTNAME variable needs to be set to: # MYSQL_NIC_HOSTNAME="cl1-phys1-hme0 cl1-phys2-hme3 cl2-phys1-hme2 cl2-phys2-hme4" MYSQL_NIC_HOSTNAME= # Where are your databases installed? (location of my.cnf) MYSQL_DATADIR= # Is MySQL Cluster installed? # Any entry here triggers the ndb engine check preparation. If no MySQL cluster should be # checked, leave it empty. NDB_CHECK=
The following is an example for a MySQL instance.
MYSQL_BASE=/global/mysql MYSQL_USER=root MYSQL_PASSWD= MYSQL_HOST=hahostix1 FMUSER=fmuser FMPASS= MYSQL_SOCK=/tmp/hahostix1.sock MYSQL_NIC_HOSTNAME="clusterix1 clusterix2" MYSQL_DATADIR=/global/mysql-data
After editing mysql_config, you must run the mysql_register script.
# /opt/SUNWscmys/util/mysql_register -f home-dir/mysql_config
# kill -TERM `cat MySQL-Database-directry/mysqld.pid
# clpstring create -t resource -b MySQL-resource MySQL-resource
# clresource create -d -g MySQL-failover-resource-group -t ORCL.mysql \ -p Mysql_basedir=MySQL-base-directory \ -p Mysql_datadir=MySQL-databse-directory \ -p Mysql_user=MySQL-OS-User \ -p Mysql_host=MySQL-logical-host \ -p Mysql_fmuser=MySQL-database-faul-monitoring-user \ -p Mysql_logdir=MySQL-database-log-directory \ -p Resource_dependencies=MySQL-logical-host-resource \ -p Resource_dependencies_offline_restart=MySQL-storage-resource \ MySQL-resource
Repeat this step for each MySQL instance, if multiple instances were created.
# clresource status # clresource enable MySQL-resource
The following example encrypts a password for the MySQL-resource resource, then creates and registers the failover resource.
# clpstring create -t resource -b MySQL-resource MySQL-resource # clresource create -d -g MySQL-failover-resource-group \ -t ORCL.mysql \ -p Mysql_basedir=MySQL-base-directory \ -p Mysql_datadir=MySQL-database-directory \ -p Mysql_user=MySQL-OS-user \ -p Mysql_host=MySQL-logical-host \ -p Mysql_fmuser=MySQL-database-fault-monitoring-user \ -p Mysql_logdir=MySQL-database-log-directory \ -p Resource_dependencies=MySQL-logical-host-resource \ -p Resource_dependencies_offline_restart=MySQL-storage-resource \ MySQL-resource