Sun Cluster Data Service for MySQL Guide for Solaris OS

Registering and Configuring Sun Cluster HA for MySQL

This section contains the procedures you need to configure Sun Cluster HA for MySQL.

How to Register and Configure Sun Cluster HA for MySQL as a Failover 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 Using the scsintall Utility.

  1. Become superuser on one of the nodes in the cluster that will host MySQL.

  2. Register the SUNW.gdsresource type.


    # scrgadm -a -t SUNW.gds
    
  3. Register the SUNW.HAStoragePlus resource type.


    # scrgadm -a -t SUNW.HAStoragePlus
    
  4. Create a failover resource group.


    # scrgadm -a -g MySQL-failover-resource-group
    
  5. 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
    
  6. Create a resource for the MySQL Logical Hostname.


    # scrgadm -a -L -j MySQL-lh-resource  \
    -g MySQL-failover-resource-group  \
    -l MySQL-logical-hostname
    
  7. Enable the failover resource group that now includes the MySQL Disk Storage and Logical Hostname resources.


    # scswitch -Z -g MySQL-failover-resource-group
    

    Note –

    Make sure that the resource group is enabled on the same node as what was used when mysql_install_db was executed.


  8. 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 &
    
  9. Configure the admin password for the adminuser.


    # <MySQL Databasedirectry>/bin/mysqladmin -S /tmp/<Logical host>.sock password 'admin password'
    
  10. 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:


    # 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=""

    Note –

    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"
    

    Note –

    If SC3.0U3 is being used, omitt the MYSQL_NIC_HOSTNAME parameter.


    After editing mysql_config you must run the mysql_register script.


    # ./mysql_register
    
  11. Stop the MySQL Server instance manually.


    # kill -TERM `cat <MySQL Databasedirectry>/mysqld.pid
    
  12. 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
    
  13. Enable each MySQL resource.

    Repeat this step for each MySQL instance, if multiple instances were created.


    # scstat -g
    # scswitch -e -j MySQL-resource
    
  14. Add adminuser for accessing locally a MySQL instance with a MySQL Logicalhost.


    Note –

    If you want to access the MySQL instance only through the socket (localhost), omit this step.


    When bootstraping MySQL the command mysql_install_db will create two adminusers, one belonging to localhost and one belonging to the node on which mysql_install_db was executed.

    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 you are using SC3.1, add a adminuser for every physical-node in the cluster that will run this MySQL instance.


    Note –

    If the nodename and the hostname for the physical interface are different, use the hostname for the physical interface.


    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;

    Note –

    You have to manually add Grant_priv to the admin users. See MySQL Administration documentation.