Windows environment configuration MySQL Cluster

Source: Internet
Author: User

Windows environment configuration MySQL Cluster

First, Cluster environment Construction

1. mysql Cluster (mysql Cluster 7.5.4) file: http://dev.mysql.com/downloads/cluster/

2, prepare three servers (virtual machine, I use Windows Server R2 Enterprise), one for the configuration management node, the other two each configuration of a data node and a SQL node :

Management node:192.168.108.128
Data Node a:192.168.108.129
Data Node b:192.168.108.130
SQL Node a:192.168.108.129
SQL Node b:192.168.108.130

3, unzip the download package to each computer's C:/mysql directory (other disks can also)

in the Management node C:\Mysql\Bin directory set up cluster-logs and config two folders cluster-logs used to store log files, set up in the Config folder My.ini and config.ini Two configuration files:

My.ini

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

Config.ini

[NDBD Default]
# Options affecting NDBD processes on all data nodes:
noofreplicas=2 # of Replicas
Datadir=c:/mysql/bin/cluster-data # directory for each data node ' s data files # Forward slashes used in Directory path, # Rather than backslashes. This is correct; # See Important Note in text
datamemory=80m # Memory allocated to data storage
indexmemory=18m # Memory allocated to index storage # for Datamemory and indexmemory, we have used the # default values. Since the ' World ' database takes up # is at 500KB, this should is more than enough for # This example Cluster setup.
[NDB_MGMD]
# Management Process Options:
hostname=192.168.108.128 # HostName or IP address of management node
Datadir=c:/mysql/bin/cluster-logs # Directory for Management node log files
[NDBD]
# Options for Data node "A":
hostname=192.168.108.130 # HostName or IP address
[NDBD]
# Options for Data node "B":
hostname=192.168.108.129 # HostName or IP address
[Mysqld]
# SQL node A options:
hostname=192.168.108.130 # HostName or IP address
[Mysqld]
# SQL node B options:
hostname=192.168.108.129 # HostName or IP address

4, the Cluster-data folder is established under the C:\Mysql\Bin directoryon the computer of the Configuration Data node (192.168.108.129,192.168.108.130). Used to store data

5, to this point, the environment installation completed

Second, Cluster cluster start-up

1. Turn off the firewall

2. Open Management Tools

cmd command: C:\mysql\bin\ndb_mgmd.exe--configdir=c:\mysql\bin\config--config-file=c:\mysql\bin\config\config.ini-- Ndb-nodeid=1--reload –initial

3, open the Data node (note: Must be run by the Administrator dos, or error)

cmd command: C:\mysql\bin\ndbd.exe--ndb-connectstring=192.168.108.128

4. Execute command initialization mysql command add data directory ( pit )

cmd command: C:\mysql\bin\mysqld--initialize-insecure--user=mysql

5. Open SQL node

cmd command: C:\mysql\bin\mysqld.exe--ndbcluster--ndb-connectstring=192.168.108.128--console

6. Check the open status on the Management Server

CMD command: C:\mysql\bin\ndb_mgm.exe

7, note that all commands are best to open the DOS environment with administrator privileges to execute, start MySQL cluster cluster when there are two big pits, the first big pit is certain to shut down the firewall , the second big Pit is the MySQL needs to initialize .

at this point, the environment is completed, you can go to the next test, use.

Third, test MySQL cluster

1、在sql节点A的计算机上(192.168.108.129)的cmd中运行C:\mysql\bin\mysql.exe -u root -p命令登录mysql,接下来需要输入密码时,密码默认为空(直接回车)。

创建数据库并插入数据:
—–创建名为”MySQL_Cluster_Test”的数据库:

Create Database mysql_cluster_test;


—–创建表”T_User”:

Use Mysql_cluster_test;
CREATE TABLE T_user (Name varchar (+), age int) Engine=ndbcluster;

注意建表语句后面一定要加上 engine=ndbcluster

—–插入数据:

INSERT into T_user values (' Dannyhoo ', 26);

—–查询数据:

SELECT * from T_user;

2、在sql节点B也可以查询到数据。

同样在sql节点B的计算机上(192.168.108.130)的cmd中运行C:\mysql\bin\mysql.exe -u root -p命令登录mysql。

执行 show databases; 命令可以查看到在sql节点A新建的数据库;
执行use MySQL_Cluster_Test;
    select * from T_User;
可以查询到在sql节点A插入的数据。

    到这里,整个集群的搭建和测试就完成了。假如一个数据节点宕机,并不会影响整个集群的运行,任何一个数据节点死掉甚至物理损坏都不用担心,因为每个数据节点保存的数据都是完整的一份数据(在你操作数据的时候,它早就自动为你把最新的数据备份到每一个数据节点上啦)。你可以测试一下,这时手动停止某个数据节点和sql节点,另外一个数据节点和sql节点还会正常运行。当你把停止的数据节点和sql节点重新启动时,会发现又重新连接到集群里了,而且每个数据节点的数据都是最新的。

Windows environment configuration 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.