-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix broken SQL indents and run init.sh only once #2
base: master
Are you sure you want to change the base?
Conversation
Fix EOSQL indents as breaking the sql commands Add check for already set MYSQL_GRANT_SLAVE_USER and password from environment variable
Copy the init.sh on first install then create a status file to ignore on further restarts
Copying init.sh to /usr/local/bin allows us to use this only once on a fresh install
@@ -1,6 +1,6 @@ | |||
FROM mariadb:10.3 | |||
|
|||
COPY mariadb/init.sh /docker-entrypoint-initdb.d/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @db260179,
the mariadb image already runs the scripts inserted in /docker-entrypoint-initdb.d/
once, see: https://github.com/docker-library/mariadb/blob/44cfe68144976ce0ec135593ffe15c4bcca0dc6f/10.3/docker-entrypoint.sh#L80.
So you do not need to manually check in the entrypoint.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are correct, so no need for that change.
I've added a commit to allow the master to confirm to the slave its ready to start. Although you have a 30 second count down it isn't that reliable and relying on the depends_on is not a good method especially on docker swarm
README.md
Outdated
@@ -109,30 +98,3 @@ MYSQL_SLAVE_SKIP_ERRORS: "all" # (Optional) Default: 'OFF' | |||
- Add `innodb-read-only` parameter (Service restart on first run is needed); | |||
- Move `/etc/mysql/conf.d/master-slave.cnf` in other path (So the user can bind a volume to `/etc/mysql/conf.d/` for custom configuration); | |||
- Permit replication on existing database. | |||
|
|||
|
|||
## Contributing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @db260179,
please leave this section in README file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are yes, sorry didn't realise I took it out
mariadb/entrypoint.sh
Outdated
# On first install cp the init.sh | ||
if [ ! -e "/docker-entrypoint-initdb.d/.init" ]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @db260179,
the docker-entrypoint-initdb.d
directory isn't a volume, so docker will re-run this at every restart. The mariadb
image already runs the scripts inserted in /docker-entrypoint-initdb.d/
once. So you don't need to check this here.
README.md
Outdated
@@ -18,7 +15,7 @@ version: '3' | |||
|
|||
services: | |||
db-master: | |||
image: caffeina/mariadb-replication |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @db260179,
why force users to build the image when they can use the one already built?
Hi @db260179, thanks for your pull request. I gave you a little review, please answer me as soon as you can so I can merge your pull request. Thanks for contributing, Gabriele |
No need to for the .init file as the mariadb container only runs on first run from the /docker-entrypoint-initdb.d But we need to check if the init.sh exists as we are not assuming that a user might mount the /docker-entrypoint-initdb.d as a volume The status folder will be used to when master is done and the slave is ready to proceed.
By adding a status function in the init.sh it allows the master to finish its tasks first before the slave can start
Unintentional commit change revert back
Create a /status folder so that the master can create a status file once finished This allows the slave to only start once the master is ready.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hope this helps and taken in account your comments
David
README.md
Outdated
@@ -109,30 +98,3 @@ MYSQL_SLAVE_SKIP_ERRORS: "all" # (Optional) Default: 'OFF' | |||
- Add `innodb-read-only` parameter (Service restart on first run is needed); | |||
- Move `/etc/mysql/conf.d/master-slave.cnf` in other path (So the user can bind a volume to `/etc/mysql/conf.d/` for custom configuration); | |||
- Permit replication on existing database. | |||
|
|||
|
|||
## Contributing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are yes, sorry didn't realise I took it out
@@ -1,6 +1,6 @@ | |||
FROM mariadb:10.3 | |||
|
|||
COPY mariadb/init.sh /docker-entrypoint-initdb.d/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are correct, so no need for that change.
I've added a commit to allow the master to confirm to the slave its ready to start. Although you have a 30 second count down it isn't that reliable and relying on the depends_on is not a good method especially on docker swarm
Hi Gadiener,
Your current master is broken due to incorrect indents when running the sql commands.
This breaks the replication process on startup.
Also the init.sh should be just run once on fresh install and not all the time.