标签:ext ast 集群 mys pass ports mysql vol 设置
yls
2020/5/2
cd /usr/local/docker
mkdir pxc
cd pxc
mkdir data master follower
# 创建数据卷
cd data
mkdir v1 v2 v3
# 设置权限
chmod 777 v1 v2 v3
docker network create --subnet 192.168.5.1/24 pxc
version: ‘3‘
services:
pxc1:
image: pxc
restart: always
container_name: pxc1
privileged: true
ports:
- 13306:3306
environment:
- MYSQL_ROOT_PASSWORD=root
- CLUSTER_NAME=pxc
volumes:
- ../data/v1:/var/lib/mysql
networks:
default:
external:
name: pxc
docker-compose up -d
运行master节点
通过docker network inspect pxc
可以查看到master节点的ip为192.168.5.2
version: ‘3‘
services:
pxc2:
image: pxc
container_name: pxc2
restart: always
privileged: true
ports:
- 13307:3306
environment:
- MYSQL_ROOT_PASSWORD=root
- CLUSTER_NAME=pxc
- CLUSTER_JOIN=192.168.5.2
volumes:
- ../data/v2:/var/lib/mysql
networks:
default:
ipv4_address: 192.168.5.5
pxc3:
image: pxc
container_name: pxc3
restart: always
privileged: true
ports:
- 13308:3306
environment:
- MYSQL_ROOT_PASSWORD=root
- CLUSTER_NAME=pxc
- CLUSTER_JOIN=192.168.5.2
volumes:
- ../data/v3:/var/lib/mysql
networks:
default:
ipv4_address: 192.168.5.4
networks:
default:
external:
name: pxc
docker-compose up -d
运行follower节点
标签:ext ast 集群 mys pass ports mysql vol 设置
原文地址:https://www.cnblogs.com/yloved/p/12817212.html