Configuring MySQL cluster +nextcloud cluster +haproxy load balancing with Docker images

Source: Internet
Author: User
Tags docker run haproxy

Test environment:

Docker

XAMPP 9.1.1

Ubuntu 16.0.4

Hadoop 2.7

JDK 1.8

First, configure MySQL cluster

Create a container from Docker pull MySQL cluster image, including NDB_MGM (Management node), NDB_MGMD01, NDBD01 (Data node 1), NDBD02 (Data node 2), MYSQLD01 (SQL Node 1), MYSQLD02 (SQL Node 2)

Docker run-itd--name ndb_mgmd01--NET=SCG--ip 192.166.0.2-v/root/owncloud-cluster/mysqlcluster/config.ini:/etc/ Mysql-cluster.ini:ro H3nrik/mysql-cluster NDB_MGMD

Docker run-itd--name ndbd01--NET=SCG--ip 192.166.0.10 h3nrik/mysql-cluster ndbd 192.166.0.2

Docker run-itd--name ndbd02--NET=SCG--ip 192.166.0.11 h3nrik/mysql-cluster ndbd 192.166.0.2

Docker run-itd--name mysqld01--NET=SCG--ip 192.166.0.100 h3nrik/mysql-cluster mysqld 192.166.0.2

Docker run-itd--name mysqld02--NET=SCG--ip 192.166.0.101 h3nrik/mysql-cluster mysqld 192.166.0.2

Docker run-it--name ndb_mgm--NET=SCG h3nrik/mysql-cluster ndb_mgm 192.166.0.2

Where the--net parameter is the internal access network name between the specified container,--ip is the content of the specified container ip,-v refers to the local configuration of the Config.ini file, and then map it into the NDB_MGMD container

Config.ini configuration content is as follows

[NDBD DEFAULT]
noofreplicas=2
datamemory=80m
indexmemory=18m
Datadir=/usr/local/mysql/data

[NDB_MGMD DEFAULT]
Datadir=/var/lib/mysql-cluster

[NDB_MGMD]
Nodeid=1
hostname=192.166.0.2

[NDBD]
nodeid=10
hostname=192.166.0.10

[NDBD]
nodeid=11
hostname=192.166.0.11

[MYSQLD]
nodeid=100
hostname=192.166.0.100

[MYSQLD]
Nodeid=101
Hostname=192.166.0.101

Verify that the MySQL cluster configuration is successful:

Docker run-it--name ndb_mgm--NET=SCG h3nrik/mysql-cluster ndb_mgm 192.166.0.2 after entering NDB_MGM management node

Enter the command show to view data node and SQL node connection condition

Mysql-cluster Configuration Succeeded

Second, configure Haproxy load Balancing

Docker run-d--name my-running-haproxy–-ip=192.166.0.50–port=8011:3306–net=scg-v/usr/local/etc/haproxy/ Haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro Haproxy:latest

--IP Specifies the Haproxy container ip,-net specify the container internal network name,-p specifies the port mapping, and-V maps the local configuration file to the container

The configuration file contents are as follows

Global
Log 127.0.0.1 local0 Notice
# User Haproxy
# Group Haproxy

Defaults
Log Global
Retries 2
Timeout Connect 3000
Timeout Server 5000
Timeout Client 5000

Listen Mysql-cluster
Bind *:3306
Mode TCP
# option Mysql-check User Haproxy_check
Balance Roundrobin
Server Mysql01 192.166.0.100:3306 Check
Server mysql02 192.166.0.101:3306 Check

Listen stats #monitor
Mode http
Bind *:8888
Stats URI/

Start Haproxy Load Balancer container

Docker Start Haproxy container name

Third, configuration Nextcloud

1. Download Nextcloud and unzip the website

2. Copy the Nextcloud folder to/opt/lamp/htdocs, which is the XAMPP host file

3. Start XAMPP

Sudo/opt/lamp/lamp start

4. Create a new Data folder under/opt/lamp/htdocs

5. Authorization to data file

Sudo Chmod-r 777/opt/lamp/htdocs

Sudo Chmod-r 770/opt/lamp/htdocs/data

Sudo Chown-r Daemon:daemon/opt/lamp/htdocs/data

6. Enter MYSQLD01 and create a database

Create a new user

Mysql>create USER ' Test ' @ ' l% ' identified by ' 123456 ';

Create a new database

Mysql>create DATABASE IF not EXISTS Nextcloud;

Authorizing the Nextcloud database

Mysql>grant all privileges in nextcloud.* to ' test ' @ ' percent ' identified by ' 123456 ';

Mysql>flush priveleges;

Authorizing remote access to a database

Mysql> Grant all privileges on * * to ' test ' @ ' percent ' identified by ' 123456 ' with GRANT option;

Mysql>flush priveleges;

7. Enter MYSQLD02 and authorize

Mysql>create USER ' Test ' @ ' l% ' identified by ' 123456 ';

Mysql>grant all privileges in nextcloud.* to ' test ' @ ' percent ' identified by ' 123456 ';

Mysql>flush priveleges;

Mysql> Grant all privileges on * * to ' test ' @ ' percent ' identified by ' 123456 ' with GRANT option;

Mysql>flush priveleges;

The difference between this and mysqld01 is that there is no need to build Nextcloud database, but to create new users and authorizations, new users are just as good as mysqld01.

8. Open Localhost/nextcloud Input Database information

Configuration succeeded

Configuring MySQL cluster +nextcloud cluster +haproxy load balancing with Docker images

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.