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