Sun Cluster 3.1 Data Service for MySQL Guide

Installing and Configuring MySQL

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

Throughout the following next sections, references will be made to certain directories for MySQL. The following list shows common pathnames for these references as shown in previous examples. Refer to Configuration Restrictions where these examples are shown.

How to Install and Configure MySQL

Use this procedure to install and configure MySQL.

  1. Determine how MySQL will be deployed in Sun Cluster – Here you need to determine how MySQL will be deployed.

    • Determine how many MySQL instances will be deployed.

    • Determine which Cluster File System will be used by each MySQL instance.

  2. Mount the MySQL Cluster File Systems – Once you have determined how MySQL will be deployed within Sun Cluster, you must ensure the Cluster File Systems are mounted.


    Note –

    If Failover File Systems will be used by the MySQL instance, you must mount these manually.


  3. Install MySQL onto all nodes within Sun Cluster – It is recommended that MySQL be installed onto a Global File System, however 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 — However, if you intend to use local disks for the MySQL software, you will need to repeat this step on all nodes within Sun Cluster.

  4. 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 
      
  5. Change owner and group for MySQL binaries

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


      # chown -R mysql:mysql /global/mysql
      
  6. 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 used from the examples in Configuration Restrictions and in the further example below.



    Example 1–4 Directories for MySQL instance

    The following example 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
    #

  7. Create the MySQL my.cnf file according to your requirements — The Sun Cluster HA for MySQL data service provides two samples 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, you should proceed to Installing the Sun Cluster HA for MySQL Packages to install it on SC3.1 and SC3.0U3. Afterwards, return back here to continue the Installation and Configuration of MySQL.


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


    # cp /opt/SUNWscmys/etc/my.cnf_sample_master  \
     <MySQL Databasedirectory>/my.cnf  
    
  8. Bootstrap MySQL instance — That 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>
    
  9. Create a logfile directory in <MySQL Database Directory>


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


    # chown -R mysql:mysql <MySQL Database Directory>
    
  11. Change filepermission for <MySQL Database Directory>/my.cnf


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