This post documents how to build MySQL cluster environment with 4 machines. Their IP addresses and roles are listed below.
- Host #1:192.168.1.100, Management node
- Host #2:192.168.1.101, SQL node
- Host #3:192.168.1.102, Data node #1
- Host #4:192.168.1.103, Data node #2
Download MySQL Cluster on each host
wget http://dev.mysql.com/get/downloads/mysql-cluster-7.3/ mysql-cluster-gpl-7.3.7-linux-glibc2.5-x86_64.tar.gztar zxvf mysql-cluster-gpl-7.3. 7-LINUX-GLIBC2. 5-x86_64. Tar . gzcd MySQL-cluster-gpl-7.3. 7-LINUX-GLIBC2. 5-x86_64/
Setup the cluster
On Management Node, run the following commands to copy NDB_MGM and ndb_mgmd to/usr/local/bin/.
CP bin/ndb_mgm/usr/local/bin/CP bin/ndb_mgmd/usr/local/bin/
On Data Node, run the following commands to copy ndbd and ndbmtd to/usr/local/bin/.
CP bin/ndbd/usr/local/bin/CP bin/ndbmtd/usr/local/bin/
On SQL Node
Check if the library libaio1 installed on the host, if not, execute the following command to install the library.
Install Libaio1
If the library can ' t be installed by running Apt-get, you can download this package first, and then install it with dpkg- I like below.
wget http://Archive.ubuntu.com/ubuntu/pool/main/liba/libaio/libaio1_0.3.109-4_amd64.deb dpkg-i Libaio1_0. 3.109-4_amd64.deb
Run the following commands to install MySQL.
#groupadd Mysqluseradd-g MySQL MySQL #TarZXVF mysql-cluster-gpl-7.3.7-LINUX-GLIBC2.5-x86_64.Tar. gz-c/usr/local/LN-s/usr/local/mysql-cluster-gpl-7.3.7-LINUX-GLIBC2.5-x86_64/usr/local/MYSQL#CD/usr/loca/mysqlscripts/mysql_install_db--user=mysql#Chown-R root.Chown-R MySQL Datachgrp-R MySQL. #CPsupport-files/mysql.server/etc/init.d/Update-RC.D mysql.server Defaults
Configure the Cluster
On the SQL and data nodes, type the following lines in/etc/my.cnf.
[mysqld]ndbcluster[mysql_cluster]ndb-connectstring=1092.168.1.100
On the Management node, type the following lines In/etc/mysql/config.ini.
[ndbd Default]noofreplicas=2# Number of Replicasdatamemory=80m # How much memory to allocate forData storageindexmemory=18m # How much memory to allocate forindex Storage [TCP default]# TCP/IP Options:portnumber=2202[ndb_mgmd]# Management process options:hostname=192.168.1.100DataDir=/var/lib/mysql-cluster # Directory forMGM node log files[ndbd]# Options forData Node #1: hostname=192.168.1.102DataDir=/usr/local/mysql/data # Directory forThis data node's data Files[ndbd]# Options forData Node #2:hostname=192.168.1.103DataDir=/usr/local/mysql/data # Directory forThis data node's data Files[mysqld]# SQL node #1:hostname=192.168.1.101
Start the cluster
Start the Management node first.
Ndb_mgmd-f/var/lib/mysql-cluster/config.ini
Start the data nodes.
ndbd
Start the SQL node.
Service Mysql.server Start
On the management node, run the following command to see if the cluster goes well.
NDB_MGMNDB_MGM> show
On the SQL node, set password for root.
' Your password '
Finally, try to create a database to test.
Build MySQL Cluster Environment