Dual-machine redundant backup and load Balancing policy (Mysql cluster Getting Started installation configuration guide)

Source: Internet
Author: User
Tags centos server

MySQL Cluster is a high-utility, high-redundancy version of MySQL suitable for distributed computing environments. It employs the NDB Cluster storage engine, allowing multiple MySQL servers to run in 1 Cluster. MySQL Cluster is a technology that allows the Cluster of an "in-memory" database to be deployed in a system that is not shared. With no shared architecture, the system can use inexpensive hardware and has no special requirements for hardware and software. In addition, because each component has its own memory and disk, there is no single point of failure.

First we download MySQL Cluster, download the link address for MySQL Cluster 7.1.17, we use the server for CentOS server and Ubuntu server, so we download the version for Linux generic.

Now I have three servers, two are CentOS server, one is Ubuntu server, the first two server as data node and SQL node (data node and SQL node on the same machine),

The latter as management Node, if there is no real machine, can be simulated with the virtual machine, the following is my IP deployment:

1 192.168.56.10     Data node + Sql node
2 192.168.56.20 Data node +sql node
3 192.168.56.30 Management Node

Here is the approximate topology diagram structure of my machine:

Next we need to do a detailed configuration of these nodes:

1. Configure Data node and SQL node

Currently we are using three machine strategy, so put these two nodes on the same machine, so we in a configuration on it.

First of all, we 192.168.56.10 this machine on the operation configuration, 192.168.56.20 operation configuration and such

We need to perform subordinate operations under the root account, and if you encounter a problem with command not found in CentOS, refer to my Blogcentos system Bash:groupadd:command not found problem

Next we will create a new user group and user with the following command:

1 Groupadd MySQL
2 useradd–g MySQL MySQL

Place the MySQL cluster under/usr/local/and execute the command:

1 tar-c/usr/local-xzvf mysql-cluster-gpl-7.1.17-linux-i686-glibc23.tar.gz
2 Ln-s/usr/local/mysql-cluster-gpl-7.1.17-linux-i686-glibc23/usr/local/mysql

Go to the MySQL directory and execute the database initialization command:

1 scripts/mysql_install_db--user=mysql

To make a permission change operation, the command is:

1 chown-r Root.
2 chown-r MySQL Data
3 chgrp-r MySQL.

2. Configure Management Node

Put the NDB_MGMD and NDB_MGM script files under the/usr/local/bin directory with the following command:

1 TAR-ZXVF mysql-5.1.56-ndb-7.1.17-linux-i686-glibc23.tar.gz
2 CD Mysql-5.1.56-ndb-7.1.17-linux-i686-glibc23
3 CP bin/ndb_mgm*/usr/local/bin

To change its corresponding permissions, the command is:

1 Cd/usr/local/bin
2 chmod +x ndb_mgm*

To create a new directory/var/lib/mysql-cluster/, the command is:

Mkdir-p/var/lib/mysql-cluster/

3. Configure the configuration files of three machines

The configuration file my.cnf is created under the/etc directory for both data nodes, with the following contents:

[Mysqld]
Ndbcluster
Datadir=/usr/local/mysql/data
Basedir=/usr/local/mysql
port=3306
[Mysql_cluster]
ndb-connectstring=192.168.56.10

If the MySQL database "Communications link failure due to underlying exception" issue appears during the run, please refer to this blog post for configuration.

For the 192.168.56.20 machine just replace the ndb-connectstring.

Create a Config.ini file under the Management node machine/etc directory with the contents:

1 [ndbd Default]
2 noofreplicas=2
3 datamemory=80m
4 indexmemory=18m

6 [NDB_MGMD]
7 nodeid=1
8 hostname=192.168.56.30
9 Datadir=/var/lib/mysql-cluster

[NDBD]
nodeid=2
hostname=192.168.56.10
Datadir=/usr/local/mysql/data

[NDBD]
Nodeid=3
hostname=192.168.56.20
Datadir=/usr/local/mysql/data

[Mysqld]
[Mysqld]

4. Start the cluster environment

First we need to start the Management node 192.168.56.30 machine, execute the command:

1 ndb_mgmd-f/etc/config.ini--initial

If the default Config directory '/usr/local/mysql/mysql-cluster ' does not exist this error message, create this folder manually.

Next we need to start the data node in 192.168.56.10 and 192.168.56.20, the command is:

1 bin/ndbd--initial

The first time to enable the need to add-initial parameters, the second start cannot add this parameter. Both machines execute the command separately.

Next, start the SQL node for both machines, and the command is:

1 Bin/mysqld_safe--user=mysql &

Both machines need to execute this command.
Finally go to the admin console to see if our cluster is configured to complete, enter the command:

1 Ndb_mgm–e Show

If the following information appears, the configuration is successful:

If you do not see the above information, it may be a firewall problem, you can choose to switch the CentOS firewall, the command is:

1/etc/init.d/iptables stop

Of course you can choose to configure the firewall, open up some necessary ports, you can refer to my other article CentOS Open 3306 port

Close the cluster and execute the command:

1 ndb_mgm–e shutdown

Dual-machine redundant backup and load Balancing policy (Mysql cluster Getting Started installation configuration guide)

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.