This repository has been archived by the owner on Jun 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added setup for mariadb with replication
- Loading branch information
Showing
9 changed files
with
118 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
|
||
mysql -h"$HOSTNAME" -u"$MYSQL_USER" -p"$MYSQL_PASSWORD" --silent -e"use $MYSQL_DATABASE" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
[mysqld] | ||
|
||
# Default authentication plugin | ||
default-authentication-plugin=caching_sha2_password | ||
|
||
# Default character charset | ||
character-set-server=utf8mb4 | ||
|
||
# Default collation server | ||
collation-server=utf8mb4_unicode_ci | ||
|
||
# Max connections | ||
max_connections=500 | ||
|
||
# Unique identifying number of the server. | ||
server-id = 2 | ||
|
||
# Set binary log file base name. This should be identical to the binary log file base name in source. | ||
log_bin=mysql-bin.log | ||
|
||
# Set the relay log file base name used by replica. This is needed to avoid error incase hostname is changed in future. | ||
relay_log=mysql-relay-bin.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
.PHONY: clean up down | ||
all: up | ||
|
||
compose := docker-compose -f docker-compose.yml | ||
|
||
up: | ||
$(compose) up --detach | ||
|
||
down: | ||
$(compose) down --volumes --remove-orphans | ||
|
||
logs: | ||
$(compose) logs | ||
|
||
clean: down | ||
|
||
cli-primary: | ||
$(compose) exec mysql-primary mysql -u root -ppassword lisk | ||
|
||
cli-replica: | ||
$(compose) exec mysql-read-replica mysql -u root -ppassword lisk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
version: '3.3' | ||
services: | ||
mysql-primary: | ||
image: mariadb:10.7 | ||
container_name: mysql-primary | ||
command: mysqld | ||
volumes: | ||
- ../../docker/mariadb/primary/conf/mysql.cnf:/etc/mysql/conf.d/mysql.cnf | ||
- mysql-primary-data:/var/lib/mysql | ||
- ../../docker/mariadb/primary/init:/docker-entrypoint-initdb.d | ||
restart: always | ||
networks: | ||
- services_network | ||
environment: | ||
- MYSQL_ROOT_PASSWORD=password | ||
- MYSQL_USER=lisk | ||
- MYSQL_PASSWORD=password | ||
ports: | ||
- '127.0.0.1:3306:3306' | ||
healthcheck: | ||
test: ['CMD', 'mysqladmin', 'ping', '-hlocalhost', '-ppassword'] | ||
|
||
mysql-read-replica: | ||
image: mariadb:10.7 | ||
depends_on: | ||
mysql-primary: | ||
condition: service_healthy | ||
command: mysqld | ||
volumes: | ||
- ../../docker/mariadb/read/conf/mysql.cnf:/etc/mysql/conf.d/mysql.cnf | ||
- ../../docker/mariadb/read/init:/docker-entrypoint-initdb.d | ||
restart: always | ||
expose: | ||
- '3306' | ||
networks: | ||
- services_network | ||
deploy: | ||
mode: replicated | ||
replicas: 1 | ||
endpoint_mode: vip | ||
environment: | ||
- MYSQL_ROOT_PASSWORD=password | ||
healthcheck: | ||
test: ['CMD', 'mysqladmin', 'ping', '-hlocalhost', '-ppassword'] | ||
|
||
mysql-read-replica-haproxy: | ||
image: nginx:latest | ||
depends_on: | ||
mysql-read-replica: | ||
condition: service_healthy | ||
volumes: | ||
- ../../docker/nginx.conf:/etc/nginx/nginx.conf:ro | ||
ports: | ||
- '127.0.0.1:3307:3307' | ||
networks: | ||
- services_network | ||
healthcheck: | ||
test: ['CMD', 'service', 'nginx', 'status'] | ||
|
||
networks: | ||
services_network: | ||
|
||
volumes: | ||
mysql-primary-data: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
|
||
mysql -h"$HOSTNAME" -u"$MARIADB_USER" -p"$MARIADB_PASSWORD" --silent -e"use $MARIADB_DATABASE" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters