Ubuntu10.10下MySQL5.1集群配置(2)
[NDBD]
hostname=192.85.1.4
datadir=/var/lib/mysql-cluster
#第二個(gè)NDB節(jié)點(diǎn)
[NDBD]
hostname=192.85.1.9
datadir=/var/lib/mysql-cluster/
#設(shè)置SQL節(jié)點(diǎn)服務(wù)器[MYSQLD]
[MYSQLD]
在server2。server3上創(chuàng)建mysql-cluster目錄,
sudo mkdir -p /var/lib/mysql-cluster
五、啟動(dòng)
1.啟動(dòng)管理:
server1:192.85.1.5
程序代碼
#/usr/local/mysql/bin/ndb_mgmd -f /usr/local/mysql/mysql-cluster/config.ini
2.啟動(dòng)存儲(chǔ)節(jié)點(diǎn)
server2:192.85.1.4
server3:192.85.1.9
程序代碼
# /usr/local/mysql/bin/ndbd –initial (第一次啟動(dòng)或管理節(jié)點(diǎn)的config.ini發(fā)生改變)
#/usr/local/mysql/bin/ndbd (以后啟動(dòng)用這條)
3.啟動(dòng)SQL節(jié)點(diǎn)
server2:192.85.1.4
server3:192.85.1.9
# /usr/local/mysql/bin/mysqld_safe --user=mysql &
六、管理
1.在管理節(jié)點(diǎn)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節(jié)點(diǎn)
server2:192.85.1.4
server3:192.85.1.9
程序代碼
#sudo /usr/local/mysql/bin/mysql –u root –p (默認(rèn)密碼為空)
mysql>use test;
mysql> Create TABLE test (name int(10)) ENGINE=NDBCLUSTER;接下來可以在兩個(gè)SQL節(jié)點(diǎn)對(duì)表test進(jìn)行操作,觀察數(shù)據(jù)是否同步.在server2上,插入一條數(shù)據(jù),查看server2上是否存在注意:如果要將現(xiàn)有的數(shù)據(jù)庫轉(zhuǎn)移到mysql集群中,應(yīng)該將數(shù)據(jù)表的格式有MyISAM或InnoDB該為NDBCLUSTER。創(chuàng)建表時(shí):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;