Docker build cluster MySQL

Source: Internet
Author: User
Tags database load balancing percona docker run haproxy

1. Create a MySQL Cluster
Download PXC image
Docker Pull Percona/percona-xtradb-cluster
Create an internal network: For security reasons, you need to create a docker internal network for your PXC cluster instances
Create command: Docker network Create Net1
Create a specified network segment: Docker network Create--SUBNET=172.18.0.0/24 Net1
View Network properties: Docker network Inspect NET1
Delete Networks: Docker network RM net1

Create a Docker volume (a workaround for the PXC node mapping data directory in the container)
Docker Volume Create--name v1

Create a PXC container (you can create a PXC container only if you want to pass in the run parameter like a PXC mirror)
Node1 node:
Docker run-d-P 3,306:3,306 \
-V v1:/var/lib/mysql \
-e mysql_root_password= database password \
-E cluster_name=pxc \
-e xtrabackup_password= passwords synchronized between database nodes \
--privileged--name=node1--net=net1--ip=172.18.0.0/24 PXC

Node2 to NODE5 node
Docker run-d-P 3,306:3,306 \
-V v1:/var/lib/mysql \
-e mysql_root_password= database password \
-E cluster_name=pxc \
-e xtrabackup_password= passwords synchronized between database nodes \
-E cluster_join=node1 \
--privileged--name=node#--net=net1--ip=172.18.0.0/24 PXC

2. Database Load Balancing:
Download Haproxy image
Docker Pull Haproxy
Docker Images viewing mirrors
Create a Haproxy configuration file
Created on Host: Touch/home/soft/haproxy.cfg
The configuration file can be consulted: https://zhangge.net/5125.html

Docker build cluster MySQL

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.