How to configure a MySQL cluster on a server

Source: Internet
Author: User

To configure a Cluster, you must at least configure
1 MGM (Management node) + 1 SQL node + 2 Data Node
MGM can share a machine with the SQL node, and the data node occupies a server separately.
This requires at least three servers.
 
Sometimes it will be very troublesome. In the learning stage, you can consider building a MySQL Cluster on a single server.
 
The following describes how to build a Cluster on a server.
 
1. Check that the Cluster package has been correctly installed.
[Root @ cluster-one ~] # Rpm-aq | grep-I mysql
MySQL-Cluster-client-gpl-7.2.10-1.el6.x86_64
MySQL-Cluster-server-gpl-7.2.10-1.el6.x86_64
MySQL-Cluster-shared-compat-gpl-7.2.10-1.el6.x86_64
MySQL-Cluster-devel-gpl-7.2.10-1.el6.x86_64

2. Create the following configuration files.
[Root @ cluster-one mysqlData] # more config. ini
[Ndbd default]
NoOfReplicas = 2
[Tcp default]
# Portnumbers = 3388
[NDB_MGMD]
NodeId = 1
Hostname = localhost
Datadir =/mysqlData/clustermgmd-data/
[NDBD]
NodeId = 2
Hostname = localhost
Datadir =/mysqlData/clusterndb1-data/
[NDBD]
NodeId = 3
Hostname = localhost
Datadir =/mysqlData/clusterndb2-data/
[MYSQLD]
NodeId = 4
Hostname = localhost
[MYSQLD]
NodeId = 5
Hostname = localhost
[MYSQLD]

[Root @ cluster-one mysqlData] # more my1.cnf
[Mysqld]
Ndbcluster
Socket =/data/socket/n1.sock
Pid-file =/data/socket/n1.pid
Log-error =/data/log/n1_err.log
Port = 3501
[Mysql_cluster]
Ndb-connectstring = localhost
[Root @ cluster-one mysqlData] # more my2.cnf
[Mysqld]
Ndbcluster
Socket =/data/socket/n2.sock
Pid-file =/data/socket/n2.pid
Log-error =/data/log/n2_err.log
Port = 3502
[Mysql_cluster]
Ndb-connectstring = localhost

[Root @ cluster-one mysqlData] # more/etc/my. cnf
[Mysqld]
Ndbcluster
Socket =/var/lib/mysql. sock
Pid-file =/data/socket/mysqld. pid
Datadir =/mysqlData/clusterapi
Log-bin = mysql-bin
Log-bin-index = mysql-bin.index
Binlog-format = ROW
Server-id = 1
Port = 3401
[Mysql_cluster]
Ndb-connectstring = localhost
[Client]
Socket =/var/lib/mysql. sock

 
3. Start all nodes respectively (Note that if it is the first time you start, add -- initial to the startup parameter of the Management node/data node)
Before starting the node, make sure that all Directories specified in the preceding configuration file exist.
Does not exist. Create one first, or modify the configuration file to specify other directories. Directory:
/MysqlData/clustermgmd-data/
/MysqlData/clusterndb1-data/
/MysqlData/clusterndb2-data/
/MysqlData/clusterapi
/Data/socket/mysqld. pid
/Data/socket/
/Data/log/
 
 
Management Node
[Root @ cluster-one ~] # Ndb_mgmd-f/mysqlData/config. ini
MySQL Cluster Management Server mysql-5.5.29 ndb-7.2.10
Data Node 1
[Root @ cluster-one ~] # Ndbd -- defaults-file =/mysqlData/my1.cnf
1186 02:35:42 [ndbd] INFO -- Angel connected to 'localhost: 100'
02:35:42 [ndbd] INFO -- Angel allocated nodeid: 2
Data Node 2
[Root @ cluster-one ~] # Ndbd -- defaults-file =/mysqlData/my2.cnf
1186 02:35:46 [ndbd] INFO -- Angel connected to 'localhost: 100'
02:35:46 [ndbd] INFO -- Angel allocated nodeid: 3

Query the node. If the/etc/init. d/mysql file does not exist, you can
Copy/usr/share/mysql. server to the/etc/init. d directory and change it to mysql.
[Root @ cluster-one ~] #/Etc/init. d/mysql start
Starting MySQL

Build a high-availability MySQL Cluster Based on Corosync + DRBD

Corosync + Pacemaker + DRBD + MySQL high availability (HA) MySQL Cluster

Heartbeat + MySQL + NFS for high availability (HA) MySQL Cluster

Full automation of MySQL cluster architecture (M-M-S-S)

MySQL cluster configuration in SUSE Linux

  • 1
  • 2
  • Next Page

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.