Ubuntu10.10下MySQL5.1集群配置(2)
[NDBD]
hostname=192.85.1.4
datadir=/var/lib/mysql-cluster
#第二个NDB节点
[NDBD]
hostname=192.85.1.9
datadir=/var/lib/mysql-cluster/
#设置SQL节点服务器[MYSQLD]
[MYSQLD]
在server2。server3上创建mysql-cluster目录,
sudo mkdir -p /var/lib/mysql-cluster
五、启动
1.启动管理:
server1:192.85.1.5
程序代码
#/usr/local/mysql/bin/ndb_mgmd -f /usr/local/mysql/mysql-cluster/config.ini
2.启动存储节点
server2:192.85.1.4
server3:192.85.1.9
程序代码
# /usr/local/mysql/bin/ndbd –initial (第一次启动或管理节点的config.ini发生改变)
#/usr/local/mysql/bin/ndbd (以后启动用这条)
3.启动SQL节点
server2:192.85.1.4
server3:192.85.1.9
# /usr/local/mysql/bin/mysqld_safe --user=mysql &
六、管理
1.在管理节点server1:192.85.1.5上操作
程序代码
# /usr/local/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=2 @192.85.1.4 (Version: 5.1.5, Nodegroup: 0)
id=3 @192.85.1.9 (Version: 5.1.5, Nodegroup: 0, Master)
[ndb_mgmd(MGM)] 1 node(s)
id=1 @10.1.11.143 (Version: 5.1.5)
[mysqld(API)] 2 node(s)
id=4 @192.85.1.4 (Version: 5.1.5)
id=5 @192.85.1.9 (Version: 5.1.5)
ndb_mgm>
2.在SQL节点
server2:192.85.1.4
server3:192.85.1.9
程序代码
#sudo /usr/local/mysql/bin/mysql –u root –p (默认密码为空)
mysql>use test;
mysql> Create TABLE test (name int(10)) ENGINE=NDBCLUSTER;接下来可以在两个SQL节点对表test进行操作,观察数据是否同步.在server2上,插入一条数据,查看server2上是否存在注意:如果要将现有的数据库转移到mysql集群中,应该将数据表的格式有MyISAM或InnoDB该为NDBCLUSTER。创建表时:CREATE TABLE tbl_name (col_name column_definitions) ENGINE=NDBCLUSTER;
Alternatively, for an existing table that uses a different storage engine,
use ALTER TABLE to change the table to use NDBCLUSTER: ALTER TABLE tbl_name ENGINE=NDBCLUSTER;