MySQL Sync cluster

Source: Internet
Author: User

mysql-cluster7.2.5 Installation and Configuration

To view the article index, please pass http://www.cnblogs.com/seesea125/archive/2012/04/17/2453256.html
The following describes the mysql-cluster7.2.5 installation and configuration, follow this step I have been configured successfully, if in doubt, please contact me
Environment:
A 10.32.33.120 to do a data node, SQL node, management node
A 10.32.34.116 makes a data node, a SQL node.
The operating system is CentOS5.4 64 bits.
Download MySQL Cluster7.2.5
http://www.mysql.com/downloads/cluster/
Note: If MySQL already exists, you need to delete it first, method:
If you can connect yum remove MySQL
Otherwise manually remove MySQL
First look at what packages are installed:
# Rpm-qa|grep MySQL
And unload all these bags.
Rpm-e mysql-server-5.5.21-1.linux2.6
Rpm-e mysql-client-5.5.20-1.linux2.6
Two downloads after decompression
First set up 10.32.33.120, download MySQL cluster to/downfiles
#cd Downfiles
#tar –ZXVF mysql-cluster-gpl-7.2.5-linux2.6-x86_64.tar.gz//Decompression
Three extracted files copied to/usr/local under the name of MySQL
#useradd-S/bin/nologin mysql//add MySQL User
#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 as the owner root
#chown –R mysql:mysql Data//Set the data directory owner to MySQL
#chgrp –R MySQL. Change to the owning group as MySQL
#cp support-file/my-medium.cnf/etc/my.cnf//Copy Master Profile
#scripts/mysql_install_db--user=mysql//Installation Database
Quad set up MySQL service for start-up
#chmod +x/etc/rc.d/init.d/mysqld//Give this file a modifiable permission
#chkconfig--add mysqld//chkconfig command is primarily used to update (start or stop) and query run-level information for system services, Chkconfig--add name: Add a new service
You cannot start the boot yet, and you need to set the environment variable
#vi/etc/profile
I'll add two sentences at the back.
Path= $PATH:/usr/local/mysql/bin
Export PATH
The above actions do the same on both servers.
Five: Configuration
1. Configuration Management node
Copy/USR/LOCAL/MYSQL/BIN/NDB_MGM,NDB_MGMD two 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 #每个数据节点的镜像数量
datamemory=200m #每个数据节点中给数据分配的内存
indexmemory=20m #每个数据节点中给索引分配的内存
[NDB_MGMD] #配置管理节点
Nodeid=1
hostname=10.32.34.116
datadir=/var/lib/mysql-cluster/#管理节点数据 (log) directory
[NDBD] #数据节点配置
nodeid=2
hostname=10.32.33.120
datadir=/usr/local/mysql/data/#数据节点目录
[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] #一定要留一个空的, in case of extended use, otherwise there will be failed to allocate Nodeid No free Node ID found for NDBD (NDB) error
[Mysqld]
Note: When configured, the comments on the right of [] do not add, otherwise the system does not recognize.
[NDBD Default]: Indicates that each data node is configured to have no more options in the [NDBD] of each node, only one.
[NDB_MGMD]: Represents the configuration of the management node, only one.
[NDBD]: Represents the configuration of each data node, can have more than one.
[MYSQLD]: Represents the configuration of the SQL node, can have more than one, write the IP address of the different SQL nodes respectively.
2. Configuring data nodes and SQL nodes
When the MySQL service starts, it will load/etc/my.cnf as its profile by default, modifying the MY.CNF on 10.32.33.120
[Mysqld]
Ndbcluster #运行NDB存储引擎
Datadir=/usr/local/mysql/data
Basedir=/usr/local/mysql
port=3306
[Mysql_cluster]
ndb-connectstring=10.32.34.116 #声明管理节点
Copies one copy to another 10.32.34.116
#scp/etc/my.cnf 10.32.34.116:/etc/
Six-start
The start order of the nodes is the->sql node of the data node, the management node.
1, 120 Start the management node
#cd/usr/local/bin
#./ndb_mgmd-f/var/lib/mysql-cluster/config.ini//NDB_MGMD is the Management Server for Mysqlcluster, followed by-F to indicate that the parameters that follow are the parameter configuration files that are started. If after the start of a few days after the addition of a data node, when the configuration file modification must be added to the--initial parameter, otherwise the added node will not work in MySQL cluster
2. Start the Data node
When you start the data node for the first time after installation, add the--initial parameter, otherwise do not add, unless it is restarted after backup, recovery, or configuration changes
#cd/var/local/mysql/bin/ndbd–initial
2012-03-28 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 information appears to indicate a successful start.
3. Start the SQL node
#mysqld_safe--ndb_nodeid=5--user=mysql &
The same way, start another machine, pay attention to the Nodeid number.
4. Client View
#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, nodegroup:0, Master)
Id=3 @10.32.34.116 (mysql-5.5.20 ndb-7.2.5, 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 the individual nodes are connected, and the MySQL cluster configuration is complete.
If you do not see the above information, it may be a firewall problem, you can choose to turn the CentOS firewall off, the command is:/etc/init.d/iptables stop
The management node is off, enter shutdown at the ndb_mgm> prompt, and exit by entering exit.
7 Test.
1. Log in from SQL Node A, create databases and tables, and perform simple tests.
mysql> CREATE DATABASE Zxztest;
mysql> use zxztest;
Database changed
Mysql> CREATE TABLE test1 (ID int,name varchar (ten)) engine=ndb;
mysql> INSERT INTO test1 values (1, ' Zhaoxuezhi ');
Mysql> select * from Test1;
+------+---------+
| ID | name |
+------+---------+
| 1 | Zhaoxuezhi |
+------+---------+
Log in to the B node to see the effects, libraries, tables, and data already synchronized.
Insert a piece of data from the B-node, and also log in a, and you can see that the data is synchronized.

This article from "Banging Blog" blog, reproduced please contact the author!

MySQL Sync 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.