Mysql集群的基本架構如下:
基本原理參考:【轉】MySQL Cluster (集群)基本原理
這里采用最小配置,用兩台機器來分別部署一個management 節點,2個data node, 2個sql node.
Management Node: 192.168.0.102
Data Node A: 192.168.0.102
Data Node B: 192.168.0.104
Sql Node A: 192.168.0.102
Sql Node B: 192.168.0.104
1. 首先從Mysql官方網站上下載最新的Mysql Cluster免安裝包 (http://downloads.mysql.com/archives/cluster/)
注意我們下載的是ZIP Archive
2.將免安裝包分別解壓到兩台機器的C:\Mysql文件夾下
3. 在Management Node的C:\Mysql\Bin下新建Config文件夾,用來存放cluster的配置文件。
3.1首先需要為management node創建一個默認配置文件my.ini ,內容如下:
[mysql_cluster]
# Options for management node process
config-file=C:/mysql/bin/config/config.ini3.2 創建整個cluster的配置文件config.ini
[ndbd default]
# Options affecting ndbd processes on all data nodes:
NoOfReplicas=2 # Number of replicas
DataDir=C:/mysql/bin/cluster-data # Directory for each data node's data files
# Forward slashes used in directory path,
# rather than backslashes. This is correct;
# see Important note in text
DataMemory=80M # Memory allocated to data storage
IndexMemory=18M # Memory allocated to index storage
# For DataMemory and IndexMemory, we have used the
# default values. Since the "world" database takes up
# only about 500KB, this should be more than enough for
# this example Cluster setup.[ndb_mgmd]
# Management process options:
HostName=192.168.0.102 # Hostname or IP address of management node
DataDir=C:/mysql/bin/cluster-logs # Directory for management node log files[ndbd]
# Options for data node "A":
# (one [ndbd] section per data node)
HostName=192.168.0.102 # Hostname or IP address[ndbd]
# Options for data node "B":HostName=192.168.0.104 # Hostname or IP address
[mysqld]
# SQL node A options:HostName=192.168.0.102 # Hostname or IP address
[mysqld]
# SQL node B options:HostName=192.168.0.104 # Hostname or IP address
4. 啟動Management Node,命令如下:
c:\mysql\bin\ndb_mgmd.exe --configdir=c:\mysql\bin\config --config-file=c:\mysql\bin\config\config.ini --ndb-nodeid=1 --reload –initial
5.啟動Data Node A,命令如下:
c:\mysql\bin\ndbd.exe --ndb-connectstring=192.168.0.102
6.啟動Data Node B,命令如下:
c:\mysql\bin\ndbd.exe --ndb-connectstring=192.168.0.102
7.可以打開management client來查看cluster當前的狀態
8.Data Node均啟動后,接下來分別啟動兩個Sql Node,命令如下:
c:\mysql\bin\mysqld.exe --ndbcluster --ndb-connectstring=192.168.0.102 --console
9. 通過management client查看cluster的當前狀態
10.至此,cluster已經成功啟動。
11.在Sql Node A上創建數據庫ClusterSample
注:默認root密碼為空
12.在Sql Node A上創建數據表Person;
13. 通過Sql Node A插入數據;
14.在Sql Node B上去查詢數據







