Skip to content

Instantly share code, notes, and snippets.

@htcang
Last active May 16, 2016 10:54
Show Gist options
  • Save htcang/4b634e7ed28478aba8eb to your computer and use it in GitHub Desktop.
Save htcang/4b634e7ed28478aba8eb to your computer and use it in GitHub Desktop.
MySQL Cluster Installation

Machine 1: Management Node + SQL Node

IP: 192.168.0.151

  1. Install prequisition
yum install perl
  1. Download the mysql cluster
cd /var/tmp
curl -OL http://dev.mysql.com/get/Downloads/MySQL-Cluster-7.3/mysql-cluster-gpl-7.3.7-linux-glibc2.5-x86_64.tar.gz
  1. Add group and user
groupadd mysql
useradd -g mysql mysql
  1. Install
cd /var/tmp
tar -C /usr/local -xzvf mysql-cluster-gpl-7.3.7-linux-glibc2.5-x86_64.tar.gz
ln -s /usr/local/mysql-cluster-gpl-7.3.7-linux-glibc2.5-x86_64 /usr/local/mysql
cd /usr/local/mysql
scripts/sql_install_db --user=mysql
cp bin/ndb_mgm* /usr/local/bin
  1. Config
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
cd /usr/local/bin
chmod +x ndb_mgm*

Machine 2 to N - Data Node

Node A: IP 192.168.0.152 Node B: IP 192.168.0.153 ...

  1. Download
cd /var/tmp
curl -OL http://dev.mysql.com/get/Downloads/MySQL-Cluster-7.3/mysql-cluster-gpl-7.3.7-linux-glibc2.5-x86_64.tar.gz
  1. Install
tar -xzvf mysql-cluster-gpl-7.3.7-linux-glibc2.5-x86_64.tar.gz
cd mysql-cluster-gpl-7.3.7-linux-glibc2.5-x86_64
cp bin/ndbd /usr/local/bin/ndbd
cp bin/ndbmtd /usr/local/bin/ndbmtd
  1. Config
cd /usr/local/bin
chmod +x ndb*

#Node 1: Management Node + SQL Node

  1. Config for SQL Node process:
# content of /etc/my.cnf

[mysqld]
# Options for mysqld process:
ndbcluster                      # run NDB storage engine
bind-address=0.0.0.0
ndb-connectstring=127.0.0.1
default_storage_engine=ndbcluster

[mysql_cluster]
# Options for MySQL Cluster processes:
ndb-connectstring=127.0.0.1  # location of management server
  1. Config for Management Node
mkdir /var/lib/mysql-cluster
cd /var/lib/mysql-cluster
vi config.ini
# content of /var/lib/mysql-cluster/config.ini
[ndbd default]
# Options affecting ndbd processes on all data nodes:
NoOfReplicas=2    # Number of replicas
DataMemory=80M    # How much memory to allocate for data storage
IndexMemory=18M   # How much memory to allocate for index storage

[tcp default]
# TCP/IP options:
portnumber=2202   

[ndb_mgmd]
# Management process options:
hostname=192.168.0.151          # Hostname or IP address of MGM node
datadir=/var/lib/mysql-cluster  # Directory for MGM node log files

[ndbd]
# Options for data node "A":
                                # (one [ndbd] section per data node)
hostname=192.168.0.152           # Hostname or IP address
datadir=/usr/local/mysql/data   # Directory for this data node's data files

[ndbd]
# Options for data node "B":
hostname=192.168.0.153           # Hostname or IP address
datadir=/usr/local/mysql/data   # Directory for this data node's data files

[mysqld]
# SQL node options:
hostname=192.168.0.151           # Hostname or IP address
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment