xinity / pxc_swarm

a docker swarm Percona PXC setup
Apache License 2.0
36 stars 12 forks source link

Can't connect to local MySQL server through socket '/var/lib/mysql/mysql. sock' in proxy node #8

Open Qanah opened 4 years ago

Qanah commented 4 years ago

I have this approach, but it does not work can you help me with this

version: '3.1'

# https://xinity.github.io/Percona-PXC-Swarm-mode/

services:

  etcd:
    image: elcolio/etcd:latest
    networks:
      - galera_network
    ports:
      - 2379:2379
      - 2380:2380
      - 4001:4001
      - 7001:7001
    deploy:
      mode: replicated
      labels: [APP=etcd]
      replicas: 1
      placement:
        constraints: [node.role == manager]

  proxy:
    depends_on:
      - etcd
    image: perconalab/proxysql
    networks:
      - galera_network
    ports:
      - 3306:3306
      - 6032:6032
    environment:
      DISCOVERY_SERVICE: "etcd:2379"
      CLUSTER_NAME: "galera-15"
      MYSQL_ROOT_PASSWORD: "s3cr3TL33tP@ssw0rd"
      MYSQL_PROXY_USER: "proxyuser"
      MYSQL_PROXY_PASSWORD: "s3cr3TL33tPr0xyP@ssw0rd"
    deploy:
      mode: replicated
      replicas: 1
      labels: [APP=proxysql]
      # service restart policy
      restart_policy:
        condition: on-failure
        delay: 5s
        max_attempts: 3
        window: 120s
      # service update configuration
      update_config:
        parallelism: 1
        delay: 10s
        failure_action: continue
        monitor: 60s
        max_failure_ratio: 0.3
      # placement constraint - in this case on 'worker' nodes only
      placement:
        constraints: [node.role == manager]

  percona-xtradb-cluster:
    image: percona/percona-xtradb-cluster
    networks:
      - galera_network
    environment:
      DISCOVERY_SERVICE: "etcd:2379"
      CLUSTER_NAME: "galera-15"
      CLUSTER_JOIN: "proxy"
      MYSQL_ROOT_PASSWORD: "s3cr3TL33tP@ssw0rd"
    command: >
      /bin/sh -c "until mysqladmin ping -h proxy -P 3306 -u root -ps3cr3TL33tP@ssw0rd | grep 'mysqld is alive'; do echo 'MySQL is unavailable - waiting for it... 😴'; sleep 1; done; mysqld"
    deploy:
      mode: global
      labels: [APP=pxc]
      # service restart policy
      restart_policy:
        condition: on-failure
        delay: 5s
        max_attempts: 3
        window: 120s
      # service update configuration
      update_config:
        parallelism: 1
        delay: 10s
        failure_action: continue
        monitor: 60s
        max_failure_ratio: 0.3
      # placement constraint - in this case on 'worker' nodes only
      placement:
        constraints: [node.role == worker]

networks:
  galera_network:
    external: true