Full version of MySQL5.6 cluster configuration under Redhat6.5

Source: Internet
Author: User
1. Prepare three servers. 2. Install the Linux operating system (OracleLinux/RHEL6.5x86 _ 64bit) for the three servers respectively. 3. Manage the IP address management node 192.168.1.110 (responsible for managing the entire cluster) and the SQL node 192.168.1.111 & nbs.

1. Prepare three servers

2. Install the Linux operating system for the three machines respectively (Oracle Linux/RHEL 6.5 x86_64bit)

3. Separate IP addresses

Management node 192.168.1.110 (responsible for managing the entire cluster)

SQL node 192.168.1.111 (responsible for database operations)

SQL node 192.168.1.112 (responsible for database operations)

Data Node 192.168.1.111 (responsible for data storage)

Data Node 192.168.1.112 (responsible for data storage)

 


SQL nodes and data nodes can be on the same machine.

 


4. Modify the/etc/hosts file of the three servers. The modified content is as follows:

127.0.0.1 localhost. domain

192.168.1.110 node01

192.168.1.111 node02

192.168.1.112 node03

 

5. Modify the/etc/sysconfig/nework file of the three servers. The modified files are as follows:

NETWORKING = yes

HOSTNAME = node01

GATEWAY = 192.168.1.1 (the GATEWAY address varies depending on the Network)

 


NETWORKING = yes

HOSTNAME = node02

GATEWAY = 192.168.1.1 (the GATEWAY address varies depending on the Network)

 

NETWORKING = yes

HOSTNAME = node03

GATEWAY = 192.168.1.1 (the GATEWAY address varies depending on the Network)

 


6. Restart the three servers respectively.

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

Install MySQL http://www.linuxidc.com/Linux/2014-05/102366.htm in Ubuntu 14.04

MySQL authoritative guide (original book version 2nd) Clear Chinese scanning version PDF http://www.linuxidc.com/Linux/2014-03/98821.htm

Ubuntu 14.04 LTS install LNMP Nginx \ PHP5 (PHP-FPM) \ MySQL http://www.linuxidc.com/Linux/2014-05/102351.htm

Build a MySQL Master/Slave server http://www.linuxidc.com/Linux/2014-05/101599.htm in Ubuntu 14.04

Ubuntu 12.04 LTS build highly available distributed MySQL cluster http://www.linuxidc.com/Linux/2013-11/93019.htm

Install MySQL5.6 and Python-MySQLdb http://www.linuxidc.com/Linux/2013-08/89270.htm in Ubuntu 12.04

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


7、download ndbcluster software mysql-cluster-advanced-7.3.5-linux-glibc2.5-x86_64.tar.gz

Cluster software has three formats:

A、binary format ending with tar.gz

B. rpm packages ending with rpm

C. Use the source file compilation and Installation Method

 


The rpm package is installed automatically, so it is not convenient to configure the software installation location and data storage location.

 


Installation files in binary format ending with commonly used .tar.gz

 


Note: The mysql-cluster-advanced-7.3.5-linux-glibc2.5-x86_64.tar.gz contains mysql database software and NDB cluster Software

 


Copy the mysql-cluster-advanced-7.3.5-linux-glibc2.5-x86_64.tar.gz file to the/usr/local/directory on the three servers.

 


9. Create a mysql user

# Groupadd mysql

# Useradd-r-g mysql (because mysql users only install and configure NDB clusters or mysql software, instead of logging on to the system)

(Therefore, create a mysql user with the-r parameter, and do not set a password for the user)

 


10、separate the mysql-cluster-advanced-7.3.5-linux-glibc2.5-x86_64.tar.gz file on the three servers.

 


# Cd/usr/local

# Tar zxvf mysql-cluster-advanced-7.3.5-linux-glibc2.5-x86_64.tar.gz

# Ln-s mysql-cluster-advanced-7.3.5-linux-glibc2.5-x86_64 mysql

# Chown-R mysql. mysql mysql-cluster-advanced-7.3.5-linux-glibc2.5-x86_64

# Cd mysql

# Chown-R mysql. mysql.

After the configuration is complete, the result is as follows:

 

 

 

11. Install mysql database software on 192.168.1.111 and 192.168.1.112 data nodes (two servers)

Because it is a binary installation, the mysql database software is installed under/usr/local/mysql,

However, the database data can be stored elsewhere, such as/u01/app/mysql/data/

 

Note: The following command must be executed on both data node servers.

 

# Mkdir-p/u01/app/mysql/data

# Chown-R mysql. mysql/u01

# Cd/usr/local/mysql

# Scripts/mysql_install_db -- basedir =/usr/local/mysql -- datadir =/u01/app/mysql/data -- user = mysql

After executing this command, the database data files (including mysql, test, performance_schema, and other databases) will be installed

/U01/app/mysql/data Directory

 


# Cp bin/ndbd/usr/local/bin/

# Cp bin/ndbmtd/usr/local/bin/

Copy the Startup file of the Database Service to the/etc/rc. d/init. d/directory.

 


# Cp support-files/mysql. server/etc/rc. d/init. d/mysqld (renamed)

After executing the preceding command, you can use the service mysqld start | stop | restart command to manage the database service.

 


# Cp my. cnf/etc/my. cnf

# Vi/etc/my. cnf

[Mysqld]

Ndbcluster

Basedir =/usr/local/mysql

Datadir =/u01/app/mysql/data

Port = 3306

SQL _mode = NO_ENGINE_SUBSTITUTION, STRICT_TRANS_TABLES

 


[Mysql_cluster]

Ndb-connectstring = 192.168.1.110

 

Note: The preceding commands must be executed on both data node servers.

 

At this point, the installation and configuration of data nodes and SQL nodes are complete. If the data nodes and SQL nodes are separated on different machines, then each data node

And each SQL node must execute the preceding commands.

 


12. install and configure on the Management Node

 

The installation package of mysql-cluster-advanced-7.3.5-linux-glibc2.5-x86_64.tar.gz to/usr/local

Directory, and perform soft connections and other operations, so you do not need to repeat these operations, and then proceed to the configuration.

 


# Cd/usr/local/mysql

# Mkdir mysql-cluster (create the mysql-cluster directory and use it later when starting the cluster Management Service)

# Cp bin/ndb_mgm */usr/local/bin/

# Cd/var/lib

# Mkdir mysql-cluster

# Cd mysql-cluster

# Vi config. ini (this is the cluster configuration file on the Management node and is very important)

[Ndbd default]

NoOfReplicas = 1 # Number of replicas

DataMemory = 80 M # How much memory to allocate for data storage

IndexMemory = 18 M # How much memory to allocate for index storage

# For DataMemory and IndexMemory, we have used

# Default values. Since the "world" database takes up

# Only about 500KB, this shoshould be more than enough

# This example Cluster setup.

 


[Tcp default]

# This the default; however, you can use any

# Port that is free for all the hosts in the cluster

# Note: It is recommended that you do not specify the port

# Number at all and simply allow the default value to be used

# Instead

 


[Ndb_mgmd]

Hostname = 192.168.1.110 # Hostname or IP address of MGM node

Datadir =/var/lib/mysql-cluster # Directory for MGM node log files

NodeId = 1

 


[Ndbd]

Hostname = 192.168.1.111 # Hostname or IP address

Datadir =/u01/app/mysql/data # Directory for this data node's data files

NodeId = 2

 


[Ndbd]

Hostname = 192.168.1.112 # Hostname or IP address

Datadir =/u01/app/mysql/data # Directory for this data node's data files

NodeId = 3

 

 

[Mysqld]

Hostname = 192.168.1.111 # Hostname or IP address

NodeId = 4 # (additional mysqld connections can be

# Specified for this node for various

# Purposes such as running ndb_restore)

 


[Mysqld]

Hostname = 192.168.1.112 # Hostname or IP address

NodeId = 5 # (additional mysqld connections can be

# Specified for this node for various

# Purposes such as running ndb_restore)

 


Configuration instructions:

[Ndbd default] This part is a public part and is valid for each data node. You only need to configure one copy.

NoOfReplicas = 1 data image (each data node backs up each other)

 


[Tcp default] Which port is used for communication between each data node and the management node,

In the earlier version of NDB cluster software configuration, portnumber = 2202 is usually configured here.

However, the new NDB software does not need to be configured here, And the MySQL official strongly recommends that you do not configure

 


[Ndb_mgmd] the configuration section of the Management node (usually only one)

Note: NodeId = 1 indicates that the node ID of the Management node is 1. If this parameter is not specified, an error is returned when the cluster is started.

Hostname = 192.168.1.110 indicates the IP address of the Management Node

Datadir =/var/lib/mysql-cluster indicates the location where cluster management logs are stored.

 


[Ndbd] for data node configuration, several data nodes are configured. [ndbd]

Hostname = 192.168.1.111 indicates the IP address of the Data Node

Datadir =/u01/app/mysql/data specifies the location where the database files on the data node are stored

NodeId = 2 indicates the nodeid of the data node in the entire cluster (important)

 

[Mysqld] For the SQL node configuration section, you can configure several [mysqld] SQL nodes.

For more details, refer to the highlights on the next page.: Http://www.linuxidc.com/Linux/2014-06/103748p2.htm

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.