硬件件条件:
- ip:192.168.12.48
软件条件:
- mysql-cluster-gpl-7.0.9-win32.msi,安装目录:D:\Program Files\MySQL\MySQL Server 7.0
- !!!以后的所有目录设置均为安装目录位置作为基准!!!所有有关目录的设置,请参见之后的配置文件,各位看官自行实验时必须保证目录有效且事先存在!
管理节点配置文件:.\Data\mysql_cfg\my_cluster.ini
内容如下:
![ContractedBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![ExpandedBlockStart.gif](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
2 NoOfReplicas = 2 # 默认值是2.
3 DataDir = D:\Program Files\MySQL\MySQL Server 7.0 \Data\user_data #如果不存在就创建一个
4
5 # Managment Server
6 [ NDB_MGMD ]
7 nodeid = 40
8 HostName = 192.168.12.48 #管理节点服务器db1的IP地址
9
10 # Storage Engines
11 [ NDBD ]
12 nodeid = 11
13 HostName = 192.168.12.48 #MySQL集群db1的IP地址
14 [ NDBD ]
15 nodeid = 12
16 HostName = 192.168.12.48 #MySQL集群db3的IP地址
17
18 [ MYSQLD ]
19 nodeid = 1
20 HostName = 192.168.12.48
21 [ MYSQLD ]
22 nodeid = 2
23 HostName = 192.168.12.48
24 [ MYSQLD ]
25 nodeid = 3
26 HostName = 192.168.12.48
启动管理服务:
"D:\Program Files\MySQL\MySQL Server 7.0\bin\ndb_mgmd.exe" --config-file="D:/Program Files/MySQL/MySQL Server 7.0/data/mysql_cfg/my_cluster.ini" --initial
启动管理客户端,show 下状态:
![ContractedBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![ExpandedBlockStart.gif](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
ndb_mgm> show
Connected to Management Server at: localhost: 1186
Cluster Configuration
---------------------
[ ndbd(NDB) ] 2 node(s)
id = 11 (not connected , accepting connect from 192.168.12.48 )
id = 12 (not connected , accepting connect from 192.168.12.48 )
[ ndb_mgmd(MGM) ] 1 node(s)
id = 40 @ 192.168.12.48 (mysql- 5.1.39 ndb- 7.0.9 )
[ mysqld(API) ] 3 node(s)
id = 1 (not connected , accepting connect from 192.168.12.48 )
id = 2 (not connected , accepting connect from 192.168.12.48 )
id = 3 (not connected , accepting connect from 192.168.12.48 )
ndb_mgm> Node 11 : Started (version 7.0.9 )
Node 12 : Started (version 7.0.9 )
配置node1,使用 通用配置文件来配置数据节点和mysqld节点:.\Data\user_data\node1\my_node1.ini
内容如下:
![ContractedBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![ExpandedBlockStart.gif](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
[ mysqld ]
basedir = " D:/Program Files/MySQL/MySQL Server 7.0 "
default-character-set = utf8
default-storage-engine = NDBCLUSTER
sql-mode = " STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION "
port = 33061
datadir = " D:/Program Files/MySQL/MySQL Server 7.0/data/user_data/node1/ "
general_log_file = " D:/Program Files/MySQL/MySQL Server 7.0/data/user_data/node1/general_log.log "
#
ndbcluster
ndb_connectstring = " 192.168.12.48 "
#
skip_innodb
#
[ ndbd ]
ndb_connectstring = " 192.168.12.48 "
node2 和 node3 同样类似设置:注意红色字体部分,改变port端口为别为 33062、33063;路径字符串中 的 1 设置为 2、3。
再次提醒:必须保证路径存在啊!!!!!!!!!!!!
提示:node3 的配置文件中可以没有 [ndbd] 节的设置,当然,你可以设置,只要不启动 ndbd程序就行了,为了好看、统一,设置吧
接下来 :将mysql的 基础数据库 【mysql】——安装mysql-cluster-gpl-7.0.9-win32.msi软件时制定的位置,别说不知道啊——文件夹 分别拷贝到 node 1 的 D:/Program Files/MySQL/MySQL Server 7.0/data/user_data/node1下 ,完成之后类似于: D:/Program Files/MySQL/MySQL Server 7.0/data/user_data/node1\mysql\
同样这样做,拷贝到node 2 和 node 3的 数据文件夹下。
启动 数据节点 node 1:"D:\Program Files\MySQL\MySQL Server 7.0\bin\ndbd.exe" --defaults-file="D:\Program Files\MySQL\MySQL Server 7.0\data\user_data\node1\my_node1.ini"
启动 数据节点 node 2:"D:\Program Files\MySQL\MySQL Server 7.0\bin\ndbd.exe"--defaults-file="D:\Program Files\MySQL\MySQL Server7.0\data\user_data\node2\my_node2.ini"
启动 mysqld 节点 node 1:"D:\Program Files\MySQL\MySQL Server 7.0\bin\mysqld.exe" --defaults-file="D:\Program Files\MySQL\MySQL Server 7.0\data\user_data\node1\my_node1.ini" --console
启动 mysqld 节点 node 2:"D:\Program Files\MySQL\MySQL Server7.0\bin\mysqld.exe" --defaults-file="D:\Program Files\MySQL\MySQLServer 7.0\data\user_data\node2\my_node2.ini" --console
启动 mysqld 节点 node 3:"D:\Program Files\MySQL\MySQL Server7.0\bin\mysqld.exe" --defaults-file="D:\Program Files\MySQL\MySQLServer 7.0\data\user_data\node3\my_node3.ini" --console
应该不会出现什么问题的:最后可以在 群集管理客户端 中 show 下状态:
![ContractedBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![ExpandedBlockStart.gif](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
Cluster Configuration
---------------------
[ ndbd(NDB) ] 2 node(s)
id = 11 @ 192.168.12.48 (mysql- 5.1.39 ndb- 7.0.9 , Nodegroup: 0 , Master)
id = 12 @ 192.168.12.48 (mysql- 5.1.39 ndb- 7.0.9 , Nodegroup: 0 )
[ ndb_mgmd(MGM) ] 1 node(s)
id = 40 @ 192.168.12.48 (mysql- 5.1.39 ndb- 7.0.9 )
[ mysqld(API) ] 3 node(s)
id = 1 @ 192.168.12.48 (mysql- 5.1.39 ndb- 7.0.9 )
id = 2 @ 192.168.12.48 (mysql- 5.1.39 ndb- 7.0.9 )
id = 3 @ 192.168.12.48 (mysql- 5.1.39 ndb- 7.0.9 )
ok 如果到这,说明你成功了!