MySQL cluster mysql-cluster Installation

Source: Internet
Author: User

Hostname IP address application service
DB1 www.bkjia.com MGM
DB2 192.168.6.160 NDBD, MYSQLD
DB3 192.168.6.188 NDBD2, MYSQLD
DB4 192.168.6.191 MYSQLD 1. DB1 management node MGM

. /Configure -- prefix =/usr/local/mysql/-- with-charset = utf8 -- with-collation = utf8_general_ci -- with-client-ldflags =-all-static-with-mysqld- ldflags =-all-static -- enable-starter er -- with-extra-charsets = complex -- enable-thread-safe-client -- with-big-tables -- with-readline -- with-ssl -- with-embedded-server -- enable-local-infile -- with-unix-socket-path =/tmp/mysql. sock -- sysconfdir =/usr/local/mysql/etc -- without-debug -- with-mysqld-user = mysql -- with-plugin = innobase -- with-plugin-ndbcluster -- with-plugin -partition
Make
Make install
Cd/usr/local/mysql
Mkdir mysql-cluster
Cd mysql-cluster
Vim config. ini

[Ndbd default]
NoOfReplicas = 2
[Mysqld default]
[Ndb_mgmd default]
DataDir =/usr/local/mysql-cluster
[Ndb_mgmd]
HostName = www.bkjia.com
[Ndbd]
HostName = 192.168.6.160
DataDir =/usr/local/mysql-cluster
[Ndbd]
HostName = 192.168.6.188
DataDir =/usr/local/mysql-cluster
[Mysqld]
HostName = 192.168.6.160
[Mysqld]
HostName = 192.168.6.188
[Mysqld]
HostName = 192.168.6.191/usr/local/mysql/libexec/ndb_mgmd-f/usr/local/mysql-cluster/config. ini/usr/local/mysql/bin/ndb_mgm
-- NDB Cluster -- Management Client --
Ndb_mgm> show
Connected to Management Server at: localhost: 1186
Cluster Configuration
---------------------
[Ndbd (NDB)] 2 node (s)
Id = 2 (not connected, accepting connect from 192.168.6.160)
Id = 3 (not connected, accepting connect from 192.168.6.188)

[Ndb_mgmd (MGM)] 1 node (s)
Id = 1 @ www.bkjia.com (Version: 5.1.45)

[Mysqld (API)] 3 node (s)
Id = 4 (not connected, accepting connect from 192.168.6.160)
Id = 5 (not connected, accepting connect from 192.168.6.188)
Id = 6 (not connected, accepting connect from 192.168.6.191) You Can See That ndb_mgmd is connected, and nbd and mysqld are not connected yet ~

2. Install mysql in DB1 on two ndbd nodes

. /Configure -- prefix =/usr/local/mysql/-- with-charset = utf8 -- with-collation = utf8_general_ci -- with-client-ldflags =-all-static-with-mysqld- ldflags =-all-static -- enable-starter er -- with-extra-charsets = complex -- enable-thread-safe-client -- with-big-tables -- with-readline -- with-ssl -- with-embedded-server -- enable-local-infile -- with-unix-socket-path =/tmp/mysql. sock -- sysconfdir =/usr/local/mysql/etc -- without-debug -- with-mysqld-user = mysql -- with-plugin = innobase -- with-plugin-ndbcluster -- with-plugin -partition

Groupadd mysql
Useradd-g mysql
Cd/usr/local/mysql
Chown root. mysql.-R
/Usr/local/mysql/bin/mysql_install_db -- user = mysql

Vim/usr/local/mysql/etc/my. cnf
[Mysqld]
Basedir =/usr/local/mysql/
Datadir =/usr/local/mysql/var
User = mysql
Port = 3306
Socket =/tmp/mysql. sock
Ndbcluster
Ndb-connectstring = www.bkjia.com
[Mysql_cluster]
Ndb-connectstring = www.bkjia.com/usr/local/mysql/libexec/ndbd -- initial ### required for first start -- mysql service on two ndbd nodes is not required after initial is started.

/Usr/local/mysql/bin/mysqld_safe -- user = mysql & then view it on the MGM Server

/Usr/local/mysql/bin/ndb_mgm
-- NDB Cluster -- Management Client --
Ndb_mgm> show
Cluster Configuration
---------------------
[Ndbd (NDB)] 2 node (s)
Id = 2 @ 192.168.6.160 (Version: 5.1.45, Nodegroup: 0)
Id = 3 @ 192.168.6.188 (Version: 5.1.45, Nodegroup: 0, Master)
[Ndb_mgmd (MGM)] 1 node (s)
Id = 1 @ www.bkjia.com (Version: 5.1.45)
[Mysqld (API)] 3 node (s)
Id = 4 @ 192.168.6.160 (Version: 5.1.45)
Id = 5 @ 192.168.6.188 (Version: 5.1.45)
Id = 6 (not connected, accepting connect from 192.168.6.191) from the above we can see that two ndbd nodes and two mysql services on ndbd have been connected.
Iii. Install mysql nodes in DB4

. /Configure -- prefix =/usr/local/mysql/-- with-charset = utf8 -- with-collation = utf8_general_ci -- with-client-ldflags =-all-static-with-mysqld- ldflags =-all-static -- enable-starter er -- with-extra-charsets = complex -- enable-thread-safe-client -- with-big-tables -- with-readline -- with-ssl -- with-embedded-server -- enable-local-infile -- with-unix-socket-path =/tmp/mysql. sock -- sysconfdir =/usr/local/mysql/etc -- without-debug -- with-mysqld-user = mysql -- with-plugin = innobase -- with-plugin-ndbcluster -- with-plugin -partition
Groupadd mysql
Useradd-g mysql
Cd/usr/local/mysql
Chown root. mysql.-R
/Usr/local/mysql/bin/mysql_install_db -- user = mysql
Vim/usr/local/mysql/etc/my. cnf
[Mysqld]
Basedir =/usr/local/mysql/
Datadir =/usr/local/mysql/var
User = mysql
Port = 3306
Socket =/tmp/mysql. sock
Ndbcluster
Ndb-connectstring = www.bkjia.com
[Mysql_cluster]
Ndb-connectstring = www.bkjia.com start mysql Service

/Usr/local/mysql/bin/mysqld_safe -- user = mysql & Return to MGM to check whether it is normal

DB1 $>/usr/local/mysql/bin/ndb_mgm
-- NDB Cluster -- Management Client --
Ndb_mgm> show
Connected to Management Server at: localhost: 1186
Cluster Configuration
---------------------
[Ndbd (NDB)] 2 node (s)
Id = 2 @ 192.168.6.160 (Version: 5.1.45, Nodegroup: 0)
Id = 3 @ 192.168.6.188 (Version: 5.1.45, Nodegroup: 0, Master)
[Ndb_mgmd (MGM)] 1 node (s)
Id = 1 @ www.bkjia.com (Version: 5.1.45)
[Mysqld (API)] 3 node (s)
Id = 4 @ 192.168.6.160 (Version: 5.1.45)
Id = 5 @ 192.168.6.188 (Version: 5.1.45)
Id = 6 @ 192.168.6.191 (Version: 5.1.45). Now everything is normal. Go back to the mysql node and create and delete data to see if data is synchronized.
Log on to mysql

DB2 $>/usr/local/mysql/bin/mysql-uroot-p
Mysql> show databases;
+ -------------------- +
| Database |
+ -------------------- +
| Information_schema |
| Mysql |
+ -------------------- +
2 rows in set (0.00 sec)
Mysql> create database eric;
Query OK, 1 row affected (0.39 sec)
Mysql> show databases;
+ -------------------- +
| Database |
+ -------------------- +
| Information_schema |
| Eric |
| Mysql |
+ -------------------- +
3 rows in set (0.01 sec). Check whether the data is synchronized on DB3 DB4.

Db3 $>/usr/local/mysql/bin/mysql-uroot-p
Mysql $> show databases;
+ -------------------- +
| Database |
+ -------------------- +
| Information_schema |
| Eric |
| Mysql |
+ ------------------ + DB4 $>/usr/local/mysql/bin/mysql-uroot-p
Mysql $> show databases;
+ -------------------- +
| Database |
+ -------------------- +
| Information_schema |
| Eric |
| Mysql |
+ -------------------- +

All of them see eric database.

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.