Windows環境配置MySQL集群 一、Cluster環境搭建 1、mysql Cluster(MySQL Cluster 7.5.4)文件下載地址:http://dev.mysql.com/downloads/cluster/ 2、準備三台伺服器(虛擬機,本人使用的是Windows Server ...
Windows環境配置MySQL集群
一、Cluster環境搭建
1、mysql Cluster(MySQL Cluster 7.5.4)文件下載地址:http://dev.mysql.com/downloads/cluster/
2、準備三台伺服器(虛擬機,本人使用的是Windows Server 2008 R2 enterprise),一臺用於配置管理節點,另外兩台每台配置一個數據節點和一個SQL節點:
管理節點:192.168.108.128
數據節點A:192.168.108.129
數據節點B:192.168.108.130
SQL節點A:192.168.108.129
SQL節點B:192.168.108.130
3、將下載壓縮包解壓到每臺電腦的C:/mysql目錄下(其他盤也可以)
在管理節點C:\Mysql\Bin目錄下建立cluster-logs和config兩個文件夾cluster-logs用來存儲日誌文件,在config文件夾中建立my.ini和config.ini兩個配置文件:
my.ini
[mysql_cluster]
# Options for management node process
config-file=C:/mysql/bin/config/config.ini
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.108.128 # 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":
HostName=192.168.108.130 # Hostname or IP address
[ndbd]
# Options for data node "B":
HostName=192.168.108.129 # Hostname or IP address
[mysqld]
# SQL node A options:
HostName=192.168.108.130 # Hostname or IP address
[mysqld]
# SQL node B options:
HostName=192.168.108.129 # Hostname or IP address
4、在配置數據節點(192.168.108.129、192.168.108.130)的電腦上的C:\Mysql\Bin目錄下建立cluster-data文件夾,用來存放數據
5、至此,環境安裝完成
二、Cluster集群啟動
1、關閉防火牆
2、開啟管理工具
CMD命令:c:\mysql\bin\ndb_mgmd.exe --configdir=c:\mysql\bin\config --config-file=c:\mysql\bin\config\config.ini --ndb-nodeid=1 --reload –initial
3、開啟數據節點(註:必須以管理員運行dos,否則報錯)
CMD命令:c:\mysql\bin\ndbd.exe --ndb-connectstring=192.168.108.128
4、執行命令初始化mysql命令添加data目錄(巨坑)
CMD命令:C:\mysql\bin\mysqld --initialize-insecure --user=mysql
5、開啟sql節點
CMD命令:c:\mysql\bin\mysqld.exe --ndbcluster --ndb-connectstring=192.168.108.128 --console