MySQL Cluster instance

Source: Internet
Author: User
Tags pkill

Original address: http://www.it165.net/database/html/201403/5678.html

MySQL Cluster

Cluster/cluster: Provide the same service with a group of servers

LB cluster: Load Balancing cluster (multiple servers working together)

Ha clusters: high-reliability clusters (one for backup)

The role of a host in the MySQL cluster architecture:

Type

Service process

Main purpose

Management node

Ndb_mgmd

Provide cluster configuration, start or stop nodes,

Perform tasks such as backup, cluster monitoring, etc.

The management node must be the first one to start

Data node

NDBD (Single thread)

NDB_MTD (multi-threaded)

Store actual table records, can have multiple replicas

Minimum of 2 data nodes recommended

SQL node

Mysqld

Can be understood as a standard MySQL server that supports NDB,

Store table structure only, independent user authorization

user authentication, SQL query, etc. for clients

Access to services

Second, installation

No need to install mysql-server software, so you can turn off the MySQL service

Install Mysql-cluster cluster software on all hosts in the cluster

Mysql-cluster software is available in 3 different processes:

1,MYSQLD process: For users to access and execute SQL statements

2, data process NDBD: Store data

3, Management process MGMD: Manage all hosts in the cluster

Third, specific ideas:

1, Configuration Management node: Server1

IP Address: 192.168.1.1

Mkdir/var/log/my-cluster

Vim/etc/my-cluster.ini (the file does not exist and needs to be created)

[NDBD Default]//set parameter for data node

noofreplicas=2//Reserved 2 copies of data

datamemory=80m//Data cache size

indexmemory=18m//Index cache size

[NDB_MGMD]//Set Management node

Nodeid=1//Management node identification

IP address of the hostname=192.168.1.1//Management node

Datadir=/var/log/my-cluster//working directory

[MYSQLD]//Set SQL node server1

nodeid=2//ID logo

hostname=192.168.1.20//IP address of this node

[MYSQLD]//Set SQL node Server2

Nodeid=3

hostname=192.168.1.30

[NDBD]//Set Data node Server4

nodeid=4//ID logo

hostname=192.168.1.40//IP address of this node

Datadir=/var/log/mysql-cluster//working directory

[NDBD]//Set Data node Server5

Nodeid=5

hostname=192.168.1.50

Datadir=/var/log/mysql-cluster

2, Configuring the SQL node (SERVER2,SERVER3)

Edit the configuration file for the SQL node/etc/my.cnf (it does not exist and needs to be created)

Vim/etc/my.cnf

[Mysqld]

Ndbcluster//using NDB cluster engine

Default-storage-engine=ndbcluster//Set default engine

[Mysql_cluster]

ndb-connectstring=192.168.1.1//Specify the Management node IP address

Server3 on the same configuration as Server2

3, Configuration Data node (SERVER4,SERVER5)

First create the folder specified on the configuration file on Server1:

Mkdir/var/log/mysql-cluster

Then edit the configuration file for the data node (/ETC/MY.CNF itself does not exist and needs to be created)

Vim/etc/my.cnf

[Mysqld]

Datadir=/var/log/mysql-cluster//working directory, the directory specified in the configuration file on the management node

ndb-connectstring=192.168.1.1//Manage the IP address of the host computer

Ndbcluster//using NDB cluster storage engine as Ndbcluster

[Mysql_cluster]//Specify the host that manages the cluster

ndb-connectstring=192.168.1.1//Specify the IP address of the management cluster

Note: The same as the configuration on Server4 and SERVER5

4, Initialize authorization library

5. Start All server services

First: Start the management process on the management host first

On the Server1:

Ndb_mgmd-f/etc/my-cluster.ini//Load configuration file when starting the management process My-cluster.ini

NDB_MGM//Login

Show//View the status of all hosts in the rush crowd

Close the process using: pkill-9 NDBD_MGMD

Second: Start the NDBD process on the Data node host (SERVER4, SERVER5)

On Server4 and Server5:

NDBD//Open NDBD process

If you want to close, kill the process number with kill or Pkill kill the NDBD process

Third: Start a SQL node (SERVER2,SERVER3)

Start the MySQL service

Service MySQL Start

MySQL Cluster configuration example:

Environment:

server1:192.168.1.1

server2:192.168.1.20

server3:192.168.1.30

server4:192.168.1.40

server5:192.168.1.50

First step: Server1 configuration:

[Email protected] ~]# Mkdir/var/log/my-cluster

[Email protected] ~]# Cat/etc/my-cluster.ini

[NDBD Default]

noofreplicas=2

datamemory=80m

indexmemory=18m

[NDB_MGMD]

Nodeid=1

hostname=192.168.1.1

Datadir=/var/log/my-cluster

[Mysqld]

nodeid=2

hostname=192.168.1.20

[Mysqld]

Nodeid=3

hostname=192.168.1.30

[NDBD]

Nodeid=4

hostname=192.168.1.40

Datadir=/var/log/mysql-cluster

[NDBD]

Nodeid=5

hostname=192.168.1.50

Datadir=/var/log/mysql-cluster

[Email protected] ~]#

Note: IP address is 192.168.1.1

Step two: Configuration of Server2 and Server3:

[Email protected] ~]# Ifconfig | grep addr

eth1 Link encap:ethernet HWaddr 00:0c:29:22:b2:31

inet addr:192.168.1.20 bcast:192.168.1.255 mask:255.255.255.0

Inet6 ADDR:FE80::20C:29FF:FE22:B231/64 Scope:link

inet addr:127.0.0.1 mask:255.0.0.0

Inet6 addr::: 1/128 scope:host

[Email protected] ~]# VIM/ETC/MY.CNF

[Email protected] ~]# CAT/ETC/MY.CNF

[Mysqld]

Ndbcluster

Default-storage-engine=ndbcluster

[Mysql_cluster]

ndb-connectstring=192.168.1.1

[Email protected] ~]#

Note: The Server3 and Server2 are configured identically and the IP address is 192.168.1.30

Step three: Configuration on Server4 and SERVER5:

[Email protected] ~]# Ifconfig | Head-2

eth1 Link encap:ethernet HWaddr 00:0c:29:b6:6a:99

inet addr:192.168.1.40 bcast:192.168.1.255 mask:255.255.255.0

[Email protected] ~]# VIM/ETC/MY.CNF

[Email protected] ~]# CAT/ETC/MY.CNF

[Mysqld]

Datadir=/var/log/mysql-cluster

ndb-connectstring=192.168.1.1

Ndbcluster

[Mysql_cluster]

ndb-connectstring=192.168.1.1

[Email protected] ~]#

Fourth Step:

Start the management host Server1 first

[Email protected] desktop]# ndb_mgmd-f/etc/my-cluster.ini

MySQL Cluster Management Server mysql-5.6.14 ndb-7.3.3

[Email protected] desktop]# NDB_MGM

--NDB Cluster--Management Client--

Ndb_mgm> Show

Connected to Management Server at:localhost:1186

Cluster Configuration

---------------------

[NDBD (NDB)] 2 node (s)

Id=4 (not connected, accepting connect from 192.168.1.40)

Id=5 (not connected, accepting connect from 192.168.1.50)

[NDB_MGMD (MGM)] 1 node (s)

Id=1 @192.168.1.1 (mysql-5.6.14 ndb-7.3.3)

[Mysqld (API)] 2 node (s)

id=2 (not connected, accepting connect from 192.168.1.20)

Id=3 (not connected, accepting connect from 192.168.1.30)

Ndb_mgm>

Then start the NDBD process on server4 and SERVER5

SERVER4:

[Email protected] desktop]# NDBD

2014-03-21 18:35:42 [NDBD] INFO--Angel connected to ' 192.168.1.1:1186 '

2014-03-21 18:35:42 [NDBD] INFO--Angel allocated Nodeid:4

[Email protected] desktop]#

SERVER5:

[Email protected] desktop]# NDBD

2014-03-21 19:57:10 [NDBD] INFO--Angel connected to ' 192.168.1.1:1186 '

2014-03-21 19:57:10 [NDBD] INFO--Angel allocated Nodeid:5

[Email protected] desktop]#

Finally, start the MySQL service on Server2 and Server3:

[[Email protected] ~]# service MySQL restart

Shutting down MySQL .... [OK]

Starting MySQL ..... [OK]

[Email protected] ~]#

[[Email protected] desktop]# service MySQL restart

Shutting down MySQL ..... [OK]

Starting MySQL .... [OK]

[Email protected] desktop]#

Verify: See if the connection is successful on Server1 by the show command

Ndb_mgm> Show

Cluster Configuration

---------------------

[NDBD (NDB)] 2 node (s)

Id=4 @192.168.1.40 (mysql-5.6.14 ndb-7.3.3, nodegroup:0, *)

Id=5 @192.168.1.50 (mysql-5.6.14 ndb-7.3.3, nodegroup:0)

[NDB_MGMD (MGM)] 1 node (s)

Id=1 @192.168.1.1 (mysql-5.6.14 ndb-7.3.3)

[Mysqld (API)] 2 node (s)

id=2 @192.168.1.20 (mysql-5.6.14 ndb-7.3.3)

Id=3 @192.168.1.30 (mysql-5.6.14 ndb-7.3.3)

Ndb_mgm>

MySQL Cluster instance

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.