Skip to content

Deploying MySQL on Oracle Clusterware – Part 5

Installing MySQL

There are a few ways to get the MySQL software set up for clustering.  One option is to install the rpm for MySQL on both cluster nodes.  There is also a tar file containing what you need to create a yum repository that can be used by multiple servers.  You could also use a tar of the software and just extract it to a shared filesystem.  The benefit of the last option is that you can have multiple instances of MySQL hosted on the same cluster running different versions.

I decided to have MySQL 5.7 installed from a yum repository, but also have a MySQL 5.6 home extracted from a tar in case you needed to run an older version concurrently.

At the time of writing, I used the following patches from MOS as they had the latest versions of MySQL 5.7 and MySQL 5.6

  • Patch 25236538: MySQL Database 5.7.17 Yum Repository TAR for Oracle Linux / RHEL 6 x86 (64bit)
  • Patch 24412279: MySQL Enterprise Backup 4.0.3 RPM for Oracle Linux / RHEL 6 x86 (64bit)
  • Patch 25238523: MySQL Database 5.6.35 TAR for Generic Linux (glibc2.5) x86 (64bit)
  • Patch 23250313: MySQL Enterprise Backup 3.12.3 TAR for Generic Linux (glibc2.5) x86 (64bit)

Yum based install

The cluster deployment should have created a filesystem at /u02/app/mysql/product by default.  We are going to use this filesystem to store a yum repository and any other MySQL versions we would like to have.  First, lets extract the yum repository:

# cd /u02/app/mysql/product/
# mkdir yum
# cd yum
# unzip /root/p25236538_570_Linux-x86-64.zip
# tar xf mysql-commercial-5.7.17-1.1.el6.x86_64.repo.tar.gz
# rm -rf mysql-commercial-5.7.17-1.1.el6.x86_64.repo.tar.gz*
# rm -f README.txt

Once this is done, you can create a file named /etc/yum.repos.d/mysql.repo on both nodes containing:

[mysql-5.7]
name=mysql-5.7
baseurl=file:///u02/app/mysql/product/yum/mysql-5.7/
gpgkey=file:///u02/app/mysql/product/yum/RPM-GPG-KEY-mysql
gpgcheck=1
enabled=1

You could also set up a yum repository elsewhere or use spacewalk, but since I only have licensed a limited number of machines, I prefer to restrict access to the installer so it isn’t inadvertently used.  You should now be able to install MySQL on both nodes:

# yum install mysql-commercial-server

The MySQL Enterprise Backup software doesn’t create a yum repository by default.  I just extracted it and installed it (make sure you do the install on both nodes):

# cd /u02/app/mysql/product/
# mkdir meb-rpm
# cd meb-rpm/
# unzip p24412279_400_Linux-x86-64.zip
# yum install meb-4.0.3-el6.x86_64.rpm

tar based install

Getting a tar based MySQL home is easy:

# cd /u02/app/mysql/product
# mkdir server
# cd server
# unzip /root/p25238523_56_Linux-x86-64.zip
# rm -f mysql-advanced-5.6.35-linux-glibc2.5-x86_64.tar.gz* README.txt
# tar xf mysql-advanced-5.6.35-linux-glibc2.5-x86_64.tar.gz
# mv mysql-advanced-5.6.35-linux-glibc2.5-x86_64 5.6.35-advanced

Its also easy to get a MySQL Enterprise Backup home setup:

# cd /u02/app/mysql/product
# mkdir meb
# cd meb
# unzip /root/p23250313_3120_Linux-x86-64.zip
# tar xf meb-3.12.3-linux-glibc2.5-x86-64bit.tar.gz
# rm -f meb-3.12.3-linux-glibc2.5-x86-64bit.tar.gz* README.txt
# mv meb-3.12.3-linux-glibc2.5-x86-64bit 3.12.3

Creating an ACFS filesystem for database storage

Now we will create another ACFS filesystem to store the actual database files.  We are going to use ACFS snapshots as well to make it easy to clone individual databases if you ever want to.  First, we need to create the mount point for the filesystem:

# mkdir /u02/app/mysql/datastore
# chown mysql:oinstall /u02/app/mysql/datastore

Once this is done, we can create the filesystem.  We are going to put this on the DATA diskgroup.  If your DATA diskgroup was created by the cluster deployment, it probably is set up to use older versions of ASM and ACFS that are lacking the features we want.  This can be upgrade as the oracle user with:

$ asmcmd
ASMCMD> setattr -G DATA compatible.asm 12.1.0.2.0
ASMCMD> setattr -G DATA compatible.advm 12.1.0.2.0
ASMCMD> setattr -G DATA compatible.rdbms 12.1.0.2.0
ASMCMD> volcreate -G DATA -s 70G MYSQL_DATA

Once this is done, we can run this as root to create the filesystem and mount it (your device name may be slightly different):

# mkfs.acfs -f /dev/asm/mysql_data-466
# acfsutil registry -a -f /dev/asm/mysql_data-466 /u02/app/mysql/datastore
# mount.acfs -o all

Now that the filesystem is mounted, we can create an ACFS snapshot to store the database in when we create it:

# acfsutil snap create -w mydb1 /u02/app/mysql/datastore

I prefer to have the snapshot name match the short hostname of the virtual IP that will host the database (e.g. the snapshot mydb1 corresponds to the database hosted by mydb1.example.com).

Install the Standalone Agent

We need to install the Standalone Agent for Oracle Clusterware, because the agent built in to Clusterware does not have MySQL support.  You can download it here.  At the time of writing this was version 7.1 with a file name of xagpack_7b.zip.  You need to get a copy of this zip file to one of your nodes, extract it, and then run this as oracle:

$ ./xagsetup.sh --install --directory /u01/xag-standalone --all_nodes

You may need to create the directory you are installing to as root and edit the permissions if you are installing somewhere that the oracle user cannot create directories.

After the install, I’ve found that some additional tweaking needs to be done.  This may not apply if you are running your MySQL instances as the oracle user instead of the mysql user.  I had to do the following on both nodes to get things to work as expected:

# cd /u01/xag-standalone
# chmod -R 755 perl/
# cd log/
# mkdir `hostname -s`
# chown oracle:mysql `hostname -s`
# chmod 775 `hostname -s`

The documentation isn’t really clear if it expects MySQL to run as the oracle user or as the mysql user.  There are examples of creating the MySQL instance to run as the mysql user, but then you will encounter the issues I mentioned above.  The documentation also talks about privileges the oracle account needs, but there are also privileges the mysql user will need.  I’ll cover this in more detail in another part.

In the next part, we will create our MySQL instance and start it up.