docker-swarm部署mysql主从集群的 Compose 模板
时间: 2023-12-04 11:17:32 浏览: 158
好的,关于docker-swarm部署mysql主从集群的Compose模板,你可以参考下面的示例:
version: '3.7'
services:
mysql-master:
image: mysql:5.7
environment:
MYSQL_ROOT_PASSWORD: example
volumes:
- master-data:/var/lib/mysql
deploy:
replicas: 1
restart_policy:
condition: any
placement:
constraints:
- node.role == manager
mysql-slave:
image: mysql:5.7
environment:
MYSQL_ROOT_PASSWORD: example
MYSQL_MASTER_HOST: mysql-master
MYSQL_MASTER_PORT: 3306
MYSQL_MASTER_ROOT_PASSWORD: example
volumes:
- slave-data:/var/lib/mysql
deploy:
replicas: 2
restart_policy:
condition: any
placement:
constraints:
- node.role == worker
volumes:
master-data:
slave-data:
为了达到最佳效果,请根据您的环境进行修改。希望对你有所帮助!接下来,你还有什么问题吗?
阅读全文