version: "3.9"
services:
teledb-dms-mysql:
image: mysql:8.2.0
hostname: teledb-dms-mysql
ports:
- "${MYSQL_PORT}:3306"
configs:
- source: mysql_conf
target: /etc/my.cnf
- source: mysql_init_druid_permission_grant
target: /docker-entrypoint-initdb.d/druid_permission_grant.sql
- source: mysql_init_dms_resource_intensive
target: /docker-entrypoint-initdb.d/dms-resource-intensive.sql
secrets:
- mysql_root_password
- mysql_db_password
volumes:
- teledb-dms-mysql-data${LABEL}:/var/lib/mysql
environment:
- "MYSQL_ROOT_PASSWORD_FILE=/run/secrets/mysql_root_password"
- "MYSQL_USER=dms"
- "MYSQL_PASSWORD_FILE=/run/secrets/mysql_db_password"
- "MYSQL_DATABASE=dms_console"
- "TZ=Asia/Shanghai"
command:
- "--default-authentication-plugin=mysql_native_password"
- "--character-set-server=utf8mb4"
- "--collation-server=utf8mb4_general_ci"
- "--explicit_defaults_for_timestamp=true"
- "--lower_case_table_names=1"
- "--gtid-mode=ON_PERMISSIVE"
- "--server-id=1"
- "--log-bin=mysql-bin"
- "--binlog-do-db=dms_console,dms_resource_intensive"
- "--binlog-ignore-db=information_schema,mysql,performance_schema,sys"
deploy:
restart_policy:
condition: on-failure
placement:
constraints:
- node.labels.mysql-role == master
teledb-dms-mysql-slave:
image: mysql:8.2.0
hostname: teledb-dms-mysql-slave
configs:
- source: mysql_conf
target: /etc/my.cnf
- source: mysql_init_druid_permission_grant
target: /docker-entrypoint-initdb.d/druid_permission_grant.sql
- source: mysql_init_dms_resource_intensive
target: /docker-entrypoint-initdb.d/dms-resource-intensive.sql
secrets:
- mysql_root_password
- mysql_db_password
volumes:
- teledb-dms-mysql-slave-data${LABEL}:/var/lib/mysql
environment:
- "MYSQL_ROOT_PASSWORD_FILE=/run/secrets/mysql_root_password"
- "MYSQL_USER=dms"
- "MYSQL_PASSWORD_FILE=/run/secrets/mysql_db_password"
- "MYSQL_DATABASE=dms_console"
- "TZ=Asia/Shanghai"
command:
- "--default-authentication-plugin=mysql_native_password"
- "--character-set-server=utf8mb4"
- "--collation-server=utf8mb4_general_ci"
- "--explicit_defaults_for_timestamp=true"
- "--lower_case_table_names=1"
- "--gtid-mode=ON_PERMISSIVE"
- "--server-id=2"
- "--log-bin=mysql-bin"
depends_on:
- teledb-dms-mysql
deploy:
restart_policy:
condition: on-failure
placement:
constraints:
- node.labels.mysql-role == slave
Above is the docker compose configuration where I deployed the mysql master and slave nodes. After the container starts, I set the slave node as the slave of the master node, and the connection status appears normal. However, after I create a database in the master node or create a new table in the dms_console database, these changes are not synchronized from the slave node. Why?
Please check what’s problem.
New contributor
阿财继续努力 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.