diff --git a/runner/master/mysql.d/master/conf.d/master.cnf b/runner/master/mysql.d/master/conf.d/master.cnf index b5d2911..5309d41 100644 --- a/runner/master/mysql.d/master/conf.d/master.cnf +++ b/runner/master/mysql.d/master/conf.d/master.cnf @@ -16,7 +16,7 @@ read_buffer_size = 1M innodb_flush_log_at_trx_commit = 1 server-id = 1 -log_bin = /var/log/mysql/mysql-bin.log +log_bin = /var/lib/mysql/mysql-bin.log sync_binlog = 1 binlog-format = ROW diff --git a/runner/master/mysql.d/master/docker-entrypoint-initdb.d/01_privileges.sql b/runner/master/mysql.d/master/docker-entrypoint-initdb.d/01_privileges.sql index 5eb948d..f67241e 100644 --- a/runner/master/mysql.d/master/docker-entrypoint-initdb.d/01_privileges.sql +++ b/runner/master/mysql.d/master/docker-entrypoint-initdb.d/01_privileges.sql @@ -1,8 +1,6 @@ -GRANT SHUTDOWN ON *.* TO 'multi_admin'@'localhost' IDENTIFIED BY 'multipass'; -CREATE USER 'replication'@'%' IDENTIFIED BY 'replication'; +CREATE USER 'replication'@'%' IDENTIFIED WITH mysql_native_password BY 'replication'; GRANT REPLICATION SLAVE ON *.* TO 'replication'@'%'; -GRANT ALL ON *.* TO 'root'@'%' IDENTIFIED BY 'moodle'; -GRANT ALL ON *.* TO 'moodle'@'%' IDENTIFIED BY 'moodle'; +ALTER USER 'root'@'%' IDENTIFIED BY 'moodle'; FLUSH PRIVILEGES; diff --git a/runner/master/mysql.d/slave/config/moodle.cnf b/runner/master/mysql.d/slave/conf.d/moodle.cnf similarity index 100% rename from runner/master/mysql.d/slave/config/moodle.cnf rename to runner/master/mysql.d/slave/conf.d/moodle.cnf diff --git a/runner/master/mysql.d/slave/conf.d/slave.cnf b/runner/master/mysql.d/slave/conf.d/slave.cnf new file mode 100644 index 0000000..ba0382c --- /dev/null +++ b/runner/master/mysql.d/slave/conf.d/slave.cnf @@ -0,0 +1,7 @@ +[mysqld] +server-id = 2 +relay-log = /var/lib/mysql/mysql-relay-bin.log +log_bin = /var/lib/mysql/mysql-bin.log + +# List of databases to replicate. +binlog_do_db = moodle diff --git a/runner/master/mysql.d/slave/config/slave.cnf b/runner/master/mysql.d/slave/config/slave.cnf deleted file mode 100644 index d875442..0000000 --- a/runner/master/mysql.d/slave/config/slave.cnf +++ /dev/null @@ -1,7 +0,0 @@ -[mysqld] -server-id = 2 -relay-log = /var/log/mysql/mysql-relay-bin.log -log_bin = /var/log/mysql/mysql-bin.log - -# List of databases to replicate. -binlog_do_db = moodle diff --git a/runner/master/mysql.d/slave/docker-entrypoint-initdb.d/10_replicate.sh b/runner/master/mysql.d/slave/docker-entrypoint-initdb.d/10_replicate.sh index d8fb9e6..d1b99dc 100755 --- a/runner/master/mysql.d/slave/docker-entrypoint-initdb.d/10_replicate.sh +++ b/runner/master/mysql.d/slave/docker-entrypoint-initdb.d/10_replicate.sh @@ -7,18 +7,6 @@ echo "========================================================================== sleep 5 -# We need to set this for some inane reason otherwise it fails to start mysql. -# This seems to be a bug with the entrypoint.sh -DATABASE_ALREADY_EXISTS='true' - -docker_temp_server_stop - -echo "Copying moodle.cnf" -gosu root cp /config/moodle.cnf /etc/mysql/conf.d/ - -echo "Restarting mysqld" -docker_temp_server_start mysqld - echo "Dumping ${DBHOST}" mysql -u root -pmoodle -h ${DBHOST} -e "FLUSH TABLES WITH READ LOCK;" moodle mysql -u root -pmoodle -h ${DBHOST} -e "SHOW MASTER STATUS;" moodle @@ -38,14 +26,6 @@ echo "Current position is {$replfile} {$position}" echo "Restoring into client" mysql -u root -pmoodle moodle < /tmp/moodle.sql -echo "Stopping server to apply slave configuration" -docker_temp_server_stop -gosu root cp /config/slave.cnf /etc/mysql/conf.d/ - -echo "Restarting mysqld" -docker_temp_server_start mysqld - -echo "Starting slave" mysql -u root -pmoodle moodle << EOSQL CHANGE MASTER TO MASTER_HOST='${DBHOST}', diff --git a/runner/master/run.sh b/runner/master/run.sh index 17d5f82..4ceedd6 100755 --- a/runner/master/run.sh +++ b/runner/master/run.sh @@ -335,14 +335,10 @@ then -e MYSQL_PASSWORD="${DBPASS}" \ -e DBHOST=$DBHOST \ -e DBHOST_SLAVE=$DBHOST_SLAVE \ - -v $SCRIPTPATH/mysql.d/slave/config:/config \ + -v $SCRIPTPATH/mysql.d/slave/conf.d:/etc/mysql/conf.d \ -v $SCRIPTPATH/mysql.d/slave/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d \ --tmpfs /var/lib/mysql:rw \ mysql:${DBTAG} - - # Hack to make gosu work for all users on the slave. - docker exec -u root $DBHOST_SLAVE bash -c 'chown root:mysql /usr/local/bin/gosu' - docker exec -u root $DBHOST_SLAVE bash -c 'chmod +s /usr/local/bin/gosu' else echo "Starting standalone" docker run \ @@ -395,7 +391,7 @@ then -e MYSQL_PASSWORD="${DBPASS}" \ -e DBHOST=$DBHOST \ -e DBHOST_SLAVE=$DBHOST_SLAVE \ - -v $SCRIPTPATH/mysql.d/slave/config:/config \ + -v $SCRIPTPATH/mysql.d/slave/conf.d:/etc/mysql/conf.d \ -v $SCRIPTPATH/mysql.d/slave/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d \ --tmpfs /var/lib/mysql:rw \ mariadb:${DBTAG}