Comments - Using Healthcheck.sh

1 month ago Mark Michaelis

I had issues using healthcheck.sh as suggested by Bren X., because I set up MariaDB with a custom port 3307 directly within the MariaDB configuration, such as:

[mariadb]
port = 3307

This custom port collides with the default healthcheck.sh in Docker, that uses a file /var/lib/mysql/.my-healthcheck.cnf generated similar to this:

[mariadb-client]
port=3306
socket=/run/mysqld/mysqld.sock
user=healthcheck
password=...
protocol=tcp

This file is passed as --defaults-extra-file to the MariaDB client.

Overriding this file is not an option, as it contains a generated password.

What works, but is undocumented here, is, that healthcheck.sh also accepts parameters --defaults-file and --defaults-extra-file. By experiment, as the MariaDB client documentation is not that clear to me, it works passing --defaults-file with reference to a file like this:

[mariadb-client]
port=3307

It will override the port from the extra-file.

Now, extending the test section as given by Bren X., this extended healthcheck.sh call would work for a file mounted to, for example, /etc/mysql/conf.d/custom-client.cnf:

test:
  [
    "CMD",
    "healthcheck.sh",
    "--su-mysql",
    "--defaults-file=/etc/mysql/conf.d/custom-client.cnf"
    "--connect",
    "--innodb_initialized"
  ]

There may be better options, like just sticking to the default port 3306 internally and use Docker to map it to 3307 to the outside. But at least, this approach works, and of course could also be used to pass other parameters to the MariaDB client.

 
4 weeks, 1 day ago Daniel Black

The .my-healthcheck.cnf is generated from the configuration at initialization. If you remove the .my-healthcheck.sh and have MARIADB_AUTO_UPGRADE=1 then the .my-healthcheck.cnf will be regenerated with the currently configured port.

The healtcheck user/password will be regenerated in the server also with this option.

 
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.