前言:亲爱的CU朋友们,大家好,好久不见了,想大家了。 

正题:以下是把所有服务都装在一台服务器上方法,多台机器可依IP拆分。
准备工作:下载安装windows x64 mysql cluster 7.2.5,不用它的向导配置和启动服务等。
准备工作:给服务器加6个IP:192.168.130.11/12/21/22/31/32

1、建好配置文件:
A、文件 C:\Program Files\MySQL\MySQL Cluster 5.5\conf\mysqld_1.ini 的内容
[mysqld]
datadir = "D:\MysqlData\mysqld_1_data"
bind-address = 192.168.130.11
ndb-connectstring = 192.168.130.31:8186
port = 8306
ndbcluster
basedir = "C:\Program Files\MySQL\MySQL Cluster 5.5"
-------------
B、文件 C:\Program Files\MySQL\MySQL Cluster 5.5\conf\mysqld_2.ini 的内容
[mysqld]
datadir = "D:\MysqlData\mysqld_2_data"
bind-address = 192.168.130.12
ndb-connectstring = 192.168.130.32:8186
port = 8306
ndbcluster
basedir = "C:\Program Files\MySQL\MySQL Cluster 5.5"
-------------
C、文件 C:\Program Files\MySQL\MySQL Cluster 5.5\conf\ndbd_all.ini 的内容
[ndb_mgmd]
NodeId = 31
hostname = 192.168.130.31
datadir = D:\MysqlData\ndbd_1_data
PortNumber = 8186
[ndb_mgmd]
NodeId = 32
hostname = 192.168.130.32
datadir = D:\MysqlData\ndbd_2_data
PortNumber = 8186
[ndbd default]
NoOfReplicas = 2
[ndbd]
NodeId = 21
hostname = 192.168.130.21
datadir = D:\MysqlData\ndbd_1_data
[ndbd]
NodeId = 22
hostname = 192.168.130.22
datadir = D:\MysqlData\ndbd_2_data
[mysqld]
NodeId = 11
hostname = 192.168.130.11
[mysqld]
NodeId = 12
hostname = 192.168.130.12
##注意这里mysqld的hostname写ip意味着测试时启动mysqld可能要--skip-grant-tables(不安全)或修改mysql.user.host的权限
-------------------------------------------------------------------------------------------------------------------------------------------------

2、启动管理服务器:
"C:\Program Files\MySQL\MySQL Cluster 5.5\bin\ndb_mgmd.exe" --config-file="C:\Program Files\MySQL\MySQL Cluster 5.5\conf\ndbd_all.ini" --skip-config-cache --ndb-nodeid=31 --bind-address=192.168.130.31

"C:\Program Files\MySQL\MySQL Cluster 5.5\bin\ndb_mgmd.exe" --config-file="C:\Program Files\MySQL\MySQL Cluster 5.5\conf\ndbd_all.ini" --skip-config-cache --ndb-nodeid=32 --bind-address=192.168.130.32
注意:第一次启动都要加--initial参数,以后启动别加这个参数。
-------------------------------------------------------------------------------------------------------------------------------------------------

3、检查管理服务器状态:
"C:\Program Files\MySQL\MySQL Cluster 5.5\bin\ndb_mgm.exe" -c 192.168.130.31:8186 -e show
能看到
Connected to Management Server at: 192.168.130.31:8186
Cluster Configuration
[ndbd(NDB)]     2 node(s)
id=21 (not connected, accepting connect from 192.168.130.21)
id=22 (not connected, accepting connect from 192.168.130.22)
[ndb_mgmd(MGM)] 2 node(s)
id=31   @192.168.130.32  (mysql-5.5.20 ndb-7.2.5)
id=32   @192.168.130.32  (mysql-5.5.20 ndb-7.2.5)
[mysqld(API)]   2 node(s)
id=11 (not connected, accepting connect from any host)
id=12 (not connected, accepting connect from any host)
-------------------------------------------------------------------------------------------------------------------------------------------------

4、启动ndbd服务器:
"C:\Program Files\MySQL\MySQL Cluster 5.5\bin\ndbd.exe" -c 192.168.130.31:8186 --ndb-nodeid=21 --bind-address=192.168.130.21

"C:\Program Files\MySQL\MySQL Cluster 5.5\bin\ndbd.exe" -c 192.168.130.32:8186 --ndb-nodeid=22 --bind-address=192.168.130.22
注意:第一次启动要加--initial参数,以后启动别加这个参数(千万别加否则后果自负)。
-------------------------------------------------------------------------------------------------------------------------------------------------

5、启动mysqld服务器:
"C:\Program Files\MySQL\MySQL Cluster 5.5\bin\mysqld.exe" --defaults-file="C:\Program Files\MySQL\MySQL Cluster 5.5\conf\mysqld_1.ini" --ndb-nodeid=11 --skip-grant-tables

"C:\Program Files\MySQL\MySQL Cluster 5.5\bin\mysqld.exe" --defaults-file="C:\Program Files\MySQL\MySQL Cluster 5.5\conf\mysqld_2.ini" --ndb-nodeid=12 --skip-grant-tables
-------------------------------------------------------------------------------------------------------------------------------------------------

6、现在完整的启动完了,可以看看变化:
A、命令 "C:\Program Files\MySQL\MySQL Cluster 5.5\bin\ndb_mgm.exe" -c 192.168.130.31:8186 -e show 有如下内容
Connected to Management Server at: 192.168.130.31:8186
Cluster Configuration
[ndbd(NDB)]     2 node(s)
id=21   @192.168.130.32  (mysql-5.5.20 ndb-7.2.5, Nodegroup: 0, Master)
id=22   @192.168.130.32  (mysql-5.5.20 ndb-7.2.5, Nodegroup: 0)
[ndb_mgmd(MGM)] 2 node(s)
id=31   @192.168.130.32  (mysql-5.5.20 ndb-7.2.5)
id=32   @192.168.130.32  (mysql-5.5.20 ndb-7.2.5)
[mysqld(API)]   2 node(s)
id=11   @192.168.130.31  (mysql-5.5.20 ndb-7.2.5)
id=12   @192.168.130.32  (mysql-5.5.20 ndb-7.2.5)
-------------
B、目录 D:\MysqlData\ndbd_1_data 和 D:\MysqlData\ndbd_2_data 下面,分别有5个文件加一个文件夹,分别共111个文件和35个夹,分别占了1G空间
-------------
C、命令 netstat -an 有如下内容
  TCP    192.168.130.11:8306    0.0.0.0:0              LISTENING
  TCP    192.168.130.12:8306    0.0.0.0:0              LISTENING
  TCP    192.168.130.21:63033   0.0.0.0:0              LISTENING
  TCP    192.168.130.21:63034   0.0.0.0:0              LISTENING
  TCP    192.168.130.21:63035   0.0.0.0:0              LISTENING
  TCP    192.168.130.22:63043   0.0.0.0:0              LISTENING
  TCP    192.168.130.22:63044   0.0.0.0:0              LISTENING
  TCP    192.168.130.31:8186    0.0.0.0:0              LISTENING
  TCP    192.168.130.32:8186    0.0.0.0:0              LISTENING
-------------------------------------------------------------------------------------------------------------------------------------------------

7、关闭集群服务器:
A、先关mysqld
"C:\Program Files\MySQL\MySQL Cluster 5.5\bin\mysqladmin.exe" -u root -h 192.168.130.11 -P8306 shutdown
"C:\Program Files\MySQL\MySQL Cluster 5.5\bin\mysqladmin.exe" -u root -h 192.168.130.12 -P8306 shutdown
-------------
B、再关ndbd及mgm
"C:\Program Files\MySQL\MySQL Cluster 5.5\bin\ndb_mgm.exe" -c 192.168.130.31:8186 -e shutdown
-------------
显示
Connected to Management Server at: 192.168.130.31:8186
4 NDB Cluster node(s) have shutdown.
Disconnecting to allow management server to shutdown.
即正常关闭了所有东东
-------------------------------------------------------------------------------------------------------------------------------------------------

8、把以上命令加为服务,以及服务的依赖性,看windows的sc命令吧

结语:现在比较懒了,写个笔记不容易,转载请保留原样,谢谢!

 

转自:[原创]Mysql集群服务器 windows mysql cluster 7.2.5 快速安装指南

http://bbs.chinaunix.net/forum.php?mod=viewthread&tid=3690808&fromuid=26934996