Configure MySQL Cluster in Windows environment

Source: Internet
Author: User

First, preparatory work

First of all have to prepare the hardware facilities, I here are 3 machines in the cluster, the structure is as follows:

Management node (MGM) 172.16.0.162 (DB1)

SQL Node 1 (SQL1) 172.16.0.161 (DB2)

SQL Node 2 (SQL2) 172.16.0.202 (DB3)

Data node 1 (NDBD1) 172.16.0.161 (DB4)

Data Node 2 (NDBD2) 172.16.0.202 (DB4)

This hardware is done, now we're doing the software.

It's best to download more than 7, because the performance is good, 7.2 this version of the new features on the introduction is: Adaptive query localization (AQL) complex connection speed increased by 70 times. Of course it is not so I have not tested the unclear.

  Second, the installation of software

Extract Mysql-cluster-gpl-7.2.9-win32.zip Package

Installation configuration for Management node.

Management node must be installed under the C disk, and is the following directory (this is the error in running this node times, saying that the corresponding directory is not found). On an IP-172.16.0.162 machine

Generate C:/mysql/bin, C:/mysql/mysql-cluster (a ndb_1_config.bin.1-like file is generated in this folder after the first startup, as if it were to start the loaded configuration at a later time)

and c:/mysql/bin/cluster-logs directory, copy Ndb_mgmd.exe and Ndb_mgm.exe to 172.16.0.162 directory in the downloaded files directory mysql/bin.

Two files, My.ini and Config.ini, are generated under the 172.16.0.162 c:/mysql/bin.

The contents of the My.ini are:

[Plain]view plaincopyprint?

[Mysql_cluster]

# Options for Management node process

Config-file=c:/mysql/bin/config.ini

[Mysql_cluster] # Options for Management node process Config-file=c:/mysql/bin/config.ini

Config.ini content: (Note: ID cannot start from 0, must be greater than 0)

[Html]view plaincopyprint?

[NDBD DEFAULT]

noofreplicas=2

Datadir=d:/program Files/mysqlcluster/datanode/mysql/bin/cluster-data

datamemory=80m

indexmemory=18m

[MYSQLD DEFAULT]

[NDB_MGMD DEFAULT]

[TCP DEFAULT]

[NDB_MGMD]

Id=1

hostname=172.16.0.162 #管理节点服务器

# Storage Engines

Datadir=c:/mysql/bin/cluster-logs

[NDBD]

id=2

hostname=172.16.0.161 #MySQL集群db1的IP地址

#DataDir = D:/program Files/mysqlcluster/datanode/mysql/bin/cluster-data #如果不存在就创建一个

[NDBD]

Id=3

hostname=172.16.0.202 #MySQL集群db2的IP地址

#DataDir = D:/program Files/mysqlcluster/datanode/mysql/bin/cluster-data #如果不存在就创建一个

[MYSQLD]

Id=4

hostname=172.16.0.161

[MYSQLD]

Id=5

hostname=172.16.0.202

[NDBD DEFAULT] Noofreplicas=2datadir=d:/program files/mysqlcluster/datanode/mysql/bin/cluster-datadatamemory=80mindexmemory= 18m[mysqld DEFAULT][NDB_MGMD default][tcp default][ndb_mgmd]id=1hostname=172.16.0.162 #管理节点服务器 # Storage enginesdatadir=c:/mysql/bin/cluster-logs[ndbd]id=2hostname=172.16.0.161 #MySQL集群db1的IP地址 #datadir= D:/Program Files/mysqlcluster/datanode/mysql/bin/cluster-data #如果不存在就创建一个 [ndbd]id=3hostname=172.16.0.202 #MySQL集群db2的IP地址 # datadir= d:/program files/mysqlcluster/datanode/mysql/bin/cluster-data #如果不存在就创建一个 [mysqld]id=4hostname= 172.16.0.161[mysqld]id=5hostname=172.16.0.202

Installation configuration for Data nodes

Generate D:/program Files/mysqlcluster/datanode/mysql/bin, D:/program files/mysqlcluster/datanode/on an IP-172.16.0.161 machine Mysql/cluster-data,

D:/program Files/mysqlcluster/datanode/mysql/bin/cluster-data. In the downloaded uncompressed folder/bin, copy Ndbd.exe to

172.16.0.161 the D:/program files/mysqlcluster/datanode/mysql/bin directory,

The My.ini file is generated in the D:/program Files/mysqlcluster/datanode/mysql/bin directory, and the contents of the file are:

[Html]view plaincopyprint?

[Mysql_cluster]

# Options for data node process:

NDB-CONNECTSTRING=172.16.0.162 # Location of Management Server

[Mysql_cluster] # Options for data node process:ndb-connectstring=172.16.0.162 # Location of Management Server empathy in 172.16.0 .202 the same configuration on the machine, can also be copied directly to the 172.16.0.202 machine.

Installation configuration for SQL node

Generate D:/program Files/mysqlcluster/sqlnode directory on the IP-172.16.0.161 machine, and copy the downloaded Extract folder directly to the d:/programfiles/mysqlcluster/ Sqlnode/mysql directory, the My.ini file is generated under D:/programfiles/mysqlcluster/sqlnode/mysql, and the contents of the file are:

[Html]view plaincopyprint?

[Html]view plaincopyprint?

[Mysqld]

# Options for Mysqld Process:ndbcluster

[Mysqld] # Options for mysqld Process:ndbcluster

[Html]view plaincopyprint?

# Run NDB Storage engine

ndb-connectstring=172.16.0.154

# Location of Management Server

# Run NDB storage Engine ndb-connectstring=172.16.0.154 # Location of Management Server in the same vein, D:/program files/mysqlcluster/ Sqlnode the entire folder to the same directory as the 172.16.0.202 machine.

 Third, start the cluster

The start of each node is sequential, first management node, then data nodes, and finally SQL nodes.

A, Start Management node to enter the command line under the 172.16.0.162 machine, go to the C:/mysql/bin directory, enter:

Ndb_mgmd-f Config.ini

(

If you report the following error: MySQL Cluster Management Server mysql-5.5.28 ndb-7.2.9

2013-05-03 10:13:10 [Mgmtsrvr] INFO--The default Config directory ' C:/prog

Ram Files/mysql/mysql Server 5.5/mysql-cluster ' does not exist. Trying to create

It ...

Failed to create directory ' C:/Program files/mysql/mysql Server 5.5/mysql-cluste

R ', Error:3

2013-05-03 10:13:10 [Mgmtsrvr] ERROR--Could not create directory ' C:/progra

M files/mysql/mysql Server 5.5/mysql-cluster '. Either create it manually or spec

Ify a different directory with--configdir=

The following folder is created: C:Program filesmysqlmysql Server 5.5

)

b, Start data node

Enter the command line under the 172.16.0.161, and go to the D:/program files/mysqlcluster/datanode/mysql/bin directory and enter:

NDBD--connect-string= "nodeid2;host=172.16.0.162:1186"

Similarly starting 172.16.0.202, Nodeid2 is based on the configuration file of the admin node

The ID in the config.ini determines that if the ID is 2, the NODEID2 is not specified in the configuration file

IDs are executed sequentially.

(note) At this point, you can go to the new command line in management node

C:/mysql/bin directory to enter the command:

Ndb_mgm

Start Ndb_mgm.exe, and then enter the command:

All STATUS

Check to see if the Data node connection was successful. After booting to normal

Sqlnode

c, start SQL node

Enter the command line under the 172.16.0.161 and go to D:/program

Files/mysqlcluster/sqlnode/mysql/bin directory, enter:

Mysqld--console

Start SQL node under 172.16.0.202 in the same way.

(note): You can go to the C:/mysql/bin directory by following the machine in the Management node node

Enter the command:

Ndb_mgm

Start Ndb_mgm.exe, and then enter the command:

Show

You can view the connections to each node.

The correct display should be:

Four, test

(Note: Be sure to add engine = ndbcluster default CharSet UTF8 when creating a table; Ndbcluster: Indicates that the table is operational for data nodes; default charset: For setting the character set)

C:>mysql-u Root Test

Mysql>create Table City (nId mediumint unsigned NOT NULL

Auto_increment primary KEY, sname varchar NOT NULL)

Engine = ndbcluster default CharSet UTF8;

Mysql>insert City VALUES (1, ' city-1′);

Mysql>insert City VALUES (1, ' city-2′);

Log on to MySQL on another SQL node and get records from Table city:

C:>mysql-u Root Test

Mysql>select * from city;

When the cluster system is working properly, you should be able to take all the records that were previously inserted. Remember to add ";" After the statement is complete. (semicolon) Oh, kiss!

Additional tests (single point of failure test):

1, you can also stop a data node (CTRL + C interrupt DOS command Ndbd.exe, stop the service), to see if all the SQL node is working properly.

2, the database operation is performed after a data node is stopped. Then reopen the data node to see if all the SQL nodes in the cluster can get the full data.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.