标签:
This post documents how build MySQL cluster environment with 4 machines. Their IP addresses and roles are listed below.
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.gz tar zxvf 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/
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.
apt-get 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 mysql useradd -g mysql mysql # tar zxvf 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/mysql scripts/mysql_install_db --user=mysql # chown -R root . chown -R mysql data chgrp -R mysql . # cp support-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 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.1.100 datadir=/var/lib/mysql-cluster # Directory for MGM node log files [ndbd] # Options for data node #1: hostname=192.168.1.102 datadir=/usr/local/mysql/data # Directory for this data node‘s data files [ndbd] # Options for data node #2: hostname=192.168.1.103 datadir=/usr/local/mysql/data # Directory for this 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_mgm
ndb_mgm> show
On the SQL node, set password for root.
mysqladmin -u root password ‘your password‘
Finally, try to create a database to test.
Build MySQL Cluster Environment
标签:
原文地址:http://www.cnblogs.com/jeffreyf/p/build-mysql-cluster-environment.html