MySQL-Cluster7.2.5 installation and configuration

Source: Internet
Author: User

ViewArticleIndex Via http://www.cnblogs.com/seesea125/archive/2012/04/17/2453256.html

The following describes the MySQL-Cluster7.2.5 installation and configuration, according to this step I have been configured successfully, if you have any questions, please contact me

Environment:

One 10.32.33.120 is used as a data node, SQL node, and management node.

One 10.32.34.116 is used as a data node and an SQL node.

The operating system is centos5.4 64-bit.

1. Download MySQL cluster7.2.5

Http://www.mysql.com/downloads/cluster/

NOTE: If MySQL already exists, delete it first. Method:

If you can connect to Yum remove MySQL

Otherwise, manually delete MySQL

First, let's see what packages are installed:

# Rpm-Qa | grep MySQL

And unmount these packages.

Rpm e MySQL-server-5.5.21-1.linux2.6

Rpm e MySQL-client-5.5.20-1.linux2.6

2. decompress the downloaded package

Set 10.32.33.120 to download MySQL cluster to/downfiles.

# Cd downfiles

# Tar-zxvf mysql-cluster-gpl-7.2.5-linux2.6-x86_64.tar.gz // unzip

3. Copy the extracted file to/usr/local and name it MySQL

# Cp/downfiles/mysql-cluster-gpl-7.2.5-linux2.6-x86_64/usr/local/MySQL

# Cd/usr/local/MySQL

# Chown-r root. // set the MySQL directory to "root" as the owner.

# Chown-r MySQL/Data // set the data directory owner to MySQL

# Change chgrp-r MySQL. // to the MySQL Group

# Cd scripts/

# Mysql_install_db-user = MySQL is installed

4. Set the MySQL service to start automatically

# Chmod + x/etc/rc. d/init. d/mysqld // grant the modifiable permission to this file

# Chkconfig -- add mysqld // The chkconfig command is mainly used to update (start or stop) and query the running level information of the System Service. chkconfig -- add name: adds a new service.

At this time, you cannot start the system on your own. You also need to set environment variables.

# Vi/etc/profile

Add two sentences at the end.

Path = $ path:/usr/local/MySQL/bin

Export path

The above operations are the same on the two servers.

V. Configuration

1. Configuration Management Node

Copy the/usr/local/MySQL/bin/ndb_mgm and ndb_mgmd files to/usr/local/bin.

# Cp/usr/local/MySQL/bin/ndb_mgm */usr/local/bin

# Mkdir/var/lib/MySQL-Cluster

# Vim/var/lib/MySQL-cluster/config. ini

Enter the following content:

[Ndbd default]

Noofreplicas = 1 # number of images on each data node

Datamemory = 200 m # Memory allocated to data in each data node

Indexmemory = 20 m # Memory allocated to the index for each data node

[Ndb_mgmd] # Configuration Management Node

Nodeid = 1

Hostname = 10.32.34.116

Datadir =/var/lib/MySQL-cluster/# manage node data (log) Directory

[Ndbd] # data node configuration

Nodeid = 2

Hostname = 10.32.33.120

Datadir =/usr/local/MySQL/data/# data node directory

[Ndbd]

Nodeid = 3

Hostname = 10.32.34.116

Datadir =/usr/local/MySQL/data/

[Mysqld]

Hostname = 10.32.33.120

[Mysqld]

Hostname = 10.32.34.116

[Mysqld] # Be sure to leave a blank value for extension. Otherwise, the error "failed to allocate nodeid no free node ID found for ndbd (NDB)" will occur.

[Mysqld]

Note: Do not add comments on the Right of [] During configuration; otherwise, the system does not recognize the comments.

[Ndbd default]: indicates that the default configuration of each data node does not need to be written in [ndbd] of each node. There can only be one.

[Ndb_mgmd]: indicates the configuration of the Management node, only one.

[Ndbd]: indicates the configuration of each data node, which can have multiple.

[Mysqld]: indicates the configuration of SQL nodes. You can enter multiple IP addresses of different SQL nodes.

2. configure data nodes and SQL nodes

When the MySQL service is started,/etc/My. CNF is loaded as its configuration file by default, and my. CNF on 10.32.33.120 is modified.

[Mysqld]

Ndbcluster # Run the NDB storage engine

Datadir =/usr/local/MySQL/Data

Basedir =/usr/local/MySQL

Port = 3306

[Mysql_cluster]

NDB-connectstring = 10.32.34.116 # declare a management Node

Copy one copy to another 10.32.34.116

# SCP/etc/My. CNF 10.32.34.116:/etc/

Six startup

The startup sequence of a node is management node> data node> SQL node.

1. Start the management node on 120

# Cd/usr/local/bin

#. /Ndb_mgmd-F/var/lib/MySQL-cluster/config. INI // ndb_mgmd is the Management Server of mysqlcluster.-F indicates that the following parameter is the startup parameter configuration file. If a data node is added several days after the startup, The -- Initial Parameter must be added when the configuration file is modified. Otherwise, the added node will not work in the MySQL cluster.

2. Start the data node

The -- Initial Parameter must be added when the data node is started for the first time after installation, unless it is restarted after backup, recovery, or configuration change.

# Cd/var/local/MySQL/bin/ndbd-initial

02:01:38 [ndbd] info -- angel connected to '10. 32.33.120: 1186'

2012-03-28 02:01:38 [ndbd] info -- angel allocated nodeid: 36

This message indicates that the startup is successful.

3. Start an SQL Node

# Mysqld_safe -- ndb_nodeid = 5 -- user = MySQL &

In the same way, start another machine and pay attention to the nodeid number.

4. Check the client

# Cd/usr/local/bin

#. Ndb_mgm

Ndb_mgm> show

Ndb_mgm> show

Cluster configuration

---------------------

Ndb_mgm> show

Cluster configuration

---------------------

[Ndbd (NDB)] 2 node (s)

Id = 2 @ 10.32.33.120 (mysql-5.5.20 ndb-7.2.5, node group: 0, Master)

Id = 3 @ 10.32.34.116 (mysql-5.5.20, nodegroup: 1)

[Ndb_mgmd (MGM)] 1 node (s)

Id = 1 @ 10.32.34.116 (mysql-5.5.20 ndb-7.2.5)

[Mysqld (API)] 4 node (s)

Id = 4 @ 10.32.33.120 (mysql-5.5.20 ndb-7.2.5)

Id = 5 @ 10.32.34.116 (mysql-5.5.20 ndb-7.2.5)

Id = 6 (not connected, accepting connect from any host)

Id = 7 (not connected, accepting connect from any host)

You can see that each node is connected, and the MySQL cluster configuration is complete.

If you cannot see the above information, it may be a firewall problem. You can choose to turn off the centos firewall and run the command:/etc/init. d/iptables stop

Close the management node. Enter shutdown at the ndb_mgm> prompt, and then enter exit to exit.

7. Test.

1. Log On from SQL node A, create a database and a table, and perform a simple test.

Mysql> Create Database zxztest;

Mysql> Use zxztest;
Database changed

Mysql> Create Table test1 (ID int, name varchar (10) engine = NDB;

Mysql> insert into test1 values (1, 'zhaoxuezhi ');

Mysql> select * From test1;

+ ------ + --------- +
| ID | Name |
+ ------ + --------- +
| 1 | zhaoxuezhi |
+ ------ + --------- +

Log on to Node B and check the effect. The database, table, and data have been synchronized.

Insert a data entry from Node B and log on to node A to see that the data has been synchronized.

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.