Architecture
Manager Node
mysql-mag1 192.168.1.31
mysql-mag2 192.168.1.32
SQL Node
mysql-sql1 192.168.1.33
mysql-sql2 192.168.1.34
NDB Node
mysql-ndb1 192.168.1.35
mysql-ndb2 192.168.1.36
[root@mysql-mag1 ~]# cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6 #manager node
192.168.1.31 mysql-mag1
192.168.1.32 mysql-mag2 #sql node
192.168.1.33 mysql-sql1
192.168.1.34 mysql-sql2 #ndb node
192.168.1.35 mysql-ndb1
192.168.1.36 mysql-ndb2
MySQL Cluster7.2 JAVA must be installed configuration environment
[root@mysql-mag1 ~]# chmod u+x jdk-6u13-linux-x64.bin
[root@mysql-mag1 ~]# ./jdk-6u13-linux-x64.bin
[root@mysql-mag1 ~]# mv jdk1.6.0_13 /usr/local/
[root@mysql-mag1 ~]# echo "export JAVA_HOME=/usr/local/jdk1.6.0_13" >> /etc/profile
[root@mysql-mag1 ~]# echo "export CLASSPATH=.:$JAVA_HOME/lib/tools.jar" >> /etc/profile
[root@mysql-mag1 ~]# echo "export PATH=$JAVA_HOME/bin:$PATH" >> /etc/profile
[root@mysql-mag1 ~]# source /etc/profile
[root@mysql-mag1 ~]# java -version
java version "1.6.0_13"
Java(TM) SE Runtime Environment (build 1.6.0_13-b03)
Java HotSpot(TM) 64-Bit Server VM (build 11.3-b02, mixed mode)
[root@mysql-mag1 ~]#
[root@mysql-mag1 ~]# javac -version
javac 1.6.0_13
Installation Manager Node1
[root@mysql-mag1 ~]# tar -zxvf mysql-cluster-gpl-7.2.10.tar.gz
[root@mysql-mag1 ~]# cd mysql-cluster-gpl-7.2.10
[root@mysql-mag1 mysql-cluster-gpl-7.2.10]#
[root@mysql-mag1 mysql-cluster-gpl-7.2.10]# cmake . -DCMAKE_INSTALL_PREFIX=/service/mysql -DSYSCONFDIR=/etc/mysql -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_EXAMPLE_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DCOMPILATION_COMMENT=Mysql-Cluster -DCMAKE_BUILD_TYPE=Release -DMYSQL_USER=mysql -DWITH_MYSQLMANAGER=ON -DWITH_EMBEDDED_SERVER=ON -DWITH_NDB_TEST=ON -DWITH_DEBUG=ON -DWITH_NDB_DEBUG=ON
[root@mysql-mag1 mysql-cluster-gpl-7.2.10]# make && make install
[root@mysql-mag1 mysql-cluster-gpl-7.2.10]# du -sh /service/mysql/
1017M /service/mysql/
[root@mysql-mag1 mysql-cluster-gpl-7.2.10]# cd /service/mysql/
[root@mysql-mag1 mysql]# mkdir mysql-cluster
[root@mysql-mag1 mysql]# chown -R mysql.mysql /service/mysql
[root@mysql-mag1 mysql]# mkdir -p /etc/mysql
[root@mysql-mag1 mysql]# cp /root/mysql-cluster-gpl-7.2.10/support-files/config.huge.ini /etc/mysql/config.ini
[root@mysql-mag1 mysql]# cat config.ini
[NDBD DEFAULT]
NoOfReplicas: 2
DataDir: /service/mysql/mysql-cluster
FileSystemPath: /service/mysql/data LockPagesInMainMemory: 1 DataMemory: 128M
IndexMemory: 64M [MGM DEFAULT]
PortNumber: 1186
DataDir: /service/mysql/mysql-cluster [TCP DEFAULT]
SendBufferMemory: 2M
ReceiveBufferMemory: 2M [NDB_MGMD]
NodeId: 1
HostName: 192.168.1.31
ArbitrationRank: 1 [NDB_MGMD]
NodeId: 2
HostName: 192.168.1.32
ArbitrationRank: 1 [NDBD]
NodeId: 3
HostName: 192.168.1.35 [NDBD]
NodeId: 4
HostName: 192.168.1.36 [API]
NodeId: 5
HostName: 192.168.1.33 [API]
NodeId: 6
HostName: 192.168.1.34
Installation Manager Node2
From manager node1 copy "config.ini,MYSQL_HOME/bin/*" to manager node2 and give permission.
[root@mysql-mag1 mysql]# scp /etc/mysql/config.ini mysql-mag2:/etc/mysql/
[root@mysql-mag1 mysql]# scp -rp /service/mysql/* mysql-mag2:/service/mysql/
On manager node2 give permission.
[root@mysql-mag2 mysql]# chown -R mysql.mysql /etc/mysql /service/mysql
Start Manager Node
The first time on the manager node to start the manager serverThe first time on the manager node to start the manager server.
On manager node1
[root@mysql-mag1 ~]# /service/mysql/bin/ndb_mgmd -f /etc/mysql/config.ini --config-dir=/service/mysql/mysql-cluster/ --initial
MySQL Cluster Management Server mysql-5.5.29 ndb-7.2.10
On manager node2
[root@mysql-mag2 mysql]# /service/mysql/bin/ndb_mgmd -f /etc/mysql/config.ini --config-dir=/service/mysql/mysql-cluster/ --initial
MySQL Cluster Management Server mysql-5.5.29 ndb-7.2.10
Start using reload parameters again
/service/mysql/bin/ndb_mgmd -f /etc/mysql/config.ini --config-dir=/service/mysql/mysql-cluster/ --reload
[root@mysql-mag1 ~]# /service/mysql/bin/ndb_mgm
-- NDB Cluster -- Management Client --
ndb_mgm> show
Connected to Management Server at: localhost:1186
Cluster Configuration
---------------------
[ndbd(NDB)] 2 node(s)
id=3 (not connected, accepting connect from 192.168.1.35)
id=4 (not connected, accepting connect from 192.168.1.36) [ndb_mgmd(MGM)] 2 node(s)
id=1 @192.168.1.31 (mysql-5.5.29 ndb-7.2.10)
id=2 @192.168.1.32 (mysql-5.5.29 ndb-7.2.10) [mysqld(API)] 2 node(s)
id=5 (not connected, accepting connect from 192.168.1.33)
id=6 (not connected, accepting connect from 192.168.1.34)
Installation NDB Node1
Create my.cnf
[root@mysql-ndb1 ~]# cat /etc/mysql/my.cnf
[mysqld]
datadir=/service/mysql/data
basedir=/service/mysql
socket=/service/mysql/mysql.sock
default_storage_engine=NDBCLUSTER
ndbcluster
ndb-connectstring=mysql-mag1,mysql-mag2 [mysql_cluster]
ndb-connectstring=mysql-mag1,mysql-mag2
From manager node1 copy "MYSQL_HOME/bin/*" to ndb node1 and give permission.
[root@mysql-mag1 ~]# scp -rp /service/mysql/* mysql-ndb1:/service/mysql
On NDB node1
give permission.
[root@mysql-ndb1 mysql]# chown -R mysql.mysql /etc/mysql /service/mysql
Installation NDB Node2
From ndb node1 copy "my.cnf,MYSQL_HOME/bin/*" to ndb node2 and give permission.
[root@mysql-ndb1 mysql]# scp -rp /etc/mysql/my.cnf mysql-ndb2:/etc/mysql/
[root@mysql-ndb1 mysql]# scp -rp /service/mysql/* mysql-ndb2:/service/mysql/
On NDB node2
give permission.
[root@mysql-ndb2 mysql]# chown -R mysql.mysql /etc/mysql /service/mysql
Start NDB Node
[root@mysql-ndb1 ~]# /service/mysql/bin/ndbd --initial
2013-11-19 22:50:40 [ndbd] INFO -- Angel connected to 'mysql-mag1:1186'
2013-11-19 22:50:40 [ndbd] INFO -- Angel allocated nodeid: 3
[root@mysql-ndb2 ~]# /service/mysql/bin/ndbd --initial
2013-11-19 23:02:26 [ndbd] INFO -- Angel connected to 'mysql-mag1:1186'
2013-11-19 23:02:26 [ndbd] INFO -- Angel allocated nodeid: 4
NDB nodes "ndbd --initial" starting up only when the first time you start or need to recover from a backup database needs, other times as long as the executive "ndbd -d"
View Manager Node
ndb_mgm> show
Cluster Configuration
---------------------
[ndbd(NDB)] 2 node(s)
id=3 @192.168.1.35 (mysql-5.5.29 ndb-7.2.10, Nodegroup: 0, Master)
id=4 @192.168.1.36 (mysql-5.5.29 ndb-7.2.10, Nodegroup: 0) [ndb_mgmd(MGM)] 2 node(s)
id=1 @192.168.1.31 (mysql-5.5.29 ndb-7.2.10)
id=2 @192.168.1.32 (mysql-5.5.29 ndb-7.2.10) [mysqld(API)] 5 node(s)
id=5 (not connected, accepting connect from 192.168.1.33)
id=6 (not connected, accepting connect from 192.168.1.34)
id=7 (not connected, accepting connect from any host)
id=8 (not connected, accepting connect from any host)
id=9 (not connected, accepting connect from any host)
Installation SQL Node1
[root@mysql-sql1 mysql-cluster-gpl-7.2.10]# cmake . -DCMAKE_INSTALL_PREFIX=/service/mysql -DMEMCACHED_HOME=/service/mysql/memcached -DSYSCONFDIR=/etc/mysql -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_EXAMPLE_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DCOMPILATION_COMMENT=Mysql-Cluster -DCMAKE_BUILD_TYPE=Release -DMYSQL_USER=mysql -DWITH_MYSQLMANAGER=ON -DBACKUP_TEST=OFF -DWITH_DEBUG=ON -DWITH_NDB_DEBUG=ON
[root@mysql-sql1 mysql-cluster-gpl-7.2.10]# make && make install
[root@mysql-sql1 mysql-cluster-gpl-7.2.10]# cp support-files/my-huge.cnf /etc/mysql/my.cnf
[root@mysql-sql1 mysql-cluster-gpl-7.2.10]# cat /etc/mysql/my.cnf
[client]
port = 3306
socket = /tmp/mysql.sock [mysqld]
port = 3306
socket = /tmp/mysql.sock
skip-external-locking
key_buffer_size = 128M
max_allowed_packet = 1M
table_open_cache = 512
sort_buffer_size = 2M
read_buffer_size = 2M
read_rnd_buffer_size = 8M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size = 32M
thread_concurrency = 8 ndbcluster
ndb-connectstring=mysql-mag1,mysql-mag2
user=mysql log-bin=mysql-bin
log-error [mysql_cluster]
ndb-connectstring=mysql-mag1,mysql-mag2 [mysqldump]
quick
max_allowed_packet = 16M [mysql]
no-auto-rehash [myisamchk]
key_buffer_size = 256M
sort_buffer_size = 256M
read_buffer = 2M
write_buffer = 2M [mysqlhotcopy]
interactive-timeout [root@mysql-sql1 mysql-cluster-gpl-7.2.10]# chown -R mysql.mysql /etc/mysql /service/mysql
[root@mysql-sql1 mysql-cluster-gpl-7.2.10]# cp support-files/mysql.server /etc/init.d/mysql
[root@mysql-sql1 mysql-cluster-gpl-7.2.10]# /service/mysql/scripts/mysql_install_db --user=mysql --basedir=/service/mysql
Installing MySQL system tables...
OK
Filling help tables...
OK To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands: /service/mysql/bin/mysqladmin -u root password 'new-password'
/service/mysql/bin/mysqladmin -u root -h mysql-sql1 password 'new-password' Alternatively you can run:
/service/mysql/bin/mysql_secure_installation which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers. See the manual for more instructions. You can start the MySQL daemon with:
cd /service/mysql ; /service/mysql/bin/mysqld_safe & You can test the MySQL daemon with mysql-test-run.pl
cd /service/mysql/mysql-test ; perl mysql-test-run.pl Please report any problems with the /service/mysql/scripts/mysqlbug script! [root@mysql-sql1 mysql-cluster-gpl-7.2.10]#
Installation SQL Node2
Installation is the same as the SQL Node1
Start SQL Node
On SQL Node1
[root@mysql-sql1 mysql-cluster-gpl-7.2.10]# /etc/init.d/mysql start
Starting MySQL....[ OK ]
On SQL Node2
[root@mysql-sql2 mysql]# /etc/init.d/mysql start
Starting MySQL.....[ OK ]
View Manager Node
ndb_mgm> show
Cluster Configuration
---------------------
[ndbd(NDB)] 2 node(s)
id=3 @192.168.1.35 (mysql-5.5.29 ndb-7.2.10, Nodegroup: 0, Master)
id=4 @192.168.1.36 (mysql-5.5.29 ndb-7.2.10, Nodegroup: 0) [ndb_mgmd(MGM)] 2 node(s)
id=1 @192.168.1.31 (mysql-5.5.29 ndb-7.2.10)
id=2 @192.168.1.32 (mysql-5.5.29 ndb-7.2.10) [mysqld(API)] 5 node(s)
id=5 @192.168.1.33 (mysql-5.5.29 ndb-7.2.10)
id=6 @192.168.1.34 (mysql-5.5.29 ndb-7.2.10)
id=7 (not connected, accepting connect from any host)
id=8 (not connected, accepting connect from any host)
id=9 (not connected, accepting connect from any host)
Test MySQL Cluster
[root@mysql-sql2 mysql]# /service/mysql/bin/mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.29-ndb-7.2.10-debug-log Mysql-Cluster Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> show engines;
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
| Engine | Support | Comment | Transactions | XA | Savepoints |
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
| ndbcluster | YES | Clustered, fault-tolerant tables | YES | NO | NO |
| MRG_MYISAM | YES | Collection of identical MyISAM tables | NO | NO | NO |
| MyISAM | YES | MyISAM storage engine | NO | NO | NO |
| BLACKHOLE | YES | /dev/null storage engine (anything you write to it disappears) | NO | NO | NO |
| PERFORMANCE_SCHEMA | YES | Performance Schema | NO | NO | NO |
| CSV | YES | CSV storage engine | NO | NO | NO |
| ARCHIVE | YES | Archive storage engine | NO | NO | NO |
| ndbinfo | YES | MySQL Cluster system information storage engine | NO | NO | NO |
| FEDERATED | NO | Federated MySQL storage engine | NULL | NULL | NULL |
| InnoDB | DEFAULT | Supports transactions, row-level locking, and foreign keys | YES | YES | YES |
| MEMORY | YES | Hash based, stored in memory, useful for temporary tables | NO | NO | NO |
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
11 rows in set (0.01 sec) mysql> select @@version;
+-----------------------------+
| @@version |
+-----------------------------+
| 5.5.29-ndb-7.2.10-debug-log |
+-----------------------------+
1 row in set (0.00 sec) mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| ndbinfo |
| performance_schema |
| test |
+--------------------+
5 rows in set (0.00 sec) mysql> use test
Database changed
mysql> show tables;
Empty set (0.06 sec) mysql> create table t_test(
-> id int(5) primary key,
-> name varchar(20)
-> )engine=ndb comment='ndb test';
Query OK, 0 rows affected (0.24 sec) mysql> show create table t_test\G
*************************** 1. row ***************************
Table: t_test
Create Table: CREATE TABLE `t_test` (
`id` int(5) NOT NULL,
`name` varchar(20) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=ndbcluster DEFAULT CHARSET=utf8 COMMENT='ndb test'
1 row in set (0.00 sec) mysql> insert into t_test values(1,'zwc');
Query OK, 1 row affected (0.00 sec)