Build MySQL cluster in Windows environment

Source: Internet
Author: User

1. Former (FEI) statement (Hua)

Recently, the teacher gave us a set up a MySQL cluster task, and threw two blog links to our reference, and then did not then. According to the teacher to the blog above the steps to try, found and can not be successfully established, so their own Baidu, found a very reliable blog, so reference a bit, feel overall is good ~

Reliable blog:
http://blog.csdn.net/mazhaojuan/article/details/42211857

2. Basic knowledge of theory

The first thing you need to know is the management node, the data node, and the SQL node ~

(1) Management node: From the name can be seen, the role of this node is to manage the other nodes, the nodes can see the other data nodes and SQL node connection status, and can control these nodes restart.

(2) Data node: The role of these nodes is to store data, each data node has the MySQL cluster of all the data (data redundancy), that is, as long as there is a can run on it ~

(3) SQL node: These nodes provide SQL interface to the outside, all the database operations are sent here, as long as there is a can run can ~

(PS: This article focuses on the actual operation, the theoretical basis of knowledge, please self-Baidu learning ~)

3. Actual operation process (Bo Master's operating system is win10~)

The following 5 computers are used to implement the MySQL cluster (1 management nodes, 2 data nodes, 2 SQL nodes)

ip:192.168.1.66 of the Management node

ip:192.168.1.50 of Data Node 1

ip:192.168.1.53 of Data Node 2

ip:192.168.1.63 for SQL Node 1

ip:192.168.1.56 for SQL Node 2

(1) to the MySQL website to download a decompression version of the MySQL cluster, below ~

Choose according to your operating system

Unzip after download is complete

(2) Configuration Management node

Create a new MySQL folder on the C drive of the management node, and then create a new Bin folder and Mysql-cluster folder under the MySQL folder. Locate Ndb_mgm.exe and Ndb_mgmd.exe under the Bin folder in the folder you just unzipped, and then copy the new Cluster-logs folder, Config.ini file, and My.ini file to the newly created Bin folder under this folder.

Edit Config.ini File:

[NDBDdefault]# Options affecting NDBD processes on all data nodes:# Number of replicas data nodesnoofreplicas=2Datadir=c:/mysqlcluster/datanode/mysql/bin/cluster-data# Directory for each data node ' s data Files# Memory allocated to data storage the path to your data nodedatamemory= theM# Memory allocated to index storageindexmemory= -M# for Datamemory and indexmemory, we have used the# default values.[NDB_MGMD]# Management Process options:# Hostname or IP address of Management node management nodes IPHostname=192.168. 1. the             # Directory for Management node log files managing nodes logs storage pathDatadir=c:/mysql/bin/cluster-logs [NDBD]# Options for Data node "1":# (one [NDBD] section per data node)# Hostname or IP address data node 1 IPHostname=192.168. 1. the[NDBD]# Options for Data Node "2":# Hostname or IP address data node 2 IPHostname=192.168. 1.[Mysqld]# SQL node options:# Hostname or IP Address SQL node 1 IPHostname=192.168. 1.[Mysqld]# SQL node options:# Hostname or IP Address SQL Node 2 IPHostname=192.168. 1. the 

Edit My.ini File:

[mysql_cluster]# Options for management node process config.ini存放路径config-file=C:/mysql/bin/config.ini

(2) Configure Data node:

Create a new C:\mysqlcluster\datanode\mysql folder in Data node 1, create a new bin folder and a Cluster-data folder in this MySQL folder, Create a new folder in this new Bin folder, also called Cluster-data. Next, copy all files from the data directory in the extracted folder to C:\mysqlcluster\datanode\mysql\cluster-data, and then copy a ndbd.exe to the bin directory in the unpacked folder to C # Mysqlcluster\datanode\mysql\bin, and finally create a new My.ini file.

Edit My.ini:

# Options for data node process: # location of management server 管理节点IPndb-connectstring=192.168.1.66

Since the configuration of the Data node 2 is the same as this one, you can choose to make a deeper impression, or you can create a new C:\mysqlcluster\datanode in the Data node 2 and then slack off the data node 1 C:\mysqlcluster\ The MySQL folder under Datanode is copied to the C:\mysqlcluster\datanode directory of data node 2.

(3) Configuring the SQL node

In SQL Node 1, create a new C:\mysqlcluster\sqlnode\mysql folder, extract the installation package files to the MySQL directory, and then create a new My.ini file under C:\mysqlcluster\sqlnode\mysql

Edit My.ini:

# Options for mysqld process: # run NDB storage engine ndbcluster                       # location of management server 管理节点IPndb-connectstring=192.168.1.66

Remember to delete or rename the My-default.ini file to another name

SQL Node 2 configuration and SQL node 11 Mao, look at it.

(4) Open MySQL Cluster

A, open the SQL node service first: (DOS command line)

If the MySQL service is not installed, go to the SQL node to enter the C:\mysqlcluster\sqlnode\mysql\bin directory, install the MySQL service using Mysqld–install, and use the net start MySQL command to start the MySQL service

If the MySQL service is already installed, start the MySQL service directly using the net start MySQL command

SQL Node 2 also does the same operation

B. Assign permissions to the root user for remote connections

To the management node into the C:\mysqlcluster\sqlnode\mysql\bin directory, use Mysql-uroot-p, and then enter the password (default is empty)

And then enter

GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ IDENTIFIED BY ‘root‘ WITH GRANT OPTION;

C. Start the Management node

To the Management node, open a command-line window, cut to the C:\mysql\bin directory, enter

ndb_mgmd -f config.ini --configdir=C:\mysql\mysql-cluster

This window cannot be turned off, otherwise the service is not available.

Open it

D. Start the Data node

To data node 1 open a command-line window, cut to C:\mysqlcluster\datanode\mysql\bin, enter NDBD

Data Node 1:

Data Node 2 operates the same:

E. Start the SQL node

Open a command-line window to SQL Node 1, cut to C:\mysqlcluster\sqlnode\mysql\bin, and enter:
Mysqld–console

SQL Node 1

SQL Node 1 startup complete:

SQL Node 2 operates the same

4. Testing

Create a database to any SQL node, creating a new table in the new database

create database db;use db;create table t (id int) engine=ndbcluster;

To another SQL node query see if you can see the new database DB and table T, if there is no problem ~

show databases;use db;show tables;

Build MySQL cluster in Windows environment

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.