Go to main content

Oracle® Solaris Cluster Data Service for MySQL Guide

Exit Print View

Updated: June 2017
 
 

How to Install and Configure MySQL in a Zone

Before You Begin

If the HA for MySQL package (ha-cluster/data-service/mysql) was not installed during your initial Oracle Solaris Cluster installation, proceed to Installing the HA for MySQL Package to install it on your cluster. Return here to continue the installation and configuration of MySQL.

  1. Ensure that you are on the node where you have enabled your resource group.
  2. Log in to your zones.
    # zlogin MySQL-zone
  3. On one of the nodes in the cluster that will host MySQL, become an administrator that provides solaris.cluster.admin authorization.
  4. Install MySQL on all nodes within Oracle Solaris Cluster.

    MySQL should be installed onto a cluster file system. For a discussion of the advantages and disadvantages of installing the software on local versus cluster file systems, see Determining the Location of the Application Binaries in Oracle Solaris Cluster 4.3 Data Services Planning and Administration 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 Oracle Solaris Cluster.

  5. Create a mysql-user and mysql-group for MySQL on all nodes in the cluster that will run MySQL.
    1. Create an entry in /etc/group on all cluster nodes.
      # groupadd -g 1000 mysql
    2. Create an entry in /etc/passwd on all cluster nodes.

      This user should have a locked password.

      # useradd -u 1000 -g 1000 -d /global/mysql -s /bin/sh mysql
  6. Change the 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 or instances.
    # mkdir MySQL-Database-directory

    Note -  Refer to Configuration Restrictions for a description of the MySQL Database directory and to Installing and Configuring MySQL for a list of common path names.

    The following listing shows one MySQL instance. MySQL has been installed from http://www.mysql.com in /global/mysql, which is mounted as a cluster 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 HA for MySQL data service provides three sample my.cnf files for MySQL. One sample configuration file is for a master configuration, one is sample file is for a slave configuration, and one for the server configuration in a MySQL cluster.

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

    # cp /opt/SUNWscmys/etc/my.cnf_sample_master \
    MySQL-Database-directory/my.cnf

    Note -  For a multiple-master operating system scalable deployment, perform the remaining step of this procedure on all zones of the cluster that are about to host the MySQL database. In this case, set the socket directive in the my.cnf file to the following value:
    socket=/tmp/physical-host.sock

  9. Bootstrap MySQL instance.

    This creates the privilege tables db, host, user, tables_priv and columns_priv in the MySQL database, as well as the func table.

    # cd MySQL-base-directory
    # ./scripts/mysql_install_db \
    --datadir=MySQL-Database-directory
  10. Create a logfile directory in MySQL-Database-Directory.
    # mkdir MySQL-Database-Directory/logs
  11. Create directories for your storage engines.
    # mkdir MySQL-Database-Directory/innodb
    # mkdir MySQL-Database-Directory/BDB
  12. Change the owner and group for MySQL—Database-Directory.
    # chown -R mysql:mysql MySQL-Database-Directory
  13. Change file permission for MySQL-Database-Directory/my.cnf.
    # chmod 644 MySQL-Database-Directory/my.cnf