Build a MySQL cluster in Linux

Source: Internet
Author: User

Build a MySQL cluster in Linux

I. Objectives

1. Install MySQL-Cluster software packages.

2. configure management/data/SQL nodes in sequence.

3. Start and test the MySQL-Cluster architecture.

Ii. Solution

Use six RHEL 6.5 virtual machines ,. Among them, sql1 and sql2 are used as SQL nodes, ndb1 and ndb2 are used as data nodes, and mgmsvr are used as management nodes. The five nodes that constitute the MySQL Cluster system should install MySQL related software packages of the Cluster version; for Linux clients used for testing, you only need to install the common MySQL-client.

-------------------------------------- Split line --------------------------------------

Install MySQL in Ubuntu 14.04

MySQL authoritative guide (original book version 2nd) Clear Chinese scan PDF

Ubuntu 14.04 LTS install LNMP Nginx \ PHP5 (PHP-FPM) \ MySQL

Build a MySQL Master/Slave server in Ubuntu 14.04

Build a highly available distributed MySQL cluster using Ubuntu 12.04 LTS

Install MySQL5.6 and Python-MySQLdb in the source code of Ubuntu 12.04

MySQL-5.5.38 universal binary Installation

-------------------------------------- Split line --------------------------------------

Iii. Implementation

1. Preparations

1) Check the IP addresses of servers on each node so that nodes can communicate with each other. Firewall and selinux are disabled.

Disable Firewall:

# Iptables-F // clear firewall entries

# Service iptables stop // disable Firewall

# Chkconfig iptables off // boot failure

Disable selinux:

Run/etc/selinux/config in vim to modify SELINUX = disabled.

# Getenforce 0

2) uninstall conflicting packages on all nodes

MySQL-Cluster-related software packages (http://pan.baidu.com/s/1pJv46j5 available here) have been integrated with database server/client programs, so they can be used directly to replace common MySQL Server/client programs. If you have installed common mysql-server, mysql, MySQL-server, and MySQL-client packages, uninstall them first (if not, ignore them ):

# Rpm-qa | grep-I mysql // check whether the common mysql software is installed

For the mysql-libs that comes with RHEL, they are temporarily retained (if they are directly uninstalled, many important packages, such as crontab and postfix, will be deleted due to dependency ), however, the "-U" upgrade method is used to replace the MySQl-Cluster package.

# Rpm-e -- nodeps MySQL-client

If any residual/etc/my. cnf file exists, make sure it has been transferred for backup or deleted directly.

# Mv/etc/my. cnf/etc/my. cnf. bak

3) decompress the downloaded MySQL-Cluster collection package on all nodes.

# Tar xvf MySQL-Cluster-gpl-7.3.3-1.el6.x86_64.rpm-bundle.tar

MySQL-Cluster-shared-gpl-7.3.3-1.el6.x86_64.rpm


MySQL-Cluster-shared-compat-gpl-7.3.3-1.el6.x86_64.rpm // install shared libraries and compatibility packages

MySQL-Cluster-server-gpl-7.3.3-1.el6.x86_64.rpm // install the server program

MySQL-Cluster-client-gpl-7.3.3-1.el6.x86_64.rpm // install client program

MySQL-Cluster-test-gpl-7.3.3-1.el6.x86_64.rpm

MySQL-Cluster-devel-gpl-7.3.3-1.el6.x86_64.rpm

MySQL-Cluster-embedded-gpl-7.3.3-1.el6.x86_64.rpm

 

On the SQL node (sql1, sql2) server, modify the root password of the MySQL database:

[Root @ sql1 ~] # Service mysql start // start the MySQL service program

Starting MySQL... [OK]

[Root @ sql2 ~] # Cat/root/. mysql_secret

# The random password set for the root user at Wed Sep 3 21:04:20 2014 (local time): msA7Bq2B

 

[Root @ sql1 ~] # Mysql-u root-pmsA7Bq2B // logon with the above default password

Mysql> set password = password ("123456 ");

Query OK, 0 rows affected (0.17 sec)

On data nodes (ndb1, ndb2) and management nodes (mgmsvr), You do not actually need to start the MySQL service program. Therefore, we recommend that you set the mysql Service self-starting status to disabled.

[Root @ ndb1 ~] # Chkconfig mysql off

4) add authorized database users to the SQL Node

On the SQL node (sql1 and sql2) server, add the corresponding authorized database user to facilitate the client to use the database service. Take a user as an example to allow access from the CIDR Block 192.168.4.0/24:

 

Mysql> grant all on *. * to user @ '192. 192.% 'identified by "168.4 ";

Query OK, 0 rows affected (0.03 sec)

 

2. Configuration Management node mgmsvr (192.168.4.3)

1) Create a working folder

Provides a working directory for the management node to easily record log messages related to the mysql cluster:

[Root @ mgmsvr ~] # Mkdir/var/log/mysql-cluster

2) create a configuration file

The configuration file of the Management node should cover the settings of all nodes, including the idnumber, host name or IP address, working directory, and other information of each node.

For this experiment, the configuration of management nodes is as follows:

[Root @ mgmsvr ~] # Cat/etc/config. ini // the file name can be arbitrary.

[Ndbd default] // specify the default configuration for all nodes

NoOfReplicas = 2 // retain two copies of data

DataMemory = 80 M // data cache size

IndexMemory = 18 M // index cache size

[Ndb_mgmd] // specifies the configuration of a management node, which can have multiple Management Nodes

Nodeid = 3 // node ID, which is the unique identifier of a node. It cannot be the same as other nodes.

Hostname = 192.168.4.3 // ip address of the node

Datadir =/var/log/mysql-cluster // working directory of the Management Node

[Ndbd] // specifies the configuration of a data node. Each data node corresponds to an ndbd configuration.

Nodeid = 4

Hostname = 192.168.4.4

Datadir =/var/log/mysql-cluster/data

[Ndbd]

Nodeid = 5

Hostname = 192.168.4.5

Datadir =/var/log/mysql-cluster/data

[Mysqld] // specifies the configuration of the SQL node. Each SQL node corresponds to a configuration of mysqld

Nodeid = 6

Hostname = 192.168.4.6

[Mysqld]

Nodeid = 7

Hostname = 192.168.4.7

For more details, please continue to read the highlights on the next page:

  • 1
  • 2
  • 3
  • 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.