MySQL Tutorial: Build a MySQL Cluster in Linux

Source: Internet
Author: User
Tags mysql tutorial

MySQL Tutorial: Build a MySQL Cluster in Linux

Install fuse for mysql-cluster-gpl-7.4.6-linux-glibc2.5-i686.tar.gz (http://pan.baidu.com/s/1c1bjxVa)

The system is a Linux virtual machine.

2 virtual machines (ensure that the firewall is disabled, otherwise the deployment may fail)

Ip: 192.168.52.130 for management, data nodes, and service nodes

Ip: 192.168.52.131 is used as the data node and service node.

I. Install cluster Software

Each node requires the following steps (in fact, management is not needed, but I am working together, so there is not much research ):

1. Download and decompress the package to/usr/local/mysql (you can select the directory as needed)

Tar-zxvf mysql-cluster-gpl-7.4.6-linux-glibc2.5-i686.tar.gz

Music mysql-cluster-gpl-7.4.6-linux-glibc2.5-i686/usr/local/mysql/

2. Create a mysql user

Useradd mysql

Chown-R mysql: mysql/usr/local/mysql/

3. Modify/etc/profile for ease of use

PATH = $ PATH:/usr/local/mysql/bin

Export PATH

4. Install mysq (Steps for installing mysql in source code)

Cd/usr/local/mysql/scripts

./Mysql_install_db -- basedir =/usr/local/mysql/-- datadir =/usr/local/mysql/data/-- user = mysql

5. Configuration Management node ndb

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

All the installation ends.

The startup sequence of nodes is management node-> data node-> SQL Node

Ii. Start the management Node

To create the config. ini configuration file on the Management node, follow these steps:

Mkdir/var/lib/mysql-cluster

Vim/var/lib/mysql-cluster/config. ini

Config. ini content

[Ndbd default]
NoOfReplicas = 2 # number of images on each data node. If it is set to 1, the cluster becomes unavailable when the data node is broken. Opposite to "1
DataMemory = 200 M # Memory allocated to data in each data node
IndexMemory = 30 M # Memory allocated to the index for each data node

[Ndb_mgmd]
Id = 1
Hostname = 192.168.52.130 # management node IP
Datadir =/var/lib/mysql-cluster/# manage the node directory

[Ndbd]
Id = 2
Hostname = 192.168.52.131 # data node IP Address
Datadir =/usr/local/mysql/data # data node directory

[Ndbd]
Id = 3
Hostname = 192.168.52.130 # IP address of the Data Node
Datadir =/usr/local/mysql/data # data node directory
 
[Mysqld]
Id = 4
Hostname = 192.168.52.130 # IP address of the SQL Node

[Mysqld]
Id = 5
Hostname = 192.168.52.131 # SQL node IP Address

(Note: NoOfReplicas indicates the number of data copies. If it is set to 1, there will be a single point of failure on the data node)

Start the management service on the Management Node

Ndb_mgmd-f/var/lib/mysql-cluster/config. ini

If you have modified config. ini, You can reload it.
Ndb_mgmd-f/var/lib/mysql-cluster/config. ini -- reload -- add a reload.

Ndb_mgm-e show view Cluster status
Ndb_mgm-e shutdown the cluster Software


 
The management node is started.

Test other machine connection management nodes

First, other nodes do not know the ip address of the Management node (because other nodes do not have config. ini)

3. Configure the/etc/my. cnf file for each node.

Therefore, you need to configure the configuration file in/etc/my. cnf. mysql loads/etc/my. cnf by default when starting the service.

The content of my. cnf is as follows:

[Mysqld]
Ndbcluster
Datadir =/usr/local/mysql/data
Basedir =/usr/local/mysql
Socket =/tmp/mysql. sock
Port = 3306
Ndb-connectstring = 192.168.52.130 --- manage node ip
[Mysql_cluster]
Ndb-connectstring = 192.168.52.130 --- manage node ip

Then ndb_mgm-e show on the non-management node can also view the cluster status.

2. Start the data node

/Usr/local/mysql/bin/ndbd -- initial

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.

Ndb_mgm-e show cluster status

3. Start a Service Node

/Usr/local/mysql/bin/mysqld_safe -- user = mysql &

Ndb_mgm-e show cluster status

Now the building is successful, and the test is to be continued.

MySQL Cluster backup and recovery

MySQL Cluster installation Configuration

Create a Cluster environment using three MySQL clusters. DOC

MySQL Cluster7.2 online addition of data nodes has major drawbacks

MySQL Cluster details: click here
MySQL Cluster: click here

This article permanently updates the link address:

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.