MariaDB / mariadb-docker

Docker Official Image packaging for MariaDB
https://mariadb.org
GNU General Public License v2.0
755 stars 436 forks source link

Adds more options as environment variables to simplify the replication cluster setup #503

Closed MdSahil-oss closed 1 year ago

MdSahil-oss commented 1 year ago

Adds more options as environment variables to simplify the replication cluster setup. Fixes: https://jira.mariadb.org/browse/MDEV-29762

MdSahil-oss commented 1 year ago

@grooverdan Please review it again, if everything is fine then I'll start adding test.

MdSahil-oss commented 1 year ago

@grooverdan I've updated the test, please review it.

MdSahil-oss commented 1 year ago

@grooverdan I think, Now this PR is ready for final review :)

grooverdan commented 1 year ago

@grooverdan I think, Now this PR is ready for final review :)

I added a couple of fixes to the entrypoint and test. It still wasn't in a state where it was even starting let alone passing.

So to run tests of the 10.5:

./update 10.5
docker build --tag ms105 10.5
bash -x v ./test/run.sh ms105 replication

Once you get this passing, 10.4 will need further adjustments in build/test.

More tests are required to check the validation bounds condition and the $MARIADB_REPLICATION_PASSWORD_HASH usage.

It occurs to me that in a replica mode the need to set a default root user password shouldn't apply as after starting replication it will. So maybe those conditions can be relaxes too. (if you get time)

MdSahil-oss commented 1 year ago

@grooverdan I'm getting error on execution of below line in the entrypoint:

changeMasterTo="CHANGE MASTER TO MASTER_HOST='$MARIADB_MASTER_HOST', MASTER_USER='$MARIADB_REPLICATION_USER', MASTER_PASSWORD='$MARIADB_REPLICATION_PASSWORD', MASTER_PORT=$MARIADB_MASTER_PORT, MASTER_CONNECT_RETRY=10;"

error:

2023-04-25 19:14:15 4 [Note] Slave I/O thread: Start asynchronous replication to master 'foo@172.17.0.2:3306' in log 'my-mariadb-bin.000002' at position 347
2023-04-25 19:14:15 0 [Note] mariadbd: ready for connections.
Version: '10.6.12-MariaDB-1:10.6.12+maria~ubu2004'  socket: '/run/mysqld/mysqld.sock'  port: 3307  mariadb.org binary distribution
2023-04-25 19:14:15 5 [Note] Slave SQL thread initialized, starting replication in log 'FIRST' at position 0, relay log './mysqld-relay-bin.000001' position: 4
2023-04-25 19:14:15 4 [Note] Slave I/O thread: connected to master 'foo@172.17.0.2:3306',replication started in log 'my-mariadb-bin.000002' at position 347
2023-04-25 19:14:15 5 [ERROR] Slave SQL: Error 'Operation CREATE USER failed for 'foo'@'%'' on query. Default database: 'mysql'. Query: 'CREATE USER 'foo'@'%' IDENTIFIED BY 'foo123'', Gtid 0-3000-2, Internal MariaDB error code: 1396
2023-04-25 19:14:15 5 [Warning] Slave: Operation CREATE USER failed for 'foo'@'%' Error_code: 1396
2023-04-25 19:14:15 5 [ERROR] Error running query, slave SQL thread aborted. Fix the problem, and restart the slave SQL thread with "SLAVE START". We stopped at log 'my-mariadb-bin.000001' position 488
2023-04-25 19:14:15 5 [Note] Slave SQL thread exiting, replication stopped in log 'my-mariadb-bin.000001' at position 488, master: 172.17.0.2:3306
grooverdan commented 1 year ago

The error was the replica created the same user, and then the replication stream attempted to create the same user again. Pushed an update.

MdSahil-oss commented 1 year ago

@grooverdan This PR need review :), If tests are correct then I'll move further to adjustment of 10.3 & 10.4

MdSahil-oss commented 1 year ago

@grooverdan Line in 10.4 & 10.3 giving an SQL syntax error:

Version: '10.3.38-MariaDB-1:10.3.38+maria~ubu2004-log'  socket: '/var/run/mysqld/mysqld.sock'  port: 0  mariadb.org binary distribution
2023-04-29 09:07:14+00:00 [Note] [Entrypoint]: Temporary server started.
2023-04-29 09:07:14+00:00 [Warn] [Entrypoint]: Excessive privileges ON *.* TO mysql@localhost facilitates risks to the confidentiality, integrity and availability of data stored
2023-04-29 09:07:14+00:00 [Note] [Entrypoint]: Creating database replcheck
2023-04-29 09:07:14+00:00 [Note] [Entrypoint]: Creating user foo
2023-04-29 09:07:14+00:00 [Note] [Entrypoint]: Securing system users (equivalent to running mysql_secure_installation)
ERROR 1064 (42000) at line 18: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'MONITOR ON *.* TO mysql@localhost' at line 1
MdSahil-oss commented 1 year ago

@grooverdan updated all the tests with MARIADB_REPLICATION_USER & MARIADB_REPLICATION_PASSWORD, works fine please review it.