MySQL database management (ii) installation of MySQL cluster in a stand-alone environment

Source: Internet
Author: User

The MySQL cluster cluster is briefly described in the MySQL database management (i) MySQL cluster cluster brief introduction . This article will teach you step by step to build MySQL database cluster in a single-machine environment.


One, single-machine environment construction

First go to the MySQL official online http://www.mysql.com/downloads/Cluster/Download the required installation package. Then extract the downloaded Zip package to C:\YPL\MYSQL\MYSQLC


The MySQL database cluster consists of a MySQL service engine (mysqlds), two data nodes (NDBD), and a Management node (NDB_MGMD), all of which are executed on the same machine. Create the following directory in turn:
C:\ypl\mysql\my_Cluster
C:\ypl\mysql\my_Cluster\ndb_data
C:\ypl\mysql\my_Cluster\mysqld_data\ndbinfo
C:\ypl\mysql\my_Cluster\conf

After that, create the following two configuration files in the C:\ypl\mysql\my_Cluster\conf directory:
(1) my.cnf
The contents are as follows:
[mysqld]ndbclusterdatadir=c:\\ypl\\mysql\\my_cluster\\mysqld_databasedir=c:\\ypl\\mysql\\mysqlcport=3306
(2) Config.ini
The contents are as follows:
[NDB_MGMD]HOSTNAME=LOCALHOSTDATADIR=C:\YPL\MYSQL\MY_CLUSTER\NDB_DATAID=1[NDBD default]noofreplicas=2datadir=C:\ Ypl\mysql\my_cluster\ndb_data[ndbd]hostname=localhostid=3[ndbd]hostname=localhostid=4[mysqld]hostname= localhost

The MYSQLD process requires a system database called MySQL to store the necessary system data and user data.

Therefore, the following operations are required:

    • will be C:\ypl\mysql\mysqlc\data\mysql The entire folder is copied to the C:\ypl\mysql\my_Cluster\ndb_data folder.

    • Copy the entire C:\ypl\mysql\mysqlc\data\ndbinfo folder to the C:\ypl\mysql\my_Cluster\ndb_data folder.

After the above work is complete, you can start MySQL Cluster.


Second, start node: Management node--Data node-->sql node

(1) Start the Management node

Go to the command line tool cleansing and enter the command in turn:

CD  c:\ypl\mysql\my_clusterstart/b C:\ypl\mysql\mysqlc\bin\ndb_mgmd-f conf\config.ini--initial--configdir=c:\ Ypl\mysql\my_cluster\conf

The results are as follows:


(2) Start Data node

    • Start the First Data node and enter a command:

Start/b C:\ypl\mysql\mysqlc\bin\ndbd-c localhost:1186

    • Start a second data node. Enter the command:

Start/b C:\ypl\mysql\mysqlc\bin\ndbd-c localhost:1186


(3) Start the MySQL service engine

Enter the command:

Start/b C:\ypl\mysql\mysqlc\bin\mysqld--defaults-file=conf\my.cnf

To see if the data node starts to complete:

C:\YPL\MYSQL\MYSQLC\BIN\NDB_MGM-  e Show

The results are as follows:

After each node has started successfully. The process of being able to see all nodes in the process. Start Task Manager and you will see the results.

Connect to MySQLServer. Enter the command:

C:\ypl\mysql\mysqlc\bin\mysql-u root-p123456

If the connection is successful. such as the following interface will appear:

Third, test

Create the database Yplbeyond (note using NDB), create the table users within the database, and insert the data

Drop database if exists yplbeyond;create database yplbeyond;use yplbeyond;create table users (id int (3) auto_increment not NULL primary Key,uid char (a) not null,pwd char (a) not null,realname char (TEN) not Null,phone char (TEN) not Null,mail char ( () not null,date datetime null) engine=ndb;; Insert into users values (' ', ' Renmin University ', ' rucedu ', ' Lizi ', ' 00000000 ', ' [email protected] ', '); select * from users;



Note : It is not necessary to add "ENGINE=NDB;" At the end of the table, unlike the table built in MySQL. Because MySQL Cluster is used. The underlying storage engine is a memory-based NDB. Rather than InnoDB. Search within the directory YPL. You can find the table that you just created under the C:\YPL\MYSQL\MY_CLUSTER\NDB_DATA\YPL folder.

At the same time, it should be noted that when data nodes are distributed on different machines, the data stored by the InnoDB engine cannot be found on other data nodes and can be verified by corresponding experiments.

The MySQL Cluster service must be stopped manually. After the service is stopped. Other cluster nodes can use the Management node (NDB_MGM) to stop. Enter the command:

C:\YPL\MYSQL\MYSQLC\BIN\NDB_MGM-E shutdownc:\ypl\mysql\mysqlc\bin\mysqladmin-u root-p123456 shutdown

The results are as follows:



MySQL database management (ii) installation of MySQL cluster in a stand-alone environment

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.