Using Healthcheck.sh script
The healthcheck.sh script is part of the Docker Official Images of MariaDB Server. The script is part of the respository of the Docker Official Image of MariaDB Server.
The script processes a number of argument and tests, together, in strict order. Arguments pertaining to a test must occur before the test name. If a test fails, no further processing is performed. Both arguments and tests begin with a double-hyphen.
Tests
--connect
This is active when a external user can connect to the TCP port of MariaDB Server. This strictly tests just the TCP connection and not if any authentication works.
--innodb_initialized
This test is true when InnoDB has completed initializing. This includes any rollback or crash recovery that may be occurring in the background as MariaDB is starting.
The connecting user must have USAGE privileges to perform this test.
--innodb_buffer_pool_loaded
This indicates that the buffer pool dump previously saved has been completed loaded into the InnoDB Buffer Pool and as such the server has a hot cache ready for use. This checks the innodb_buffer_pool_load_status for a "complete" indicator.
This test doesn't check if innodb-system-variables/#innodb_buffer_pool_load_at_startupinnodb_buffer_pool_load_at_startup is set at startup.
The connecting user must have USAGE privileges to perform this test.
--galera_online
This indicates that the galera node is online by the wsrep_local_state variable. This includes states like "joining" and "donor" where it cannot serve SQL queries.
The connecting user must have USAGE privileges to perform this test.
--replication
This tests a replica based on the --replication_*
parameters. The replica test must pass all of the subtests to be true. The subtests are:
- io - the IO thread is running
- sql - the sql thread is running
- seconds_behind_master - the replica is less than X seconds behind the master.
- sql_remaining_delay - the delayed replica is less than X seconds behind the master's execution of the same SQL.
These are tested for all connections, if --replication_all
is set (default), or --replication_name
.
The connecting user must have REPLICATION_CLIENT if using a version less than MariaDB 10.5, or REPLICA MONITOR for MariaDB 10.5 or later.
--mariadbupgrade
This healthcheck indicates that the mariadb is upgrade to the current version.
Parameters
--replication_all
Checks all replication sources
--replication_name=n
Sets the multisource connection name tested. Unsets --replication_all
.
--replication_io
IO thread is running
--replication_sql
SQL thread is running
--replication_seconds_behind_master=n
Less than or equal this seconds of delay
--replication_sql_remaining_delay=n
Less than or equal this seconds of remaining delay
--su=n
Change to this user. Can only be done once as the root user is default for healthchecks.
--su-mysql
Change to the mysql
unix user. Like --su
this respawns the script so will reset all parameters. Should be the first argument. The MARIADB_MYSQL_LOCALHOST_USER=1
environment variable is designed around usage here.
--datadir=n
For the --mariadbupgrade
test where the upgrade file is located.
--no-defaults --defaults-file --defaults-extra-file --defaults-group-suffix
These are passed to mariadb shell for all tests except --mariadbupgrade
Examples
healtcheck.sh --su-mysql --connect --innodb_initialized
Switch to mysql
user, and check if can connect and the innodb is initialized.
healtcheck.sh --su-mysql --connect --replication_io --replication_sql --replication_seconds_behind_master=600 --replication_sql_remaining_delay=30 ----replication_name=archive --replication --replication_seconds_behind_master=10 --replication_name=channel1 --replication
Switch to mysql
user, check if connections can be made, for the replication channel "archive", ensure io and sql threads are running and the seconds behind master < 600 seconds and the sql remaining delay < 30 seconds. For the "channel1", the seconds behind master is limit to 10 seconds maximum.