數據庫數據節點: 192.168.100.65,192.168.100.58
數據庫sql節點: 192.168.100.65,192.168.100.58
NoOfReplicas=2
DataMemory=80M
IndexMemory=18M //這裏有很多參數,大家可以自己找下相關資料
Id=1
Hostname=10.10.1.151 //管理節點IP
datadir=/usr/local/mysql/logs
Id=2
Hostname=10.10.1.65 //數據節點IP
datadir=/usr/local/mysql/data/ //數據節點的數據目錄,這裏要與數據節點的配置文件my.cnf
Id=3
Hostname=10.10.1.58 //數據節點IP
datadir=/usr/local/mysql/data/
[MYSQLD]
ndbcluster
ndb-connectstring=10.10.1.151
[ndbd]
connect-string=10.10.1.151
[mysql_cluster]
ndb-connectstring=10.10.1.151
[ndb_mgm]
connect-string=192.168.1.151
[ndb_mgmd]
config-file=/var/lib/mysql-cluster/config.ini //這裏要指定管理節點配置文件路徑
tcp 0 0 10.10.1.65:32975 0.0.0.0:* LISTEN 1901/ndbd
tcp 0 0 10.10.1.65:32976 0.0.0.0:* LISTEN 1901/ndbd
tcp 0 0 10.10.1.65:32977 0.0.0.0:* LISTEN 1901/ndbd
ndb_mgm> show
Connected to Management Server at: localhost:1186
Cluster Configuration
---------------------
[ndbd(NDB)] 2 node(s)
id=2 @10.10.1.65 (mysql-5.1.37 ndb-7.0.8, Nodegroup: 0, Master)
id=3 @10.10.1.58 (mysql-5.1.37 ndb-7.0.8, Nodegroup: 0)
id=1 @10.10.1.151 (mysql-5.1.37 ndb-7.0.8)
id=4 @10.10.1.65 (mysql-5.1.37 ndb-7.0.8)
id=5 @10.10.1.58 (mysql-5.1.37 ndb-7.0.8)
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| ndb_2_fs |
| test |
+--------------------+
mysql> create database aa;
mysql> use aa
mysql> CREATE TABLE ctest2 (i INT) ENGINE=NDB; //這裏必須指定數據庫表的引擎爲NDB,否則同
mysql> INSERT INTO ctest2 () VALUES (1);
mysql> SELECT * FROM ctest2;
+------+
| i |
+------+
| 1 |
+------+
+--------------------+
| Database |
+--------------------+
| information_schema |
| aa |
| bb |
| mysql |
| ndb_3_fs |
| test |
+--------------------+
mysql> use aa
mysql> select * from ctest2;
+------+
| i |
+------+
| 1 |
+------+
Cluster Configuration
---------------------
[ndbd(NDB)] 2 node(s)
id=2 (not connected, accepting connect from 10.10.1.65)
id=3 @10.10.1.58 (mysql-5.1.37 ndb-7.0.8, Nodegroup: 0, Master)
id=1 @10.10.1.151 (mysql-5.1.37 ndb-7.0.8)
id=4 (not connected, accepting connect from any host)
id=5 @10.10.1.58 (mysql-5.1.37 ndb-7.0.8)
mysql> show tables;
+--------------+
| Tables_in_aa |
+--------------+
| ctest2 |
| ctest3 |
+--------------+
mysql> insert into ctest3 values(1);
mysql> select * from ctest3;
+------+
| id |
+------+
| 1 |
+------+
+--------------------+
| Database |
+--------------------+
| information_schema |
| aa |
| bb |
| mysql |
| ndb_2_fs |
| test |
+--------------------+
mysql> use aa
mysql> show tables;
+--------------+
| Tables_in_aa |
+--------------+
| ctest |
| ctest2 |
| ctest3 |
+--------------+
mysql> select * from ctest3;
+------+
| id |
+------+
| 1 |
+------+