MySQL cluster setup (all nodes on the same machine)

Source: Internet
Author: User
Tags mysql cluster setup

Transferred from:

Added a number of errors encountered and their solutions;

------------------------------------------------Gorgeous split-line--------------------------------------------------------

MySQL is used to develop small and medium-sized projects is very useful, from the cost-saving aspects of the consideration is a good choice, but the development of a larger project is still a bit difficult, the previous few years to solve the problem is usually through the read and write separation to optimize the database, so there is amoeba this thing, Now this thing has been discarded, but it is MYSQL-CLUSTER-GPL used more. But the configuration of MySQL cluster is still relatively cumbersome, a lot of people can not get out on, terrible is the online a lot of information is reproduced others, have not been verified by their actual, it is too pit dad. This time I'm going to share the knowledge about MySQL cluster.

1 Development Readiness

Download mysql-cluster-gpl-7. X version of the MSI or EXE file, double-click the installation location arbitrarily, after the installation of the directory is roughly the following (PS: can be directly downloaded version of the installation)

2 Creating a cluster-related file directory

(1) Create a folder name on the disk arbitrarily, under this folder built Mgm_data, Ndb_data, Mysqld_data, after the installation from the MYSQL-CLUSTER-GPL of the bin directory under the directory to copy Ndb_mgm.exe and NDB _mgmd.exe to this directory

(2) then build NDB1 and ndb2 two folders under Ndb_data and copy Ndbd.exe from the Bin folder under the Mysql-cluster installation directory to NDB1 and NDB2 folders

(3) then build Mysqld1 and mysqld2 two folders under Mysqld_data

(4) Copy the data, share directory from the mysql-cluster below and copy the Mysqld.exe, Mysqladmin.exe to Mysqld1 and Mysqld2 folders from the bin directory

(5) Next Create two My.ini file contents as follows

The first one:

DataDir configuration is the data directory of the database, Basedir configuration is the Mysql-cluster installation directory

The second one:

The first My.ini is placed under the Mysqld1 folder, the second one under the Mysqld2 folder

3 Create a file named Config.ini below the base directory with the following contents

[MYSQLD] ID=21[MYSQLD]ID=22[NDB_MGMD]HOSTNAME=LOCALHOSTDATADIR=D:/MYDATABASE/MY_CLUSTER/MGM_DATAID=1[NDBD DEFAULT] noofreplicas=2 datamemory=80m indexmemory=18m [ndbd]hostname=localhostid=11[ndbd]hostname=localhostid=12
DataDir configuration is the directory of the Management node, the management node to the data node and database service node Unified management

4 Starting the Management node

The command is: ndb_mgmd.exe-f config.ini--initial

You need to add the--initial parameter when you start the first time, but you don't need it when you start it.

PS: Start the Management node may error, do not control it, because the other nodes have not yet started;

4 Starting the Data node

Enter each data node, that is, the NDB1 and NDB2 directories, respectively: Ndbd-c localhost:1186

Start a second data node in the same way

PS: If you are prompted that a folder does not exist, create a new folder in that directory, and then restart it;

5 starting the MySQL service node

The same access to the MySQL Service node directory is the Mysqld1 and mysqld2 directories, executed: Mysqld.exe--defaults-file=my.ini

Or start a second MySQL service node in the same way

Just in case it's best to enter the admin node input: Ndb_mgm.exe after entering show enter to see if the node is in a normal state

This situation indicates that the nodes are normal

6 The next work is simple, just open the graphical interface tool, connect 5000 and 5001 of the database, then on the 5000 of this MySQL randomly build a database and create a table, it should be noted that the table engine should use NDB. After adding a few data, we can see that the database created on 5000 is also visible on MySQL 5001, and the information in the table is consistent

In order to successfully execute the various commands, it is recommended to execute the command with administrator, otherwise it is very likely that the command execution is unsuccessful.

? According to the above method to build the cluster, but no synchronization success, tomorrow to see what the reason, and then do the supplement!

MySQL cluster setup (all nodes on the same machine)

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: 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.