MySQL Cluster---②windows platform to build MySQL cluster cluster

Source: Internet
Author: User
Tags log log

This article will be through two computers Here's a quick introduction to how the Windows platform builds MySQL clusters.

MySQL cluster supports multiple computers, the MySQL cluster built in this article for example, two, one (IP for 192.168.24.33) deployment Management node, data node and SQL node, and another (IP for 192.168.24.82) deployment data node and SQL node.

In practice, do not 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 is unavailable. So a MySQL cluster ideally has at least three servers, and the management node is placed on a single server. Here are two sets of examples, just to illustrate the configuration of three nodes to start the method.


a brief introduction to the three types of nodes that MySQL cluster involves:

The Management node (also called the Management Server) is the core of the whole cluster environment, which is similar to the dispatching function in the cluster, which is responsible for managing the opening, shutting down or restarting a node of other nodes ( data node and SQL node ), etc. 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. This management node is also available from the MySQL 5.6 version, the visible database for the direction of the cluster is putting forward new requirements and new challenges, perhaps in the later version of the cluster will become very simple, look forward to the next version of more powerful features.

data nodes are used to store data, such as the user's data, databases, tables, views, stored procedures, and so on, in the data node.

The SQL node (that is, the MySQL service server) is the same as the normal MySQL server, which manages and maintains the data, providing various services to the database, such as operational database, security, and backup.

The following is a brief description of the MySQL cluster build process:


First, this example MySQL cluster needs the environment

1. Two computers (I use two computer with WINDOWS8 operating system).

2.MySQL cluster software, website address: http://dev.mysql.com/downloads/cluster/

(I use the MySQL cluster version as: Mysql-cluster-gpl-7.3.5-winx64.zip )

Note: download the appropriate MySQL version, including the platform and installation method, recommended download zip version, easy to configure and migrate


Second, configure MySQL Cluster

1. Configure the Management node

1.1 Create a new folder in the C-packing directory of the host with IP 192.168.24.33 MySQL, and then create a new subdirectory under this folder bin and mysql-cluster , and then copy the Ndb_mgm.exe and Ndb_mgmd.exe under the Bin directory in the installation package to C:\mysql\bin. Create a new cluster-logs directory, config.ini file, and My.ini file under directory C:\mysql\bin.


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

[NDBD Default] # Options affecting NDBD processes on all data nodes: # Number of replicasnoofreplicas=2 DATADIR=C:/MYSQLCL  Uster/datanode/mysql/bin/cluster-data # Directory for each data node ' s data files # Memory  Allocated to data storage datamemory=80m# Memory allocated to 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 node management node hostname=192.168.24.33                                # Directory for Management node log files DATADIR=C:/MYSQL/BIN/CLUSTER-LOGS[NDBD] # Options for data node "A": # (one [NDBD] section per data node) # Hostname or IP address data nodes hostname=192.168.24.33 [NDB D] # Options for data node "B": # Hostname or IP addresshostname=192.168.24.82 [mysqld] # SQL node Options: # Hos Tname or IP Address SQL node hostname=192.168.24.33 [mysqld] # SQL node Options: # Hostname or IP addresshostname=192.168.24.82  

The contents of 1.3 My.ini are as follows

[mysql_cluster]# Options for Management node Processconfig-file=c:/mysql/bin/config.ini

2. Configure the Data node

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

2.2 Copy all files under the data directory of the installation package to C:\mysqlcluster\datanode\mysql\cluster-data

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

[Mysql_cluster] # Options for Data node process: # Location of Management serverndb-connectstring=192.168.24.33  


Note: Because the configuration of each data node is the same, we can copy the folder C:\mysqlcluster in the 192.168.24.33 host directly to the C drive of the 192.168.24.82 host without any changes.


3. Configuring the SQL Node

3.1 Under the C:\mysqlcluster of the 192.168.24.33 host, create a new subdirectory Sqlnode, create a new subdirectory under C:\mysqlcluster\sqlnode MySQL, extract the installation package files to the MySQL directory, and then C \ Mysqlcluster\sqlnode\mysql the new My.ini file, the file content is:

[Mysqld] # Options for MYSQLD process: # run NDB storage engine Ndbcluster                       # Location of Management Server Ndb-connect string=192.168.24.33

3.2 Delete or rename the My-default.ini file to My-default.ini.bak

Note: Because the configuration of each SQL node is the same, we can directly 192.168.24.33 folders in the host C:\mysqlcluster Copy to 192.168.24.82 Host on the C drive, without any changes .


Third, start MySQL Cluster

Before starting MySQL cluster, the first thing to do is to ensure that the MySQL service on each SQL node can start successfully and assign the appropriate permissions to each SQL node to allow remote login access. Then start three nodes in turn. 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 MySQL service

1.1 into the C:\mysqlcluster\sqlnode\mysql\bin directory, use Mysqld–install to install the MySQL service

1.2 using the net start MySQL command to start the MySQL service (if the MySQL service is already installed, you do not need to take 1th steps)


If the MySQL service is not installed, first install the MySQL service and then turn on the MySQL service.


Note: Run each SQL node sequentially to ensure that the MySQL service starts correctly.

2. Configure MySQL remote connection

2.1 Enter the C:\mysqlcluster\sqlnode\mysql\bin directory, use Mysql-uroot-p, and then enter the password to set the root user password. (Note: Just installed MySQL, the default password is empty!) )


2.2 switch to the MySQL database and enter the following command to assign permissions to the root user for the remote connection


GRANT all privileges on * * to ' root ' @ '% ' identifiedby ' root ' with Grant OPTION;



Next, start each node in turn:

3. Start the Management node

Open a command-line window in the 192.168.24.33 host, cut to the C:\mysql\bin directory, 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: This line command-line window cannot be closed unless you want to stop the service.


4. Start the Data node

4.1 Open a new command line window in the 192.168.24.33 host, cut to C:\mysqlcluster\datanode\mysql\bin, enter NDBD, press ENTER, the data node starts


4.2 initiates the Data node service in the same way as in other data nodes, that is, 192.168.24.82.

4.3 View data node and SQL node connection situation

Open a new command line window in the 192.168.24.33 host, cut to the directory C:\mysql\bin, enter: NDB_MGM; Press ENTER, then enter:

All STATUS, enter, you can view the data node connection information (if you use show to see the management node, data node, SQL node connection information)




5. Start the SQL node

5.1 Open a new command line window in the 192.168.24.16 host, cut to C:\mysqlcluster\sqlnode\mysql\bin, enter:

Mysqld--console; Enter, the SQL node starts.


5.2 starts the SQL node in the same way as in other SQL nodes, that is, 192.168.24.82.

Follow the previous step (4.3) To view the methods, and use the show command to view the connection of each SQL node. If this happens, the nodes are connected successfully!

Four, test MySQL Cluster

On any SQL node, a newly created database mytestmysql on the 192.168.24.33 host, you can see other SQL nodes, that is, 192.168.24.82 creates a mytestmysqlb database. Perform any operation on the data table on one machine, and the database on the other machine will be operated accordingly.




At this point, the Windows platform to build the MySQL cluster process is finished! There may be minor problems in the building process, but it can be solved basically through the network.


MySQL Cluster---②windows platform to build MySQL cluster 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.