本文主要是介绍docker-compose部署traefik负载本机docker-pxc集群,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
一.下载docker-compose
https://download.csdn.net/download/cyw8998/89093489 2.172
https://download.csdn.net/download/cyw8998/89122396 2.5
拷贝到/usr/local/bin中,并赋权限chmod +x /usr/local/bin/docker-compose
二.安装docker traefik:v2.4
docker pull traefik:v2.4
或者直接下载镜像
https://download.csdn.net/download/cyw8998/89122404
三.docker-conpose.yml配置
#abc#
version : '3.7'
services:traefik:image: traefik:v2.4command:- "--providers.docker=true"- "--entrypoints.pxc.address=:3301"- "--api=true" # 启用Traefik的API- "--api.insecure=true" # 启用Traefik的Web UI- "--providers.docker"ports:- "18080:8080" # Traefik dashboard- "3301:3301"volumes:- "/var/run/docker.sock:/var/run/docker.sock"restart: always #on-failurenetworks:- traefik-pxcdb1:container_name: db1image: percona/percona-xtradb-cluster:8.0privileged: truenetworks:traefik-pxc:ipv4_address: 170.19.0.11environment:- "CLUSTER_NAME=JWSPXC"- "XTRABACKUP_PASSWORD=123456"- "MYSQL_ROOT_PASSWORD=123456"- "TZ=Asia/Shanghai"ports:- "23306:3306"volumes:- v301:/var/lib/mysql- ~/pxc-docker-test/cert:/cert- ~/pxc-docker-test/config:/etc/percona-xtradb-cluster.conf.dlabels:- "traefik.enable=true"- "traefik.tcp.routers.pxc-cluster.rule=HostSNI(`*`)"- "traefik.tcp.routers.pxc-cluster.entrypoints=pxc"- "traefik.tcp.services.pxc-cluster.loadbalancer.server.port=3306"db2:container_name: db2image: percona/percona-xtradb-cluster:8.0privileged: truenetworks:traefik-pxc:ipv4_address: 170.19.0.12environment:- "CLUSTER_NAME=JWSPXC"- "XTRABACKUP_PASSWORD=123456"- "TZ=Asia/Shanghai"- "CLUSTER_JOIN=db1"ports:- "23307:3306"volumes:- v302:/var/lib/mysql- ~/pxc-docker-test/cert:/cert- ~/pxc-docker-test/config:/etc/percona-xtradb-cluster.conf.ddepends_on:- db1labels:- "traefik.enable=true"- "traefik.tcp.routers.pxc-cluster.rule=HostSNI(`*`)"- "traefik.tcp.routers.pxc-cluster.entrypoints=pxc"- "traefik.tcp.services.pxc-cluster.loadbalancer.server.port=3306"volumes:v301:v302:
networks:traefik-pxc:driver: bridgeipam:driver: defaultconfig:- subnet: 170.19.0.0/24
1.运行命令
docker-compose up -d traefik
docker-compose up -d db1
docker-compose up -d db2
注意pxc8需要集群需要证书验证
生成证书命令见另一篇文章
这篇关于docker-compose部署traefik负载本机docker-pxc集群的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!