Sun Cluster Data Service for MySQL Guide for Solaris OS

Installing and Configuring MySQL

This section contains the procedures you need to install and configure MySQL.

References will be made to certain directories for MySQL. The following list shows common pathnames for these references. Refer to Configuration Restrictions where these examples .

Determine how MySQL will be deployed in Sun Cluster –

To install and configure MySQL in a global zone configuration, complete the following tasks:

To install and configure MySQL in a zone configuration, complete the following tasks:

To install and configure MySQL in a failover zone configuration, complete the following tasks:

You will find installation examples for each zone type in:

ProcedureHow to Enable MySQL to run in a Global Zone Configuration

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

  2. Register the SUNW.gds and SUNW.HAStoragePlus resource type.


    # clresourcetype register  SUNW.gds SUNW.HAStoragePlus
    
  3. Create a failover resource group.


    # clresourcegroup create MySQL-failover-resource-group
    
  4. Create a resource for the MySQL Disk Storage.


    # clresource create   \
    -g MySQL-failover-resource-group   \
    -t SUNW.HAStoragePlus  \
    -p FilesystemMountPoints=MySQL- instance-mount-points MySQL-has-resource
    
  5. Create a resource for the MySQL Logical Hostname.


    # clreslogicalhostname   \
    -g MySQL-failover-resource-group  \
    -h MySQL-logical-hostname \
    MySQL-lh-resource
    
  6. Enable the failover resource group that now includes the MySQL Disk Storage and Logical Hostname resources.


    # clresourcegroup online -M -n current-node MySQL-failover-resource-group
    

ProcedureHow to Install and Configure MySQL in a Global Zone

  1. Insure that you are on the node where your enabled your resource group.

  2. Install MySQL onto all nodes within Sun Cluster

    It is recommended that MySQL be installed onto a Global File System. For a discussion of the advantages and disadvantages of installing the software on local versus cluster files systems, see “Determining the Location of the Application Binaries” in the Sun Cluster Data Services Installation and Configuration Guide.

    Download MySQL from http://www.mysql.com — If you intend to use local disks for the MySQL software, you will need to repeat this step on all nodes within Sun Cluster.

  3. Create a mysql-user and mysql-group for MySQL on all nodes in the cluster that will run MySQL

    Create an entry in /etc/group on all nodes with Sun Cluster.


    • # groupadd -g 1000 mysql
      

      Create an entry in /etc/passwd on all nodes within Sun Cluster. This user should have a locked password.


      # useradd -u 1000 -g 1000 -d /global/mysql -s /bin/sh mysql 
      
  4. Change owner and group for MySQL binaries

    If MySQL binaries are on all nodes then repeat this step on every node.


    # chown -R mysql:mysql /global/mysql
    
  5. Create your MySQL Database directory for your MySQL Instance(s).


    # mkdir <MySQL Database directory>
    #

    Note –

    Refer back to Configuration Restrictions for a description of the <MySQL Database directory> and to Installing and Configuring MySQL for a list of common pathnames.


    Shows one MySQL instance. MySQL has been installed from http://www.mysql.com in /global/mysql which is mounted as a Global File System. The MySQL Database Directory for the MySQL instance is /global/mysql-data.


    # cd /global/mysql
    #
    # ls -l
    -rw-r--r--   1 mysql    mysql      19106 Dec 10 14:52 COPYING
    -rw-r--r--   1 mysql    mysql      28003 Dec 10 14:52 COPYING.LIB
    -rw-r--r--   1 mysql    mysql      44577 Dec  5 10:37 ChangeLog
    -rw-r--r--   1 mysql    mysql       6811 Dec 10 14:53 INSTALL-BINARY
    -rw-r--r--   1 mysql    mysql       1976 Dec  5 10:37 README
    drwxr-xr-x   2 mysql    mysql       1024 Dec 13 18:05 bin
    -rwxr-xr-x   1 mysql    mysql        773 Dec 10 15:34 configure
    drwxr-x---   3 mysql    mysql        512 Apr  3 12:23 data
    drwxr-xr-x   2 mysql    mysql       1024 Dec 10 15:35 include
    drwxr-xr-x   2 mysql    mysql        512 Dec 10 15:35 lib
    drwxr-xr-x   2 mysql    mysql        512 Dec 10 15:35 man
    -rw-r--r--   1 mysql    mysql    2582089 Dec 10 14:47 manual.html
    -rw-r--r--   1 mysql    mysql    2239278 Dec 10 14:47 manual.txt
    -rw-r--r--   1 mysql    mysql      94600 Dec 10 14:47 manual_toc.html
    drwxr-xr-x   6 mysql    mysql        512 Dec 10 15:35 mysql-test
    drwxr-xr-x   2 mysql    mysql        512 Dec 10 15:35 scripts
    drwxr-xr-x   3 mysql    mysql        512 Dec 10 15:35 share
    drwxr-xr-x   7 mysql    mysql       1024 Dec 10 15:35 sql-bench
    drwxr-xr-x   2 mysql    mysql        512 Dec 10 15:35 support-files
    drwxr-xr-x   2 mysql    mysql        512 Dec 10 15:35 tests
    #
  6. Create the MySQL my.cnf file according to your requirements — The Sun Cluster HA for MySQL data service provides two sample my.cnf file for MySQL: one sample configuration file is for a master configuration and one sample file is for a slave configuration.


    Note –

    If the Sun Cluster HA for MySQL package (SUNWscmys) was not installed during your initial Sun Cluster installation, proceed to Installing the Sun Cluster HA for MySQL Packages to install it on your cluster. Return here to continue the Installation and Configuration of MySQL.


    The contents of /opt/SUNWscmys/etc/my.cnf_sample_[master|slave]provide a sample MySQL configuration file that you can use to create your MySQL instance <MySQL Databasedirectory>/my.cnf. You must still edit that file to reflect your configuration values.


    # cp /opt/SUNWscmys/etc/my.cnf_sample_master  \
     <MySQL Databasedirectory>/my.cnf  
    
  7. Bootstrap MySQL instance — This will create the privilege tables db, host, user, tables_priv and columns_priv in the mysql database, as well as the func table.


    # cd <MySQL Basedirectory>
    

    # ./scripts/mysql_install_db  \
    --datadir=<MySQL Database directory>
    
  8. Create a logfile directory in <MySQL Database Directory>


    # mkdir <MySQL Database Directory>/logs  
    
  9. Change owner and group for <MySQL Database Directory>


    # chown -R mysql:mysql <MySQL Database Directory>
    
  10. Change file permission for <MySQL Database Directory>/my.cnf


    # chmod 644  <MySQL Database Directory>/my.cnf

ProcedureHow to Enable MySQL to run in a Zone Configuration

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

  2. Create and boot your zone MySQL-zone on all the nodes to host your MySQL data base.

  3. Register the SUNW.gds and SUNW.HAStoragePlus resource type.


    # clresourcetype register  SUNW.gds SUNW.HAStoragePlus
    
  4. Create a failover resource group.


    # clresourcegroup create \
    -n node1:MySQL-zone,node2:MySQL-zone \ 
    MySQL-failover-resource-group
    
  5. Create a resource for the MySQL Disk Storage.


    # clresource create   \
    -g MySQL-failover-resource-group   \
    -t SUNW.HAStoragePlus  \
    -p FilesystemMountPoints=MySQL- instance-mount-points MySQL-has-resource
    
  6. Create a resource for the MySQL Logical Hostname.


    # clreslogicalhostname   \
    -g MySQL-failover-resource-group  \
    -h MySQL-logical-hostname \
    MySQL-lh-resource
    
  7. Enable the failover resource group that now includes the MySQL Disk Storage and Logical Hostname resources.


    # clresourcegroup online -M -n current-node MySQL-failover-resource-group
    

ProcedureHow to Install and Configure MySQL in a Zone

  1. Insure that you are on the node where your enabled your resource group.

  2. Log in to your zone


    # zlogin MySQL-zone
    
  3. Become superuser or assume a role that provides solaris.cluster.verb RBAC authorization on one of the nodes in the cluster that will host MySQL.

  4. Install MySQL onto all nodes within Sun Cluster

    It is recommended that MySQL be installed onto a Global File System. For a discussion of the advantages and disadvantages of installing the software on local versus cluster files systems, see “Determining the Location of the Application Binaries” in the Sun Cluster Data Services Installation and Configuration Guide.

    Download MySQL from http://www.mysql.com — If you intend to use local disks for the MySQL software, you will need to repeat this step on all nodes within Sun Cluster.

  5. Create a mysql-user and mysql-group for MySQL on all nodes:zones in the cluster that will run MySQL

    Create an entry in /etc/group on all nodes with Sun Cluster.


    • # groupadd -g 1000 mysql
      

      Create an entry in /etc/passwd on all nodes within Sun Cluster. This user should have a locked password.


      # useradd -u 1000 -g 1000 -d /global/mysql -s /bin/sh mysql 
      
  6. Change owner and group for MySQL binaries

    If MySQL binaries are on all nodes then repeat this step on every node.


    # chown -R mysql:mysql /global/mysql
    
  7. Create your MySQL Database directory for your MySQL Instance(s).


    # mkdir <MySQL Database directory>
    #

    Note –

    Refer back to Configuration Restrictions for a description of the <MySQL Database directory> and to Installing and Configuring MySQL for a list of common pathnames.


    Shows one MySQL instance. MySQL has been installed from http://www.mysql.com in /global/mysql which is mounted as a Global File System. The MySQL Database Directory for the MySQL instance is /global/mysql-data.


    # cd /global/mysql
    #
    # ls -l
    -rw-r--r--   1 mysql    mysql      19106 Dec 10 14:52 COPYING
    -rw-r--r--   1 mysql    mysql      28003 Dec 10 14:52 COPYING.LIB
    -rw-r--r--   1 mysql    mysql      44577 Dec  5 10:37 ChangeLog
    -rw-r--r--   1 mysql    mysql       6811 Dec 10 14:53 INSTALL-BINARY
    -rw-r--r--   1 mysql    mysql       1976 Dec  5 10:37 README
    drwxr-xr-x   2 mysql    mysql       1024 Dec 13 18:05 bin
    -rwxr-xr-x   1 mysql    mysql        773 Dec 10 15:34 configure
    drwxr-x---   3 mysql    mysql        512 Apr  3 12:23 data
    drwxr-xr-x   2 mysql    mysql       1024 Dec 10 15:35 include
    drwxr-xr-x   2 mysql    mysql        512 Dec 10 15:35 lib
    drwxr-xr-x   2 mysql    mysql        512 Dec 10 15:35 man
    -rw-r--r--   1 mysql    mysql    2582089 Dec 10 14:47 manual.html
    -rw-r--r--   1 mysql    mysql    2239278 Dec 10 14:47 manual.txt
    -rw-r--r--   1 mysql    mysql      94600 Dec 10 14:47 manual_toc.html
    drwxr-xr-x   6 mysql    mysql        512 Dec 10 15:35 mysql-test
    drwxr-xr-x   2 mysql    mysql        512 Dec 10 15:35 scripts
    drwxr-xr-x   3 mysql    mysql        512 Dec 10 15:35 share
    drwxr-xr-x   7 mysql    mysql       1024 Dec 10 15:35 sql-bench
    drwxr-xr-x   2 mysql    mysql        512 Dec 10 15:35 support-files
    drwxr-xr-x   2 mysql    mysql        512 Dec 10 15:35 tests
    #
  8. Create the MySQL my.cnf file according to your requirements — The Sun Cluster HA for MySQL data service provides two sample my.cnf file for MySQL: one sample configuration file is for a master configuration and one sample file is for a slave configuration.


    Note –

    If the Sun Cluster HA for MySQL package (SUNWscmys) was not installed during your initial Sun Cluster installation, proceed to Installing the Sun Cluster HA for MySQL Packages to install it on your cluster. Return here to continue the Installation and Configuration of MySQL.


    The contents of /opt/SUNWscmys/etc/my.cnf_sample_[master|slave]provide a sample MySQL configuration file that you can use to create your MySQL instance <MySQL Databasedirectory>/my.cnf. You must still edit that file to reflect your configuration values.


    # cp /opt/SUNWscmys/etc/my.cnf_sample_master  \
     <MySQL Databasedirectory>/my.cnf  
    
  9. Bootstrap MySQL instance — This will create the privilege tables db, host, user, tables_priv and columns_priv in the mysql database, as well as the func table.


    # cd <MySQL Basedirectory>
    

    # ./scripts/mysql_install_db  \
    --datadir=<MySQL Database directory>
    
  10. Create a logfile directory in <MySQL Database Directory>


    # mkdir <MySQL Database Directory>/logs  
    
  11. Change owner and group for <MySQL Database Directory>


    # chown -R mysql:mysql <MySQL Database Directory>
    
  12. Change file permission for <MySQL Database Directory>/my.cnf


    # chmod 644  <MySQL Database Directory>/my.cnf

ProcedureHow to Enable MySQL to run in Failover Zone Configuration

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

  2. As superuser register the SUNW.HAStoragePlus and the SUNW.gds resource types.


    # clresourcetype register SUNW.HAStoragePlus SUNW.gds
    
  3. Create a failover resource group.


    # clresourcegroup create MySQL-resource-group
    
  4. Create a resource for the MySQL zone`s disk storage.


    # clresource create -t SUNW.HAStoragePlus \
    -p FileSystemMountPoints=MySQL-instance-mount-points \
    MySQL-has-resource
    
  5. (Optional) If you want the protection against a total adapter failure for your public network, create a resource for the MySQL`s logical hostname.


    # clreslogicalhostname create -g MySQL-resource-group \
    -h logical-hostname \
    MySQL-logical-hostname-resource-name
    
  6. Place the resource group in the managed state.


    # clresourcegroup online -M  MySQL-resource-group
    
  7. Install the zone.

    Install the zone according to the Sun Cluster HA for Solaris Containers agent documentation, assuming that the resource name is MySQL-zone-rs and that the zone name is MySQL-zone.

  8. Verify the zone's installation.


    # zoneadm -z MySQL-zone boot
    # zoneadm -z MySQL-zone halt
    
  9. Register the zone's boot component.

    1. Copy the container resource boot component configuration file.


      # cp /opt/SUNWsczone/sczbt/util/sczbt_config zones-target-configuration-file
      
    2. Use a plain text editor to set the following variables:

      RS=MySQL-zone-rs
      RG=MySQL-resource-group
      PARAMETERDIR=MySQL-zone-parameter-directory
      SC_NETWORK=true|false
      SC_LH=MySQL-logical-hostname-resource-name
      FAILOVER=true|false
      HAS_RS=MySQL-has-resource
      Zonename=MySQL-zone
      Zonebootopt=zone-boot-options
      Milestone=zone-boot-milestone
      Mounts=
    3. Create the parameter directory for your zone's resource.


      # mkdir MySQL-zone-parameter-directory
      
    4. Execute the Sun Cluster HA for Solaris Container's registration script.


      # /opt/SUNWsczone/sczbt/util/sczbt_register -f zones-target-configuration-file
      
    5. Enable the Solaris Container resource


      # clresource enable MySQL-zone-rs
      
  10. Enable the resource group.


    # clresourcegroup online  MySQL-resource-group
    

ProcedureHow to Install and Configure MySQL in a Failover Zone

  1. Insure that you are on the node where your enabled your resource group.

  2. Log in to your zone


    # zlogin MySQL-zone
    
  3. Become superuser or assume a role that provides solaris.cluster.verb RBAC authorization on one of the nodes in the cluster that will host MySQL.

  4. Install MySQL.

    It is recommended that MySQL be installed onto a Global File System. For a discussion of the advantages and disadvantages of installing the software on local versus cluster files systems, see “Determining the Location of the Application Binaries” in the Sun Cluster Data Services Installation and Configuration Guide.

    Download MySQL from http://www.mysql.com — If you intend to use local disks for the MySQL software, you will need to repeat this step on all nodes within Sun Cluster.

  5. Create a mysql-user and mysql-group for MySQL zone that will run MySQL

    Create an entry in /etc/group in the zone.


    • # groupadd -g 1000 mysql
      

      Create an entry in /etc/passwd on all nodes within Sun Cluster. This user should have a locked password.


      # useradd -u 1000 -g 1000 -d /global/mysql -s /bin/sh mysql 
      
  6. Change owner and group for MySQL binaries


    # chown -R mysql:mysql /global/mysql
    
  7. Create your MySQL Database directory for your MySQL Instance(s).


    # mkdir <MySQL Database directory>
    #

    Note –

    Refer back to Configuration Restrictions for a description of the <MySQL Database directory> and to Installing and Configuring MySQL for a list of common pathnames.


    Shows one MySQL instance. MySQL has been installed from http://www.mysql.com in /global/mysql which is mounted as a Global File System. The MySQL Database Directory for the MySQL instance is /global/mysql-data.


    # cd /global/mysql
    #
    # ls -l
    -rw-r--r--   1 mysql    mysql      19106 Dec 10 14:52 COPYING
    -rw-r--r--   1 mysql    mysql      28003 Dec 10 14:52 COPYING.LIB
    -rw-r--r--   1 mysql    mysql      44577 Dec  5 10:37 ChangeLog
    -rw-r--r--   1 mysql    mysql       6811 Dec 10 14:53 INSTALL-BINARY
    -rw-r--r--   1 mysql    mysql       1976 Dec  5 10:37 README
    drwxr-xr-x   2 mysql    mysql       1024 Dec 13 18:05 bin
    -rwxr-xr-x   1 mysql    mysql        773 Dec 10 15:34 configure
    drwxr-x---   3 mysql    mysql        512 Apr  3 12:23 data
    drwxr-xr-x   2 mysql    mysql       1024 Dec 10 15:35 include
    drwxr-xr-x   2 mysql    mysql        512 Dec 10 15:35 lib
    drwxr-xr-x   2 mysql    mysql        512 Dec 10 15:35 man
    -rw-r--r--   1 mysql    mysql    2582089 Dec 10 14:47 manual.html
    -rw-r--r--   1 mysql    mysql    2239278 Dec 10 14:47 manual.txt
    -rw-r--r--   1 mysql    mysql      94600 Dec 10 14:47 manual_toc.html
    drwxr-xr-x   6 mysql    mysql        512 Dec 10 15:35 mysql-test
    drwxr-xr-x   2 mysql    mysql        512 Dec 10 15:35 scripts
    drwxr-xr-x   3 mysql    mysql        512 Dec 10 15:35 share
    drwxr-xr-x   7 mysql    mysql       1024 Dec 10 15:35 sql-bench
    drwxr-xr-x   2 mysql    mysql        512 Dec 10 15:35 support-files
    drwxr-xr-x   2 mysql    mysql        512 Dec 10 15:35 tests
    #
  8. Create the MySQL my.cnf file according to your requirements — The Sun Cluster HA for MySQL data service provides two sample my.cnf file for MySQL: one sample configuration file is for a master configuration and one sample file is for a slave configuration.


    Note –

    If the Sun Cluster HA for MySQL package (SUNWscmys) was not installed during your initial Sun Cluster installation, proceed to Installing the Sun Cluster HA for MySQL Packages to install it on your cluster. Return here to continue the Installation and Configuration of MySQL.


    The contents of /opt/SUNWscmys/etc/my.cnf_sample_[master|slave]provide a sample MySQL configuration file that you can use to create your MySQL instance <MySQL Databasedirectory>/my.cnf. You must still edit that file to reflect your configuration values.


    # cp /opt/SUNWscmys/etc/my.cnf_sample_master  \
     <MySQL Databasedirectory>/my.cnf  
    
  9. Bootstrap MySQL instance — This will create the privilege tables db, host, user, tables_priv and columns_priv in the mysql database, as well as the func table.


    # cd <MySQL Basedirectory>
    

    # ./scripts/mysql_install_db  \
    --datadir=<MySQL Database directory>
    
  10. Create a logfile directory in <MySQL Database Directory>


    # mkdir <MySQL Database Directory>/logs  
    
  11. Change owner and group for <MySQL Database Directory>


    # chown -R mysql:mysql <MySQL Database Directory>
    
  12. Change file permission for <MySQL Database Directory>/my.cnf


    # chmod 644  <MySQL Database Directory>/my.cnf