Skip to content

wodby/mariadb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MariaDB Docker Container Image

Build Status Docker Pulls Docker Stars

Docker Images

âť—For better reliability we release images with stability tags (wodby/mariadb:11-X.X.X) which correspond to git tags. We strongly recommend using images only with stability tags.

Overview:

Supported tags and respective Dockerfile links:

Credits to Alpine Linux team for patches for better musl compatibility of MariaDB. Patches taken from Alpine's packages repository.

All images built for linux/amd64 and linux/arm64.

Environment Variables

Variable 11.4 10.11, 10.6, 10.5
MARIADB_PLUGIN_LOAD
MARIADB_SSL_CERT
MARIADB_SSL_KEY
MARIADB_SSL_CA
MARIADB_TLS_VERSION TLSv1.2,TLSv1.3 TLSv1.2,TLSv1.3
MYSQL_BACK_LOG 100 100
MYSQL_CHARACTER_SET_FILESYSTEM binary binary
MYSQL_CHARACTER_SET_SERVER utf8mb4 utf8mb4
MYSQL_CLIENT_DEFAULT_CHARACTER_SET utf8mb4 utf8mb4
MYSQL_COLLATION_SERVER utf8mb4_unicode_ci utf8mb4_unicode_ci
MYSQL_CONNECT_TIMEOUT 10 10
MYSQL_DATABASE
MYSQL_DEFAULT_STORAGE_ENGINE InnoDB InnoDB
MYSQL_DUMP_MAX_ALLOWED_PACKET 1G 1G
MYSQL_GENERAL_LOG 1 1
MYSQL_INIT_CONNECT SET NAMES utf8 SET NAMES utf8
MYSQL_INNODB_BUFFER_POOL_INSTANCES - -
MYSQL_INNODB_BUFFER_POOL_SIZE 128M 128M
MYSQL_INNODB_DEFAULT_ROW_FORMAT dynamic dynamic
MYSQL_INNODB_FAST_SHUTDOWN 1 1
MYSQL_INNODB_FILE_FORMAT - -
MYSQL_INNODB_FILE_PER_TABLE - 1
MYSQL_INNODB_FLUSH_LOG_AT_TRX_COMMIT 2 2
MYSQL_INNODB_FLUSH_METHOD - O_DIRECT
MYSQL_INNODB_FORCE_LOAD_CORRUPTED 0 0
MYSQL_INNODB_FORCE_RECOVERY 0 0
MYSQL_INNODB_IO_CAPACITY 200 200
MYSQL_INNODB_LARGE_PREFIX - -
MYSQL_INNODB_LOCK_WAIT_TIMEOUT 50 50
MYSQL_INNODB_LOG_BUFFER_SIZE 8M 8M
MYSQL_INNODB_LOG_FILE_SIZE 128M 128M
MYSQL_INNODB_LOG_FILES_IN_GROUP - -
MYSQL_INNODB_OLD_BLOCKS_TIME 1000 1000
MYSQL_INNODB_OPEN_FILES
MYSQL_INNODB_PURGE_THREADS 4 4
MYSQL_INNODB_READ_IO_THREADS 4 4
MYSQL_INNODB_STATS_ON_METADATA OFF OFF
MYSQL_INNODB_STRICT_MODE OFF OFF
MYSQL_INNODB_WRITE_IO_THREADS 4 4
MYSQL_INTERACTIVE_TIMEOUT 420 420
MYSQL_JOIN_BUFFER_SIZE
MYSQL_JOIN_BUFFER_SPACE_LIMIT
MYSQL_LOG_WARNINGS 2 2
MYSQL_LONG_QUERY_TIME 2 2
MYSQL_LOWER_CASE_TABLE_NAMES
MYSQL_MAX_ALLOWED_PACKET 256M 256M
MYSQL_MAX_CONNECT_ERRORS 100000 100000
MYSQL_MAX_CONNECTIONS 50 50
MYSQL_MAX_HEAP_TABLE_SIZE 16M 16M
MYSQL_NET_READ_TIMEOUT 90 90
MYSQL_NET_WRITE_TIMEOUT 90 90
MYSQL_OPEN_FILES_LIMIT 0 0
MYSQL_OPTIMIZER_PRUNE_LEVEL 1 1
MYSQL_OPTIMIZER_SEARCH_DEPTH 62 62
MYSQL_OPTIMIZER_SWITCH
MYSQL_PASSWORD
MYSQL_PERFORMANCE_SCHEMA OFF OFF
MYSQL_PORT 3306 3306
MYSQL_QUERY_CACHE_LIMIT 1M 1M
MYSQL_QUERY_CACHE_MIN_RES_UNIT 2K 2K
MYSQL_QUERY_CACHE_SIZE 1M 1M
MYSQL_QUERY_CACHE_TYPE OFF OFF
MYSQL_RELAY_LOG_RECOVERY 0 0
MYSQL_ROOT_PASSWORD
MYSQL_SLOW_QUERY_LOG 0 0
MYSQL_SORT_BUFFER_SIZE 2M 2M
MYSQL_TABLE_DEFINITION_CACHE 400 400
MYSQL_TABLE_OPEN_CACHE 4096 4096
MYSQL_THREAD_CACHE_SIZE 75 75
MYSQL_TMP_TABLE_SIZE 16M 16M
MYSQL_USER
MYSQL_WAIT_TIMEOUT 420 420
MYSQL_TRANSACTION_ISOLATION REPEATABLE-READ REPEATABLE-READ
MYSQL_TRANSACTION_READ_ONLY OFF -

"-" - Not available for this version

Additional environment variables

MYSQL_INNODB_DATA_FILE_PATH:

Default value for all versions:

ibdata1:10M:autoextend:max:10G"

Additional Galera environment variables

Variable Value
WSREP_ON OFF
MYSQL_INNODB_FLUSH_LOG_AT_TRX_COMMIT 0
WSREP_AUTO_INCREMENT_CONTROL ON
WSREP_CERTIFICATION_RULES strict
WSREP_CERTIFY_NONPK ON
WSREP_CLUSTER_ADDRESS
WSREP_CLUSTER_NAME my_wsrep_cluster
WSREP_CONVERT_LOCK_TO_TRX OFF
WSREP_DATA_HOME_DIR
WSREP_DBUG_OPTION
WSREP_DEBUG NONE
WSREP_DESYNC OFF
WSREP_DIRTY_READS OFF
WSREP_DRUPAL_282555_WORKAROUND OFF
WSREP_FORCED_BINLOG_FORMAT NONE
WSREP_GTID_DOMAIN_ID 0
WSREP_GTID_MODE OFF
WSREP_IGNORE_APPLY_ERRORS 0
WSREP_LOAD_DATA_SPLITTING OFF
WSREP_LOG_CONFLICTS OFF
WSREP_MAX_WS_ROWS 0
WSREP_MAX_WS_SIZE 2G
WSREP_MYSQL_REPLICATION_BUNDLE 0
WSREP_NODE_ADDRESS 0.0.0.0
WSREP_NODE_INCOMING_ADDRESS AUTO
WSREP_NODE_NAME
WSREP_NOTIFY_CMD
WSREP_OSU_METHOD TOI
WSREP_PROVIDER_OPTIONS
WSREP_RECOVER OFF
WSREP_REJECT_QUERIES NONE
WSREP_REPLICATE_MYISAM OFF
WSREP_RESTART_SLAVE OFF
WSREP_RETRY_AUTOCOMMIT 1
WSREP_SLAVE_FK_CHECKS ON
WSREP_SLAVE_THREADS 1
WSREP_SLAVE_UK_CHECKS OFF
WSREP_SR_STORE table
WSREP_SST_AUTH
WSREP_SST_DONOR
WSREP_SST_DONOR_REJECTS_QUERIES OFF
WSREP_SST_METHOD rsync
WSREP_RECEIVE_ADDRESS AUTO
WSREP_START_POSITION
WSREP_SYNC_WAIT 0
WSREP_TRX_FRAGMENT_SIZE 0
WSREP_TRX_FRAGMENT_UNIT bytes
Galera Config Directive Override
-------------------------- --------
binlog_format ROW
default_storage_engine InnoDB
innodb_autoinc_lock_mode 2

Galera Cluster

Galera Cluster Documentation

In-depth documentation about Galera would be too lengthy for this README file. Instead, refer to these authoritative documentation sources:

When these sources disagree (for example, wsrep options/system vars are slightly different), favor MariaDB's documentation over Codership's.

Galera-specific MariaDB configuration

You must set the WSREP_ON environment variable if you want the container's /etc/mysql/my.cnf to include Galera/wsrep specific configuration settings.

Bootstrapping a Galera Cluster

When starting a new cluster, the first node must bootstrap the cluster:

$ docker run -e WSREP_ON=ON -v data1:/var/lib/mysql --name galera-1 \
    wodby/mariadb:galera --wsrep-new-cluster

When the first node is ready, the other nodes can join it (via its hostname or IP) and participate in the cluster:

$ docker run -e WSREP_ON=ON -v data2:/var/lib/mysql --name galera-2 \
    wodby/mariadb:galera --wsrep-cluster-address="gcomm://<node-1>"
$ docker run -e WSREP_ON=ON -v data3:/var/lib/mysql --name galera-3 \
    wodby/mariadb:galera --wsrep-cluster-address="gcomm://<node-1>,<node-2>"

After the other nodes have joined the first, you should terminate the first container and docker run a new container without the --wsrep-new-cluster and join the other nodes. This is to prevent cluster re-bootstrap if the bootstrap container (or the host it's on) ever decided to restart.

You may also want to restart the second node with a --wsrep-cluster-address=gcomm://<node-1>,<node-3>, or if you know all three node hostnames or IPs ahead of time, you can use gcomm://<node-1>,<node-2>,<node-3> for all node containers.

Using Galera Arbitrator Daemon for Small/Even Clusters

For Galera clustering to work properly, it requires a quorum of nodes to agree on pending commits.

Although a one-node cluster is possible (it will always agree with itself), the minimum number of "voters" to achieve quorum is 3. A two-node cluster is possible, but you must add a Galera Arbitrator Daemon (aka garbd) as add a third voter. In general, it's a good idea to use garbd for clusters with even numbers of nodes, to provide a tie-breaking vote in case half of the nodes agree and the other half disagree.

The galera-tagged images also include garbd, which can be run instead of mariadb.

$ docker run wodby/mariadb:galera garbd --help
Usage: garbd [options] [group address]
[...]

Refer to the documentation for configuration details.

Orchestration Actions

Usage:

make COMMAND [params ...]

commands:
    import source=</path/to/dump.zip or http://example.com/url/to/dump.sql.gz> [db root_password host ignore="table1;table2;cache_%"]
    backup filepath=</path/to/backup.sql.gz> [root_password host db]
    query query [db user password host]
    query-silent query [db user password host]
    query-root query [db root_password host]
    check-ready [root_password host max_try wait_seconds]
    mysql-upgrade [root_password host]
    mysql-check [root_password host db]
    create-db name [charset collation]
    drop-db name
    create-user username password
    drop-user username
    grant-user-db username db
    revoke-user-db username db

default params values:
    user $MYSQL_USER
    password $MYSQL_PASSWORD
    db $MYSQL_DATABASE
    root_password $MYSQL_ROOT_PASSWORD
    host localhost
    max_try 1
    wait_seconds 1
    ignore ""

Deployment

Deploy MariaDB to your own server via Wodby Wodby.