CENTOS7 MySQL cluster cluster build based on Docker

Source: Internet
Author: User
Tags db2 install perl docker ps

1. Preparation

MN: The cluster Management Server is used to manage other nodes of the cluster. We can create and configure new nodes on the cluster, restart, delete, or back up nodes from the management node.

DB2/DB3: This is the layer in which the process of inter-node synchronization and data replication occurs.

DB4/DB5: An interface server used by an application to connect to a DB cluster.

[[email protected] ~]# Docker inspect-f ' {{. Name}}-{{range. networksettings.networks}}{{. Ipaddress}}{{end}} ' $ (Docker Ps-aq)
/db5-172.17.0.6
/db4-172.17.0.5
/db3-172.17.0.4
/db2-172.17.0.3
/mn-172.17.0.2
[Email protected] ~]#

2.MN Installation

CD ~
wget Http://dev.mysql.com/get/Downloads/MySQL-Cluster-7.4/MySQL-Cluster-gpl-7.4.10-1.el7.x86_64.rpm-bundle.tar
TAR-XVF Mysql-cluster-gpl-7.4.10-1.el7.x86_64.rpm-bundle.tar

Yum-y Install Perl-data-dumper
Yum-y Remove Mariadb-libs

CD ~
RPM-UVH mysql-cluster-client-gpl-7.4.10-1.el7.x86_64.rpm
RPM-UVH mysql-cluster-server-gpl-7.4.10-1.el7.x86_64.rpm
RPM-UVH mysql-cluster-shared-gpl-7.4.10-1.el7.x86_64.rpm

Make sure there is no error.

To configure MN:

Mkdir-p/var/lib/mysql-cluster

Cd/var/lib/mysql-cluster
VI Config.ini

[NDB_MGMD Default]
# Directory for MGM node log files
Datadir=/var/lib/mysql-cluster

[NDB_MGMD]
#Management Node DB1
hostname=192.168.1.120

[NDBD Default]
noofreplicas=2 # of Replicas
datamemory=256m # Memory allocate for data storage
indexmemory=128m # Memory allocate for index storage
#Directory for Data Node
Datadir=/var/lib/mysql-cluster

[NDBD]
#Data Node DB2
hostname=192.168.1.121

[NDBD]
#Data Node DB3
hostname=192.168.1.122

[Mysqld]
#SQL Node DB4
Hostname=192.168.1.123

[Mysqld]
#SQL Node DB5
hostname=192.168.1.124

Start MN:

NDB_MGMD--config-file=/var/lib/mysql-cluster/config.ini

MySQL Cluster Management Server mysql-5.6.28 ndb-7.4.10
2016-03-22 19:26:08 [Mgmtsrvr] INFO-The default Config directory '/usr/mysql-cluster ' does not exist. Trying to create it ...
2016-03-22 19:26:08 [Mgmtsrvr] INFO--Successfully created Config directory

Ndb_mgm
Show

DB2/DB3 Configuration Data node:

CD ~
wget Http://dev.mysql.com/get/Downloads/MySQL-Cluster-7.4/MySQL-Cluster-gpl-7.4.10-1.el7.x86_64.rpm-bundle.tar
TAR-XVF Mysql-cluster-gpl-7.4.10-1.el7.x86_64.rpm-bundle.tar

Yum-y Install Perl-data-dumper
Yum-y Remove Mariadb-libs

CD ~
RPM-UVH mysql-cluster-client-gpl-7.4.10-1.el7.x86_64.rpm
RPM-UVH mysql-cluster-server-gpl-7.4.10-1.el7.x86_64.rpm
RPM-UVH mysql-cluster-shared-gpl-7.4.10-1.el7.x86_64.rpm

Vi/etc/my.cnf

[Mysqld]
Ndbcluster
NDB-CONNECTSTRING=192.168.1.120 # IP Address of Management Node

[Mysql_cluster]
NDB-CONNECTSTRING=192.168.1.120 # IP Address of Management Node

Mkdir-p/var/lib/mysql-cluster

ndbd

Results

2016-03-22 19:35:56 [NDBD] INFO--Angel connected to ' 192.168.1.120:1186 '
2016-03-22 19:35:56 [NDBD] INFO--Angel allocated Nodeid:2

DB4/DB5 configuration:

CD ~
wget Http://dev.mysql.com/get/Downloads/MySQL-Cluster-7.4/MySQL-Cluster-gpl-7.4.10-1.el7.x86_64.rpm-bundle.tar
TAR-XVF Mysql-cluster-gpl-7.4.10-1.el7.x86_64.rpm-bundle.tar

Yum-y Install Perl-data-dumper
Yum-y Remove Mariadb-libs

CD ~
RPM-UVH mysql-cluster-client-gpl-7.4.10-1.el7.x86_64.rpm
RPM-UVH mysql-cluster-server-gpl-7.4.10-1.el7.x86_64.rpm
RPM-UVH mysql-cluster-shared-gpl-7.4.10-1.el7.x86_64.rpm

Vi/etc/my.cnf

[Mysqld]
Ndbcluster
NDB-CONNECTSTRING=192.168.1.120 # IP address for Server Management node
Default_storage_engine=ndbcluster # Define default storage engine used by MySQL

[Mysql_cluster]
NDB-CONNECTSTRING=192.168.1.120 # IP address for Server Management node

Service MySQL Start

Cluster monitoring:

Ndb_mgm
Ndb_mgm> Show

Ndb_mgm-e "All Status"
NDB_MGM-E "All report Memory"

In DB4 or in the DB5 test cluster:

Mysql-u root-p

CREATE USER ' root ' @ '% ' identified by ' aqwe123 ';

Select User, host, password from Mysql.user;

GRANT all privileges on * * to ' root ' @ '% ' identified by PASSWORD ' *94cc7bf027327993d738e11 ... (Encrypted PASSWORD) ' with GRANT OPTION;

The final result:

Results also appear on DB5:

They say the problem is much, the mainstream is mycat+mysql. We'll toss it tomorrow.

CENTOS7 MySQL cluster cluster build based on Docker

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.