Skip to content

Commit

Permalink
Add semi-sync replication example
Browse files Browse the repository at this point in the history
  • Loading branch information
an3l committed Nov 27, 2023
1 parent 69641d4 commit 5abef0b
Showing 1 changed file with 67 additions and 0 deletions.
67 changes: 67 additions & 0 deletions examples/compose-replication-semisync.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
version: "3"
x-common-variables: &common-variables
MARIADB_ROOT_PASSWORD: ${MARIADB_ROOT_PASSWORD}
MYSQL_INITDB_SKIP_TZINFO: ${MYSQL_INITDB_SKIP_TZINFO}
MARIADB_REPLICATION_USER: ${MARIADB_REPLICATION_USER}
MARIADB_REPLICATION_PASSWORD: ${MARIADB_REPLICATION_PASSWORD}

x-common-attributes: &common-attributes
image: mariadb:lts
env_file:
- .env
environment: *common-variables
healthcheck:
test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"]
interval: 10s
timeout: 5s
retries: 3
logging:
driver: journald
networks:
- backend

x-common-replication: &common-replication
healthcheck:
test: ["CMD", "healthcheck.sh", "--connect", "--replication_io", "--replication_sql", "--replication_seconds_behind_master=1", "--replication"]
interval: 10s
timeout: 5s
retries: 3

services:
master:
<<: *common-attributes
container_name: ${PRIMARY_name}
command: --log-bin --log-basename=mariadb --rpl_semi_sync_master_enabled
environment:
- MARIADB_USER=testuser
- MARIADB_PASSWORD=password
- MARIADB_DATABASE=testdb

replica1:
<<:
- *common-attributes
- *common-replication
container_name: ${REPLICATION_name_1}
command: --server-id=2 --log-basename=mariadb --rpl_semi_sync_slave_enabled
environment:
- MARIADB_MASTER_HOST=${PRIMARY_name}
- MARIADB_HEALTHCHECK_GRANTS=REPLICA MONITOR
depends_on:
master:
condition: service_healthy

replica2:
<<:
- *common-attributes
- *common-replication
container_name: ${REPLICATION_name_2}
command: --server-id=3 --log-basename=mariadb --rpl_semi_sync_slave_enabled
environment:
- MARIADB_MASTER_HOST=${PRIMARY_name}
- MARIADB_HEALTHCHECK_GRANTS=REPLICA MONITOR
depends_on:
master:
condition: service_healthy

networks:
backend:

0 comments on commit 5abef0b

Please sign in to comment.