Skip to content

Instantly share code, notes, and snippets.

@arsalanses
Last active May 18, 2024 08:06
Show Gist options
  • Select an option

  • Save arsalanses/3cff56f2c49d97f7ee85041c5b712875 to your computer and use it in GitHub Desktop.

Select an option

Save arsalanses/3cff56f2c49d97f7ee85041c5b712875 to your computer and use it in GitHub Desktop.
mysql router
services:
mysql:
image: hub.hamdocker.ir/bitnami/mysql:8.0
ports:
- '127.0.0.1:3306:3306'
# volumes:
# - 'mysql_data:/bitnami/mysql/data'
environment:
- ALLOW_EMPTY_PASSWORD=yes
healthcheck:
test: ['CMD', '/opt/bitnami/scripts/mysql/healthcheck.sh']
interval: 15s
timeout: 5s
retries: 6
mysql-router:
image: hub.hamdocker.ir/mysql/mysql-router:8.0
restart: on-failure
environment:
- MYSQL_HOST=mysql
- MYSQL_PORT=3306
- MYSQL_USER=root
- MYSQL_PASSWORD=""
- MYSQL_INNODB_CLUSTER_MEMBERS=1
- MYSQL_CREATE_ROUTER_USER=0
- MYSQL_ROUTER_BOOTSTRAP_EXTRA_OPTIONS=""
volumes:
- ./mysqlrouter-config.conf:/etc/mysqlrouter-config.conf
command:
- ./bin/mysqlrouter
- --config
- /etc/mysqlrouter-config.conf
ports:
- "127.0.0.1:6446:6446"
depends_on:
- mysql
[DEFAULT]
max_idle_server_connections=64
[logger]
level = INFO
[routing:secondary]
bind_address = localhost
bind_port = 7001
destinations = mysql:3306
routing_strategy = round-robin
mode = read-only
protocol=classic
connection_sharing=1
[routing:primary]
bind_address = localhost
bind_port = 6446
destinations = mysql:3306
routing_strategy = first-available
protocol=classic
connection_sharing=1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment