Skip to content

Commit

Permalink
wip: Add mariadb primary/secondary cluster
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Härtl <[email protected]>
  • Loading branch information
juliusknorr committed Nov 2, 2023
1 parent b067fd3 commit d057009
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 0 deletions.
43 changes: 43 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,48 @@ services:
talk-janus:
image: ghcr.io/juliushaertl/nextcloud-dev-talk-janus:latest

mariadb-primary:
image: docker.io/bitnami/mariadb:10.6
ports:
- '3306'
volumes:
- 'mariadb_primary_data:/bitnami/mariadb'
environment:
- MARIADB_REPLICATION_MODE=master
- MARIADB_REPLICATION_USER=repl_user
- MARIADB_REPLICATION_PASSWORD=repl_password
- MARIADB_ROOT_PASSWORD=master_root_password
- MARIADB_USER=my_user
- MARIADB_PASSWORD=my_password
- MARIADB_DATABASE=my_database

mariadb-replica:
image: docker.io/bitnami/mariadb:10.6
ports:
- '3306'
depends_on:
- mariadb-primary
environment:
- MARIADB_REPLICATION_MODE=slave
- MARIADB_REPLICATION_USER=repl_user
- MARIADB_REPLICATION_PASSWORD=repl_password
- MARIADB_MASTER_HOST=mariadb-primary
- MARIADB_MASTER_PORT_NUMBER=3306
- MARIADB_MASTER_ROOT_PASSWORD=master_root_password
- MARIADB_MASTER_DELAY=180

maxscale:
image: mariadb/maxscale:latest
depends_on:
- mariadb-primary
- mariadb-replica
volumes:
- './docker/maxscale/my-maxscale.cnf:/etc/maxscale.cnf.d/my-maxscale.cnf'
ports:
- '3306'



volumes:
data:
config:
Expand All @@ -865,6 +907,7 @@ volumes:
smbhomes:
elasticsearch_data:
clam:
mariadb_primary_data:

networks:
default:
Expand Down
31 changes: 31 additions & 0 deletions docker/maxscale/my-maxscale.cnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[primary]
type=server
address=mariadb-master
port=3306
protocol=MariaDBBackend

[replica1]
type=server
address=mariadb-slave
port=3306
protocol=MariaDBBackend

[MariaDB-Monitor]
type=monitor
module=mariadbmon
servers=primary,replica1
user=root
password=master_root_password

[RW-Split-Router]
type=service
router=readwritesplit
servers=primary,replica1
user=root
password=master_root_password

[RW-Split-Listener]
type=listener
service=RW-Split-Router
protocol=MariaDBClient
port=3306

0 comments on commit d057009

Please sign in to comment.