How to configure a MySQL cluster in a Windows system (MySQL Cluster)

Source: Internet
Author: User
Tags log log

About MySQL cluster (Cluster)

A MySQL cluster requires a set of computers, and the roles of each computer may be different. There are three types of nodes in the MySQL cluster: management nodes, data nodes, and SQL nodes. A computer in a cluster may be a node or a collection of two or three nodes. These three nodes are logically divided, so they do not necessarily correspond to the physical computer one by one.

Management nodes (also known as Management Servers) are primarily responsible for managing data nodes and SQL nodes, as well as cluster configuration files and cluster log files. It monitors the working state of other nodes and is capable of starting, shutting down, or restarting a node. Other nodes retrieve configuration data from the management node, sending event information to the management node and writing to the cluster log when a new event occurs on the data node.

Data nodes are used to store data.

SQL node is the same as the normal MySQL server, we can use it for SQL operations.

The relationships between the three cluster nodes and applications are drawn:

downloads for MySQL cluster

The MySQL server we use has not been able to meet the requirements of the cluster, and the configuration cluster needs to use MySQL Cluster, that is, just download MySQL Cluster, no need to download and install MySQL server. Because the MySQL cluster is already self-contained.

MySQL cluster supports Linux, Mac OS X, Solaris, and Windows operating systems. Take the MySQL Cluster version of MySQL Cluster 7.2.5 under Windows system as an example to illustrate the configuration and startup of MySQL Cluster.

The MySQL cluster is http://dev.mysql.com/downloads/cluster. If your operating system is 32-bit, choose Windows (x86, 32-bit), zip Archive download, size 228.9M, if 64-bit, download windows (x86, 64-bit), Zip Archive, Size is 232.7M. They are both binary versions that are free of installation.

Configuration of MySQL Cluster

First three computers, or three virtual machines, the management node is deployed on one machine, the other two each deploy a data node and a SQL node. Here, for example, one of the two machines (IP 192.168.1.10) deploys the management node, the data node and the SQL node, and the other (IP 192.168.1.20) deploys the data node and the SQL node.

It is best not to deploy the management node with the data node on one machine, because if the data node outage causes the management node to be unavailable, the entire MySQL cluster will not be available. So a MySQL cluster ideally has at least three servers, and the management node is placed on a single server. Chicken Peck Rice to two sets of examples, just to illustrate the configuration of three nodes to start the method.

1. Unzip the installation package downloaded above and change the folder name to MySQL, because it needs to be operated on the command line more than once, so the name is shorter and easier to enter.

2. Configure the Management node

In the IP 192.168.1.10 host's C drive, create a new folder in MySQL, and then create a new subdirectory under this folder bin and Mysql-cluster, and then unpack the package Mysql\bin Ndb_mgm.exe and Ndb_ Mgmd.exe Copy to C:\mysql\bin. Create a new cluster-logs directory, config.ini file, and My.ini file under directory C:\mysql\bin.

The contents of the Config.ini file are as follows:

[NDBDdefault]# Options affecting NDBD processes on all data nodes:# number of Replicasnoofreplicas=2# Directory forEach data node 's Data Files Datadir=c:/mysqlcluster/datanode/mysql/bin/cl Uster-data # Memory allocated to data storage datamemory=80m # Memory allocated T                   o Index Storage indexmemory=18m # for Datamemory and indexmemory, we have used the # default values. [ndb_mgmd]# Management process options:# Hostname or IP address of Management nodehostname=10.0.0.11 # Dir                                Ectory for Management node log filesdatadir=c:/mysql/bin/cluster-logs [ndbd]# Options for Data node "A": # (one [NDBD] section per data node) # Hostname or IP addresshostname=10.0.0.11 [ndbd]# Options F or data node "B": # Hostname or IP addresshostname=10.0.0.10 [mysqld]# SQL node options: # Hostname or IP addressh ostname=10.0.0.11 [mysqld]# SQL node options:# Hostname or IP addresshostname=10.0.0.10 

The contents of the My.ini file are as follows:

 for Management node Processconfig-file=c:/mysql/bin/config.ini

3. Configure the Data node

Create a new folder C:\mysqlcluster\datanode\mysql in the IP 192.168.1.10 host, and then continue with the new subdirectory bin and Cluster-data in this folder, Another subdirectory under the bin is also called Cluster-data.

Copy the Ndbd.exe from the Mysql\bin folder in the installation package to C:\mysqlcluster\datanode\mysql\bin, and in the C:\mysqlcluster\datanode\ Create a new My.ini file in MySQL with the following file contents:

       [Mysql_cluster]        for  data node process:       NDB-connectstring=192.168.1.10      # Location of Management Server

Since the configuration of the data nodes of the two hosts is the same, we can directly copy the folder C:\mysqlcluster from the 192.168.1.10 Host to the C drive of the 192.168.1.20 host.

4. Configuring the SQL Node

Under C:\mysqlcluster of the 192.168.1.10 host, create a new subdirectory Sqlnode, unzip the entire copy of the installation package into this subdirectory, and then in the C:\mysqlcluster\sqlnode\ New My.ini file under MySQL, the file content is:

       [mysqld]       for  mysqld process:       ndbcluster                        # run NDB storage engine        NDB -connectstring=192.168.1.10   # Location of Management Server

The C:\mysqlcluster\sqlnode folder is then copied to the same directory as the 192.168.1.20 host.

MySQL Cluster Start-up

Three types of node services when starting, be sure to follow the start of the management node, after the start of the data node, and then start the SQL node sequence.

1. Start the Management node

Open a command-line window in the 192.168.1.10 host, cut to the C:\mysql\bin directory, and enter:

Ndb_mgmd-f Config.ini--configdir=c:\mysql\mysql-cluster

Enter, the Management node service is started, there may be no prompt on the command line, you can open the C:\mysql\bin\cluster-logs\ndb_1_cluster.log log file to view the boot information. Note that this command-line window cannot be closed unless you want to stop the service.

Note: We can also make it into a service and enter it on the command line:

NDB_MGMD--install=ndb_mgmd-f Config.ini--configdir=c:\mysql\mysql-cluster

2. Start the Data node

Open a new command-line window in the 192.168.1.10 host, cut to directory C:\mysqlcluster\datanode\mysql\bin, and enter:

ndbd

Enter, the data node is started.

Note: We can also make it into a service and enter it on the command line:

NDBD--INSTALL=NDBD

Start the Data node service in the 192.168.1.20 in the same way.

How do I see if it started successfully? We can open a new command line window in the 192.168.1.10 host, cut to the directory C:\mysql\bin, enter:

Ndb_mgm

Enter, and then type:

  All STATUS

Enter, you can see the data node connection information.

3. Start the SQL node

In the 192.168.1.10 host, continue to open a new command-line window, cut to the directory C:\mysqlcluster\sqlnode\mysql\bin, enter:

Mysqld--console

Enter the SQL node to start.

Note: We can also make it into a service, enter:

  Mysqld-install MySQL

Start the SQL node in 192.168.1.20 in the same way.

To view the startup of the SQL node, you can also open a new command line in the 192.168.1.10 host and enter:

Ndb_mgm

Enter, and then type:

SHOW

Enter, you can see the connection of the SQL node.

  Test MySQL Cluster
Database and insert the data ">1, establish the database in SQL Node A and insert the data:

Run the C:\mysqlcluster\sqlnode\mysql\bin\mysql.exe-u root-p command in cmd on SQL Node A on the computer (192.168.1.10) to log in to MySQL, and the next time you need to enter a password, The password defaults to null (direct carriage return).

To create a database and insert data:
-Create a database named "Mysql_cluster_test":

Create Database Mysql_cluster_test;

-Create TABLE "T_user":

   Use  mysql_cluster_test;  Createtablevarchar(int) engine=ndbcluster;

Note that you must add engine=ndbcluster after the build statement

--Insert data:

Insert  into Values ('dannyhoo',+);

-Query data:

Select *  from T_user;

How to configure a MySQL cluster in a Windows system (MySQL Cluster)

Related Article

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.