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. According to your zone type yo need to complete either one of the following tasks.

ProcedureHow to Register and Configure Sun Cluster HA for MySQL as a Failover Service in a Global Zone Configuration

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 Installing the Sun Cluster HA for MySQL Packages.

  1. Become superuser or assume a role that provides solaris.cluster.verb RBAC authorization on the node in the cluster that host MySQL.

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


    # <MySQL Databasedirectry>/bin/mysqladmin \
    -S /tmp/<Logical host>.sock password 'admin password'
    
  4. Copy the MySQL configuration files to your private place.


    # cp /opt/SUNWscmys/util/ha_mysql_config /my-place
    # cp /opt/SUNWscmys/util/mysql_config /my-place
    
  5. Create a faultmonitor-user and a test-database for the MySQL instance.


    # cd my-place
    

    Edit the mysql_config file and follow the comments within that file:


    #
    # Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
    # Use is subject to license terms.
    #
    
    #ident   "@(#)mysql_config.ksh 1.3     06/03/08 SMI"
    
    # 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
    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 the
    # 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-hme0 and
    # for hme3 on phys-2 it is phys-2-hme3.
    # IE: MYSQL_NIC_HOSTNAME="phys-1-hme0 phys-2-hme3"
    MYSQL_NIC_HOSTNAME=

    Note –

    The following is an example for MySQL instance on SC3.2.



    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"
    

    After editing mysql_config you must run the mysql_register script.


    # /opt/SUNWscmys/util//mysql_register -f my-place/mysql_config
    
  6. Stop the MySQL Server instance manually.


    # kill -TERM `cat <MySQL Databasedirectry>/mysqld.pid
    
  7. Create and register MySQL as a failover data service.


    # cd my-place
    

    Edit the ha_mysql_config file and follow the comments within that file, i.e.


    #
    # Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
    # Use is subject to license terms.
    #
    
    #ident   "@(#)ha_mysql_config.ksh 1.3     06/03/08 SMI"
    
    # This file will be sourced in by ha_mysql_register and the parameters
    # listed below will be used.
    #
    # 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
    #
    #        To have the mysql agent local zone aware, 4 Variables are needed:
    #      ZONE - the zone name where the Mysql Database should run in
    #             Optional
    #    ZONEBT - The resource name which controls the zone.
    #             Optional
    #   PROJECT - A project in the zone, that will be used for this service
    #             specify it if you have an su - in the start stop or probe,
    #             or to define the smf credentials. If the variable is not set,
    #             it will be translated as :default for the sm and default
    #             for the zsh component
    #             Optional
    #     ZUSER - A user in the the zone which is used for the smf method
    #             credentials. Yur smf servic e will run under this user
    #             Optional
    #
    # Mysql specific Variables
    #
    #   BASEDIR - name of the Mysql bin directory
    #   DATADIR - name of the Mysql Data directory
    # MYSQLUSER - name of the user Mysql should be started of
    #        LH - name of the LogicalHostname SC resource
    # MYSQLHOST - name of the host in /etc/hosts
    #    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
    MYSQLHOST=hahostix1
    FMUSER=fmuser
    FMPASS=fmuser
    LOGDIR=/global/mysql-data/logs
    CHECK=YES 
    HAS_RS=mysql-has-res
    ZONE=
    ZONE_BT=
    PROJECT=

    Register the MySQL resource.


    # /opt/SUNWscmys/util/ha_mysql_register -f my-place/ha_mysql_config
    
  8. Enable each MySQL resource.

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


    # clresource status
    # clresource enable MySQL-resource
    
  9. Add adminuser for accessing locally a MySQL instance with a MySQL Logicalhost ip name.


    Note –

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


    When bootstrapping 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.

    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.2.


    # 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.


ProcedureHow to Register and Configure Sun Cluster HA for MySQL as a Failover Service in a Zone Configuration

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 Installing the Sun Cluster HA for MySQL Packages.

  1. Log in to the zone on the node that hosts yourMySQLresource-group

  2. Become superuser or assume a role that provides solaris.cluster.verb RBAC authorization on the nodes zone in the cluster that host MySQL.

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


    # <MySQL Databasedirectry>/bin/mysqladmin \
    -S /tmp/<Logical host>.sock password 'admin password'
    
  5. Copy the MySQL configuration file to your private place.


    # cp /opt/SUNWscmys/util/mysql_config /my-place
    
  6. Create a faultmonitor-user and a test-database for the MySQL instance.


    # cd my-place
    

    Edit the mysql_config file and follow the comments within that file:


    #
    # Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
    # Use is subject to license terms.
    #
    
    #ident   "@(#)mysql_config.ksh 1.3     06/03/08 SMI"
    
    # 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
    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 the
    # 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-hme0 and
    # for hme3 on phys-2 it is phys-2-hme3.
    # IE: MYSQL_NIC_HOSTNAME="phys-1-hme0 phys-2-hme3"
    MYSQL_NIC_HOSTNAME=

    Note –

    The following is an example for MySQL instance on SC3.2.



    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="zone1 zone2"
    

    After editing mysql_config you must run the mysql_register script.


    # /opt/SUNWscmys/util//mysql_register -f my-place/mysql_config
    
  7. Stop the MySQL Server instance manually.


    # kill -TERM `cat <MySQL Databasedirectry>/mysqld.pid
    
  8. Leave the zone and become superuser or assume a role that provides solaris.cluster.verb RBAC authorization on the nodes global zone in the cluster that host MySQL.

  9. Copy the MySQL configuration file to your private place.


    # cp /opt/SUNWscmys/util/ha_mysql_config /my-place
    
  10. Create and register MySQL as a failover data service.


    # cd my-place
    

    Edit the ha_mysql_config file and follow the comments within that file, i.e.


    #
    # Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
    # Use is subject to license terms.
    #
    
    #ident   "@(#)ha_mysql_config.ksh 1.3     06/03/08 SMI"
    
    # This file will be sourced in by ha_mysql_register and the parameters
    # listed below will be used.
    #
    # 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
    #
    #        To have the mysql agent local zone aware, 4 Variables are needed:
    #      ZONE - the zone name where the Mysql Database should run in
    #             Optional
    #    ZONEBT - The resource name which controls the zone.
    #             Optional
    #   PROJECT - A project in the zone, that will be used for this service
    #             specify it if you have an su - in the start stop or probe,
    #             or to define the smf credentials. If the variable is not set,
    #             it will be translated as :default for the sm and default
    #             for the zsh component
    #             Optional
    #     ZUSER - A user in the the zone which is used for the smf method
    #             credentials. Yur smf servic e will run under this user
    #             Optional
    #
    # Mysql specific Variables
    #
    #   BASEDIR - name of the Mysql bin directory
    #   DATADIR - name of the Mysql Data directory
    # MYSQLUSER - name of the user Mysql should be started of
    #        LH - name of the LogicalHostname SC resource
    # MYSQLHOST - name of the host in /etc/hosts
    #    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
    MYSQLHOST=hahostix1
    FMUSER=fmuser
    FMPASS=fmuser
    LOGDIR=/global/mysql-data/logs
    CHECK=YES 
    HAS_RS=mysql-has-res
    ZONE=
    ZONE_BT=
    PROJECT=

    Register the MySQL resource.


    # /opt/SUNWscmys/util/ha_mysql_register -f my-place/ha_mysql_config
    
  11. Enable each MySQL resource.

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


    # clresource status
    # clresource enable MySQL-resource
    
  12. Add adminuser for accessing locally a MySQL instance with a MySQL Logicalhost ip name.


    Note –

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


    When bootstrapping 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.

    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.2.


    # mysql -S /tmp/hahostix1.sock -uroot
    mysql> use mysql;
    mysql> mysql> GRANT ALL ON *.* TO 'root'@'zone1' IDENTIFIED BY 'rootpasswd';
    mysql> mysql> GRANT ALL ON *.* TO 'root'@'zone2' IDENTIFIED BY 'rootpasswd';
    mysql> exit;

    Note –

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


ProcedureHow to Register and Configure Sun Cluster HA for MySQL as a Failover Service in a Failover Zone Configuration

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 Installing the Sun Cluster HA for MySQL Packages.

  1. Log in to the zone on the node that hosts yourMySQLresource-group

  2. Become superuser or assume a role that provides solaris.cluster.verb RBAC authorization on the nodes zone in the cluster that host MySQL.

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


    # <MySQL Databasedirectry>/bin/mysqladmin \
    -S /tmp/<Logical host>.sock password 'admin password'
    
  5. Copy the MySQL configuration file to your private place.


    # cp /opt/SUNWscmys/util/mysql_config /my-place
    
  6. Create a faultmonitor-user and a test-database for the MySQL instance.


    # cd my-place
    

    Edit the mysql_config file and follow the comments within that file:


    #
    # Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
    # Use is subject to license terms.
    #
    
    #ident   "@(#)mysql_config.ksh 1.3     06/03/08 SMI"
    
    # 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
    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 the
    # 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-hme0 and
    # for hme3 on phys-2 it is phys-2-hme3.
    # IE: MYSQL_NIC_HOSTNAME="phys-1-hme0 phys-2-hme3"
    MYSQL_NIC_HOSTNAME=

    Note –

    The following is an example for MySQL instance on SC3.2.



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

    After editing mysql_config you must run the mysql_register script.


    # /opt/SUNWscmys/util//mysql_register -f my-place/mysql_config
    
  7. Stop the MySQL Server instance manually.


    # kill -TERM `cat <MySQL Databasedirectry>/mysqld.pid
    
  8. Leave the zone and become superuser or assume a role that provides solaris.cluster.verb RBAC authorization on the nodes global zone in the cluster that host MySQL.

  9. Copy the MySQL configuration file to your private place.


    # cp /opt/SUNWscmys/util/ha_mysql_config /my-place
    
  10. Create and register MySQL as a failover data service.


    # cd my-place
    

    Edit the ha_mysql_config file and follow the comments within that file, i.e.


    #
    # Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
    # Use is subject to license terms.
    #
    
    #ident   "@(#)ha_mysql_config.ksh 1.3     06/03/08 SMI"
    
    # This file will be sourced in by ha_mysql_register and the parameters
    # listed below will be used.
    #
    # 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
    #
    #        To have the mysql agent local zone aware, 4 Variables are needed:
    #      ZONE - the zone name where the Mysql Database should run in
    #             Optional
    #    ZONEBT - The resource name which controls the zone.
    #             Optional
    #   PROJECT - A project in the zone, that will be used for this service
    #             specify it if you have an su - in the start stop or probe,
    #             or to define the smf credentials. If the variable is not set,
    #             it will be translated as :default for the sm and default
    #             for the zsh component
    #             Optional
    #     ZUSER - A user in the the zone which is used for the smf method
    #             credentials. Yur smf servic e will run under this user
    #             Optional
    #
    # Mysql specific Variables
    #
    #   BASEDIR - name of the Mysql bin directory
    #   DATADIR - name of the Mysql Data directory
    # MYSQLUSER - name of the user Mysql should be started of
    #        LH - name of the LogicalHostname SC resource
    # MYSQLHOST - name of the host in /etc/hosts
    #    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
    MYSQLHOST=hahostix1
    FMUSER=fmuser
    FMPASS=fmuser
    LOGDIR=/global/mysql-data/logs
    CHECK=YES 
    HAS_RS=mysql-has-res
    ZONE=zone1
    ZONE_BT=zone1-rs
    PROJECT=MySQL-project
    

    Register the MySQL resource.


    # /opt/SUNWscmys/util/ha_mysql_register -f my-place/ha_mysql_config
    
  11. Enable each MySQL resource.

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


    # clresource status
    # clresource enable MySQL-resource
    
  12. Add adminuser for accessing locally a MySQL instance with a MySQL Logicalhost ip name.


    Note –

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


    When bootstrapping 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.

    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.2.


    # mysql -S /tmp/hahostix1.sock -uroot
    mysql> use mysql;
    mysql> mysql> GRANT ALL ON *.* TO 'root'@'zone1' IDENTIFIED BY 'rootpasswd';
    mysql> exit;

    Note –

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


ProcedureHow to Modify Parameters in the Sun Cluster HA for MySQL Manifest

Perform this task to change parameters in the Sun Cluster HA for MySQL manifest and to validate the parameters in the failover zone. Parameters for the Sun Cluster HA for MySQL manifest are stored as properties of the SMF service. To modify parameters in the manifest, change the related properties in the SMF service then validate the parameter changes.

  1. Become superuser or assume a role that provides solaris.cluster.modify and solaris.cluster.admin RBAC authorizations on the zones console.

  2. Change the Solaris Service Managemet Facility (SMF) properties for the Sun Cluster HA for MySQL manifest.


    # svccfg svc:/application/sczone-agents:resource
    

    For more information, see the svccfg(1M) man page.

  3. Validate the parameter changes.


    # /opt/SUNWsctomcat/bin/control_mysql validate resource
    

    Messages for this command are stored in the /var/adm/messages/ directory of the failover zone.

  4. Disconnect from the failover zone's console.

ProcedureHow to Remove a Sun Cluster HA for MySQL Resource From a Failover Zone

  1. Become superuser or assume a role that provides solaris.cluster.modify and solaris.cluster.admin RBAC authorizations.

  2. Disable and remove the resource that is used by the Sun Cluster HA for MySQL data service.


    # clresource disable resource
    # clresource delete resource
    
  3. Log in as superuser to the failover zone's console.

  4. Unregister Sun Cluster HA for MySQL from the Solaris Service Managemet Facility (SMF) service.


    # /opt/SUNWscmys/util/ha_mysql_smf_remove -f filename
    
    -f

    Specifies the configuration file name.

    filename

    The name of the configuration file that you used to register Sun Cluster HA for MySQL with the SMF service.


    Note –

    If you no longer have the configuration file that you used to register Sun Cluster HA for MySQL with the SMF service, create a replacement configuration file:

    1. Make a copy of the default file, /opt/SUNWscmys/util/ha_mysql_config.

    2. Set the ZONE and RS parameters with the values that are used by the data service.

    3. Run the ha_mysql_smf_remove command and use the -f option to specify this configuration file.


  5. Disconnect from the failover zone's console.