添加sql节点相对比较简单。

由于资源有限,而且管理节点平时也没有什么负载,就把管理节点变成一个sql节点。这个操作比较简单。

如何配置一个mysql cluster可以参考http://itlaowu.blog.51cto.com/1358545/1030688

1.只需要修改管理节点的cong.ini文件,在文件末尾追加

[mysqld]

Hostname=192.168.163.110

2.然后编辑sql节点的my.cnf文件

[mysqld]

#basedir         = /var/lib/mysql/data

#datadir         = /var/lib/mysql/data

user            = mysql

port            = 3306

#socket          = /tmp/mysql.sock

ndbcluster

ndb-connectstring=192.168.163.110

[MYSQL_CLUSTER]

ndb-connectstring=192.168.163.110

1,  关闭管理节点,并使用—reload启动管理节点

ndb_mgm> show

Cluster Configuration

---------------------

[ndbd(NDB)]     2 node(s)

id=2    @192.168.163.140  (mysql-5.5.27 ndb-7.2.8, Nodegroup: 0, Master)

id=3    @192.168.163.170  (mysql-5.5.27 ndb-7.2.8, Nodegroup: 0)

 

[ndb_mgmd(MGM)] 1 node(s)

id=1    @192.168.163.110  (mysql-5.5.27 ndb-7.2.8)

 

[mysqld(API)]   3 node(s)

id=4 (not connected, accepting connect from 192.168.163.160)

ndb_mgm> 1 stop

Node 1 has shutdown.

Disconnecting to allow Management Server to shutdown

 

ndb_mgm> quit

[root@vmhost02 local]# ndb_mgmd -f /var/lib/mysql/config.ini –reload

MySQL Cluster Management Server mysql-5.5.27 ndb-7.2.8

2,  把其他数据节点的ndb表所在的数据库建库脚本在新sql节点执行一下,或者把其他sql节点的数据结构文件copy到新sql节点,就完成了。

[root@vmhost02 local]# ndb_mgm

-- NDB Cluster -- Management Client --

ndb_mgm> show

Connected to Management Server at: 192.168.163.110:1186

Cluster Configuration

---------------------

[ndbd(NDB)]     2 node(s)

id=2 (not connected, accepting connect from 192.168.163.140)

id=3 (not connected, accepting connect from 192.168.163.170)

 

[ndb_mgmd(MGM)] 1 node(s)

id=1    @192.168.163.110  (mysql-5.5.27 ndb-7.2.8)

 

[mysqld(API)]   3 node(s)

id=4 (not connected, accepting connect from 192.168.163.160)

id=5 (not connected, accepting connect from 192.168.163.110)