PROBLEM
Using NDB Cluster storage
ENVIRONMENT
- On-Premise Server + WebMail Installations: Version 6.0 > Current Version
- Webmail Only Installations: Version 6.0 > Current Version
CAUSE
Using NDB Cluster storage
RESOLUTION
This portion of the guide covers the steps necessary to use the MySQL NDB Cluster with two storage engines and one management server. This will allow the two MySQL servers to share data independently, and still have the same information for both. In the case of one server going down, the other server will still be active. Changes made to the other server during this period will be "healed" by the MySQL NDB management system.
Packages for MySQL NDB exist for a lot of systems. However, this guide will cover the process of installing it from source - along with PHP.
For this guide, we will have three servers - server1.local (192.168.0.1), server2.local (192.168.0.2), andserver3.local (192.168.0.3). The first two servers will be the replicated storage engines. The third server will act as an NDB management machine.
Setting up the Storage Machines
This step applies to server1.local and server2.local. First, download the MySQL Cluster package from: http://dev.mysql.com/downloads/cluster/. Then, untar to your preferred base directory. For this example, we will use /usr/local/:
% tar xvfz mysql-cluster-gpl-7.1.3-linux-i686-glibc23. tar .gz -C /usr/local/ |
Create a symlink for ease, or rename the folder:
% ln -s /usr/local/mysql-cluster-gpl-7 .1.3-linux-i686-glibc23 /usr/local/mysql |
Then, install MySQL:
% cd /usr/local/mysql % adduser mysql % groupadd mysql % scripts /mysql_install_db --user=mysql % chown -R root . % chown -R mysql data % chgrp -R mysql . % cp support-files /mysql .server /etc/rc .d /init .d/ % chmod +x /etc/rc .d /init .d /mysql .server % chkconfig --add mysql.server |
Then, create a file called /etc/my.cnf. In the file, add:
[mysqld] ndbcluster ndb-connectstring=192.168.0.3 [mysql_cluster] ndb-connectstring=192.168.0.3 |
Replace "192.168.0.3" with your management server's (server3.local) IP. Then, create the required directories:
% mkdir /var/lib/mysql-cluster |
Setting up the Management Server
The MySQL Cluster package will contain the following files:
bin /ndb_mgm bin /ndb_mgmd |
Transfer these files to the server3.local server, as:
/usr/bin/ndb_mgm /usr/bin/ndb_mgmd |
Then, assign permissions:
% chmod +x /usr/bin/ndb_mgm % chmod +x /usr/bin/ndb_mgmd |
Then, create the required directories:
% mkdir /var/lib/mysql-cluster |
In the directory, setup the configuration file called "/var/lib/mysql-cluster/config.ini". In the file:
[NDBD DEFAULT] NoOfReplicas=2 [MYSQLD DEFAULT] [NDB_MGMD DEFAULT] [TCP DEFAULT] # NDB MGM Server [NDB_MGMD] HostName=192.168.0.3 # MySQL servers [NDBD] HostName=192.168.0.1 DataDir= / var /lib/mysql-cluster [NDBD] HostName=192.168.0.2 DataDir=/ var /lib/mysql-cluster [MYSQLD] [MYSQLD] |
Change the IP addresses accordingly, depending on your setup. Now, start the NDB management process:
% /usr/bin/ndb_mgmd |
Starting the NDB processes
On the two MySQL servers, execute:
/usr/local/mysql/bin/ndbd --initial /etc/rc .d /init .d /mysql .server start |
You can check if the MySQL NDB is active by typing this in the third server (server3.local):
% ndb_mgm |
This will show a terminal. Type:
ndb_mgm> show |
It will show something similar to:
Cluster Configuration --------------------- [ndbd(NDB)] 2 node(s) id=2 @192.168.0.1 (mysql-5.1.44 ndb-7.1.3, Nodegroup: 0, Master) id=3 @192.168.0.2 (mysql-5.1.44 ndb-7.1.3, starting, Nodegroup: 0) [ndb_mgmd(MGM)] 1 node(s) id=1 @192.168.0.3 (mysql-5.1.44 ndb-7.1.3) [mysqld(API)] 2 node(s) id=4 @192.168.0.1 (mysql-5.1.44 ndb-7.1.3) id=5 @192.168.0.2 (mysql-5.1.44 ndb-7.1.3) |
Congratuations! You have MySQL NDB active.
Comments