From 779ae3b8fd1991bf8d5411561d3874a09a93dc7d Mon Sep 17 00:00:00 2001 From: Ahmedul Haque Abid Date: Fri, 18 Oct 2024 23:53:20 +0600 Subject: [PATCH] Add mysql-slave --- mysql-slave/.example.env | 16 ++++++++++++++++ mysql-slave/.gitignore | 2 ++ mysql-slave/compose.mysql-slave.example.yaml | 20 ++++++++++++++++++++ mysql-slave/my_custom.example.cnf | 5 +++++ mysql-slave/readme.md | 7 +++++++ 5 files changed, 50 insertions(+) create mode 100644 mysql-slave/.example.env create mode 100644 mysql-slave/.gitignore create mode 100644 mysql-slave/compose.mysql-slave.example.yaml create mode 100644 mysql-slave/my_custom.example.cnf create mode 100644 mysql-slave/readme.md diff --git a/mysql-slave/.example.env b/mysql-slave/.example.env new file mode 100644 index 0000000..3111ba0 --- /dev/null +++ b/mysql-slave/.example.env @@ -0,0 +1,16 @@ +# https://github.com/bitnami/containers/blob/main/bitnami/mysql/README.md#environment-variables + +MYSQL_ROOT_PASSWORD=secret +MYSQL_REPLICATION_USER=slaveuser +MYSQL_REPLICATION_PASSWORD=slavepass +MYSQL_REPLICATION_MODE=slave +MYSQL_CHARACTER_SET=utf8mb4 +MYSQL_COLLATE=utf8mb4_0900_ai_ci +MYSQL_ENABLE_SLOW_QUERY=0 +MYSQL_LONG_QUERY_TIME=2 +# MYSQL_EXTRA_FLAGS= +# MYSQL_SQL_MODE= + +MYSQL_MASTER_HOST=common-mysql +MYSQL_MASTER_PORT_NUMBER=3306 +MYSQL_MASTER_ROOT_PASSWORD=secret diff --git a/mysql-slave/.gitignore b/mysql-slave/.gitignore new file mode 100644 index 0000000..20ca8e2 --- /dev/null +++ b/mysql-slave/.gitignore @@ -0,0 +1,2 @@ +/data +/my_custom.cnf diff --git a/mysql-slave/compose.mysql-slave.example.yaml b/mysql-slave/compose.mysql-slave.example.yaml new file mode 100644 index 0000000..ac95f81 --- /dev/null +++ b/mysql-slave/compose.mysql-slave.example.yaml @@ -0,0 +1,20 @@ +volumes: + common-mysql-slave: + name: 'common-mysql-slave' + +services: + mysql-slave: + image: 'bitnami/mysql:${MYSQL_IMAGE_TAG:-8.4.3}' + depends_on: + - mysql + env_file: + - .env + networks: + common-net: + aliases: + - common-mysql-slave + # ports: + # - 127.0.0.1:${MYSQL_SLAVE_PUBLISH_PORT:-3307}:3306 + volumes: + - common-mysql-slave:/var/lib/mysql + - ./my_custom.cnf:/opt/bitnami/mysql/conf/my_custom.cnf:ro diff --git a/mysql-slave/my_custom.example.cnf b/mysql-slave/my_custom.example.cnf new file mode 100644 index 0000000..5da3352 --- /dev/null +++ b/mysql-slave/my_custom.example.cnf @@ -0,0 +1,5 @@ +[mysql] +local-infile=1 + +[mysqld] +secure-file-priv="" diff --git a/mysql-slave/readme.md b/mysql-slave/readme.md new file mode 100644 index 0000000..a4aafb7 --- /dev/null +++ b/mysql-slave/readme.md @@ -0,0 +1,7 @@ +# MySQL (Slave) + +This service is used to replicate the slave instance of MySQL. + +Reference: +* [Official MySQL Documentation](https://dev.mysql.com/doc/relnotes/mysql/8.4/en/news-8-4-3.html) +* [Bitnami MySQL](https://github.com/bitnami/containers/blob/main/bitnami/mysql/README.md)