Ubuntu12.04LTS to build a highly available distributed MySQL Cluster

Source: Internet
Author: User
MySQLCluster is a highly practical and redundant MySQL version suitable for distributed computing environments. It uses the NDBCluster storage engine and allows multiple MySQL servers to run in one Cluster. Without a shared architecture, the system can use cheap hardware without special requirements for hardware and software. In addition, since each component has its own memory and disk, there is no single point of failure. In this article, the developer's official website www.Oracle.com will describe how

MySQL Cluster is a highly practical and redundant MySQL version suitable for distributed computing environments. It uses the NDB Cluster Storage engine and allows multiple MySQL servers to run in one Cluster. Without a shared architecture, the system can use cheap hardware without special requirements for hardware and software. In addition, since each component has its own memory and disk, there is no single point of failure.

Official developer website www.Oracle.com
In this article, I will describe how to build a highly available MySQL cluster in Ubuntu 12.04 LTS.

1. SQL Cluster VM
To create a fully functional cluster, at least three hosts are required. One host acts as the management node and the other two act as the data node. If the data node is offline, the cluster can still work, but if there is a problem with the management node, the cluster will not work normally, so if possible, create two management nodes. In my example, I will use a cluster with two Management Nodes
In this example, five hosts are used, as shown in figure

Virtual Machine Group platform VMware ESXi 4.1
Virtual Machine operating system Ubuntu 12.04.3 LTS (Precise Pangolin) 64-bit
All virtual machines are in the same IP address range of 192.168.67.0/24. Configure the IP address according to your network conditions. Before starting, make sure that the network connection settings of all hosts are normal.

2. Install the management Node
First, we need to install the management node of the MySQL cluster. We will start with the MySQL-MGM-1, configure the Second Administrative node following the same steps after the configuration is complete, if only one administrative node is set, then continue with the configuration next
Before starting the configuration, visit the http://www.mysql.com/downloads/cluster/#downloads to confirm version information for the current installation document. Here the MySQL Cluster version I am using is 7.3.3
First, download the MySQL Cluster installation package to the management host. Go to the/usr/src folder and create the mysql-mgm directory.

Mkdir/usr/src/mysql-mgm
Cd/usr/src/mysql-mgm

After completing this step, download the latest installation source code from the official MySQL website and decompress the software package.
Wget http://cdn.mysql.com/Downloads/MySQL-Cluster-7.3/mysql-cluster-gpl-7.3.3-linux-glibc2.5-x86_64.tar.gz
Tar xvfz mysql-cluster-gpl-7.3.3-linux-glibc2.5-x86_64.tar.gz

Enter the decompressed folder and move the binary file.
Cd mysql-cluster-gpl-7.3.3-linux-glibc2.5-x86_64
Cp bin/ndb_mgm/usr/bin
Cp bin/ndb_mgmd/usr/bin

Change the directory permission and delete the downloaded source file.
Chmod 755/usr/bin/ndb_mg *
Cd/usr/src
Rm-rf/usr/src/mysql-mgm

Next, create a management node configuration file named config. ini in the/var/lib/mysql-cluster/folder.
Mkdir/var/lib/mysql-cluster

After the config. ini file is created, use your favorite text editor to edit the file. The content is similar
[Ndbd default]
NoOfReplicas = 2
DataMemory = 80 M
IndexMemory = 18 M
[Mysqld default]
[NDB_MGMD DEFAULT]
DataDir =/var/lib/mysql-cluster
[Tcp default]
# Section for the cluster management node
[NDB_MGMD]
NodeId = 1
# IP address of the first management node (this system)
HostName = 192.168.67.10
[NDB_MGMD]
NodeId = 2
# IP address of the second management node
HostName = 192.168.67.11
# Section for the storage nodes
[NDBD]
# IP address of the first storage node
HostName = 192.168.67.12
DataDir =/var/lib/mysql-cluster
[NDBD]
# IP address of the second storage node
HostName = 192.168.67.13
DataDir =/var/lib/mysql-cluster
# One [MYSQLD] per storage node
[MYSQLD]
[MYSQLD]

All Hosts are defined here, even if we only install the first one. Note that NodeId must be set for managing host nodes, but not for NDBD nodes.
After completing this step, you can use the following command to start the management Node
Ndb_mgmd-f/var/lib/mysql-cluster/config. ini -- configdir =/var/lib/mysql-cluster/

After completing this step, you can use the following command to add an entry to init. d to automatically start the program.
Echo "ndb_mgmd-f/var/lib/mysql-cluster/config. ini -- configdir =/var/lib/mysql-cluster/">/etc/init. d/ndb_mgmd
Chmod 755/etc/init. d/ndb_mgmd

If everything goes well, the second management node follows the same steps and uses the same configuration. Do not change the ID in the node configuration file
You can use the ndb_mgm command to verify the running of the Management node (you only need to enter ndb_mgm in the terminal), and start the Configuration Utility by typing show. At this time, the NDBD node and MySQL node are in the disconnected state. You need to complete the configuration of all nodes to output the correct state.

For more details, refer to the highlights on the next page.: Http://www.linuxidc.com/Linux/2013-11/93019p2.htm

Recommended reading:

Build high-availability MySQL cluster http://www.linuxidc.com/Linux/2013-10/91386.htm Based on Corosync + DRBD

Corosync + Pacemaker + DRBD + MySQL high availability (HA) MySQL cluster http://www.linuxidc.com/Linux/2013-08/89036p3.htm

Heartbeat + MySQL + NFS for high availability (HA) MySQL cluster http://www.linuxidc.com/Linux/2013-08/88663.htm

Hadoop cluster (Phase 1) _ MySQL relational database http://www.linuxidc.com/Linux/2012-12/76706.htm

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.