mysql 7.x 集群_mysql-cluster 7.x安装(windows)

mysql 集群配置(windows2台机器模拟)

1、环境规划

win7 192.168.1.1(管理节点,存储节点,sql节点)

win03 192.168.1.2(存储节点,sql节点)

2、安装cluster(zip包)

win7机器安装在D:\mysql-cluster中

win03机器安装在C:\mysql-cluster中

存储节点存储路径分别为:D:\mysql-cluster\ndbdata和C:\mysql-cluster\ndbdata

3、win7机器配置

创建D:\mysql-cluster\config.txt文件,内容为:

[NDBD DEFAULT]

NoOfReplicas=2

[NDB_MGMD]

ID=1

hostname=192.168.1.1

datadir=D:\mysql-cluster\data

[NDBD]

ID=21

hostname=192.168.1.1

datadir=D:\mysql-cluster\ndbdata

[NDBD]

ID=22

hostname=192.168.1.2

datadir=C:\mysql-cluster\ndbdata

[MYSQLD]

ID=11

hostname=192.168.1.1

[MYSQLD]

ID=12

hostname=192.168.1.2

复制D:\mysql-cluster\my-small.ini到c:\windows\my.ini并添加

[mysqld]

ndbcluster

ndb-connectstring=192.168.1.1

[mysql_cluster]

ndb-connectstring=192.168.1.1

4、win03机器配置

复制C:\mysql-cluster\my-small.ini到c:\windows\my.ini并添加

[mysqld]

ndbcluster

ndb-connectstring=192.168.1.1

[mysql_cluster]

ndb-connectstring=192.168.1.1

5、启动

5.1)启动管理节点(win7 上)

D:\mysql-cluster\bin>ndb_mgmd.exe –config-file=D:\mysql-cluster\config.txt –co

nfigdir=D:\mysql-cluster

5.2)启动存储节点(无先后顺序,第一个启动使用–initial)

win7

D:\mysql-cluster\bin>ndbd.exe –initial

win03

C:\mysql-cluster\bin>ndbd.exe

5.3)启动sql节点(无先后顺序)

win03

C:\mysql-cluster\bin>mysqld.exe –defaults-file=c:\windows\my.ini

win7

d:\mysql-cluster\bin>mysqld.exe –defaults-file=c:\windows\my.ini

6、查看是否启动成功

6.1)查看状态

D:\mysql-cluster\bin>ndb_mgm.exe

– NDB Cluster — Management Client –

ndb_mgm> show

Connected to Management Server at: 192.168.1.1:1186

Cluster Configuration

———————

[ndbd(NDB)] 2 node(s)

id=21 @192.168.1.1 (mysql-5.1.56 ndb-7.1.15, Nodegroup: 0, Master)

id=22 @192.168.1.2 (mysql-5.1.56 ndb-7.1.15, Nodegroup: 0)

[ndb_mgmd(MGM)] 1 node(s)

id=1 @192.168.1.1 (mysql-5.1.56 ndb-7.1.15)

[mysqld(API)] 2 node(s)

id=11 @192.168.1.1 (mysql-5.1.56 ndb-7.1.15)

id=12 @192.168.1.2 (mysql-5.1.56 ndb-7.1.15)

6.2数据操作测试

在win7上创建表,并插入数据

C:\Users\XIFENFEI>mysql -uroot

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 2

Server version: 5.1.56-ndb-7.1.15-cluster-gpl MySQL Cluster Server (GPL)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

mysql> use test;

Database changed

mysql> create table city(

-> id mediumint unsigned not null auto_incremen

-> name varchar(20) not null default ”

-> ) engine = ndbcluster default charset utf8;

Query OK, 0 rows affected (9.60 sec)

mysql> insert into city values(1, ‘city1′);

Query OK, 1 row affected (0.41 sec)

mysql> insert into city values(2, ‘city2′);

Query OK, 1 row affected (0.01 sec)

mysql> select * from city;

+—-+——-+

| id | name |

+—-+——-+

| 1 | city1 |

| 2 | city2 |

+—-+——-+

2 rows in set (0.00 sec)

win03机器查看数据

C:\mysql-cluster\bin>mysql -uroot

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 2

Server version: 5.1.56-ndb-7.1.15-cluster-gpl MySQL Cluster Server (GPL)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.

This software comes with ABSOLUTELY NO WARRANTY. This is free software,

and you are welcome to modify and redistribute it under the GPL v2 license

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

mysql> use test;

Database changed

mysql> show tables;

+—————-+

| Tables_in_test |

+—————-+

| city |

+—————-+

1 row in set (0.11 sec)

mysql> select * from city;

+—-+——-+

| id | name |

+—-+——-+

| 1 | city1 |

| 2 | city2 |

+—-+——-+

2 rows in set (0.05 sec)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值