Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- version: '2'
- volumes:
- dbdata:
- external: false
- services:
- # the MariaDB database MASTER container
- #
- database:
- image: mariadb:10.3.4
- env_file:
- - ./env/.env.database
- volumes:
- - dbdata:/data/db
- - /etc/localtime:/etc/localtime:ro
- # mount the configuration files in the approriate place
- #
- - ./database/master/etc/mysql/conf.d:/etc/mysql/conf.d:ro
- # mount the SQL files for initialization in a place where the
- # database container will look for it on initialization; see
- # "Initializing a fresh instance" at
- # https://hub.docker.com/_/mariadb/ for details
- #
- - ./database/master/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d:ro
- ports:
- - "3306:3306"
- # the MariaDB database SLAVE container
- #
- slave:
- image: mariadb:10.3.4
- # env_file:
- # - ./env/.env.database
- environment:
- - MYSQL_ALLOW_EMPTY_PASSWORD=yes
- volumes:
- - /etc/localtime:/etc/localtime:ro
- # mount the configuration files in the approriate place
- #
- - ./database/slave/etc/mysql/conf.d:/etc/mysql/conf.d:ro
- # mount the SQL files for initialization in a place where the
- # database container will look for it on initialization; see
- # "Initializing a fresh instance" at
- # https://hub.docker.com/_/mariadb/ for details
- #
- - ./database/slave/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d:ro
- depends_on:
- - database
- # the root user password
- #
- MYSQL_ROOT_PASSWORD=password
- # the database to use
- #
- MYSQL_DATABASE=mydatabase
- GRANT REPLICATION SLAVE ON *.* TO 'replicant'@'%' IDENTIFIED BY 'password';
- [mariadb]
- log-bin
- server_id=1
- log-basename=master1
- # force binlog format to ROW to avoid issues with
- # replicate_do_db
- binlog_format=ROW
- -- configure the connection to the master
- --
- CHANGE MASTER TO
- MASTER_HOST='database',
- MASTER_USER='replicant',
- MASTER_PASSWORD='password',
- MASTER_PORT=3306,
- MASTER_USE_GTID=slave_pos,
- MASTER_CONNECT_RETRY=10;
- -- start the slave
- --
- START SLAVE;
- [mariadb]
- server_id=1000
- relay-log = /var/log/mysql/mysql-relay-bin.log
- log_bin = /var/log/mysql/mysql-bin.log
- Could not execute Write_rows_v1 event on table mysql.user; Duplicate entry 'localhost-root' for key 'PRIMARY', Error_code: 1062; handler error HA_ERR_FOUND_DUPP_KEY;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement