332 lines
7.7 KiB
Groff
332 lines
7.7 KiB
Groff
.\"t
|
|
.\" WARNING: Do not edit this file manually, it is generated from README.md automatically.
|
|
.\"
|
|
.\"t
|
|
.\" Automatically generated by Pandoc 1.16.0.2
|
|
.\"
|
|
.TH "MARIADB\-101\-RHEL7" "1" "February 22, 2017" "Container Image Pages" ""
|
|
.hy
|
|
.SH MariaDB Docker image
|
|
.PP
|
|
This container image includes MariaDB server 10.1 for OpenShift and
|
|
general usage.
|
|
Users can choose between RHEL and CentOS based images.
|
|
.PP
|
|
Dockerfile for CentOS is called Dockerfile, Dockerfile for RHEL is
|
|
called Dockerfile.rhel7.
|
|
.SS Environment variables and volumes
|
|
.PP
|
|
The image recognizes the following environment variables that you can
|
|
set during initialization by passing \f[C]\-e\ VAR=VALUE\f[] to the
|
|
Docker run command.
|
|
.PP
|
|
.TS
|
|
tab(@);
|
|
l l.
|
|
T{
|
|
Variable name
|
|
T}@T{
|
|
Description
|
|
T}
|
|
_
|
|
T{
|
|
\f[C]MYSQL_USER\f[]
|
|
T}@T{
|
|
User name for MySQL account to be created
|
|
T}
|
|
T{
|
|
\f[C]MYSQL_PASSWORD\f[]
|
|
T}@T{
|
|
Password for the user account
|
|
T}
|
|
T{
|
|
\f[C]MYSQL_DATABASE\f[]
|
|
T}@T{
|
|
Database name
|
|
T}
|
|
T{
|
|
\f[C]MYSQL_ROOT_PASSWORD\f[]
|
|
T}@T{
|
|
Password for the root user (optional)
|
|
T}
|
|
.TE
|
|
.PP
|
|
The following environment variables influence the MySQL configuration
|
|
file.
|
|
They are all optional.
|
|
.PP
|
|
.TS
|
|
tab(@);
|
|
lw(17.2n) lw(35.5n) lw(17.2n).
|
|
T{
|
|
Variable name
|
|
T}@T{
|
|
Description
|
|
T}@T{
|
|
Default
|
|
T}
|
|
_
|
|
T{
|
|
\f[C]MYSQL_LOWER_CASE_TABLE_NAMES\f[]
|
|
T}@T{
|
|
Sets how the table names are stored and compared
|
|
T}@T{
|
|
0
|
|
T}
|
|
T{
|
|
\f[C]MYSQL_MAX_CONNECTIONS\f[]
|
|
T}@T{
|
|
The maximum permitted number of simultaneous client connections
|
|
T}@T{
|
|
151
|
|
T}
|
|
T{
|
|
\f[C]MYSQL_MAX_ALLOWED_PACKET\f[]
|
|
T}@T{
|
|
The maximum size of one packet or any generated/intermediate string
|
|
T}@T{
|
|
200M
|
|
T}
|
|
T{
|
|
\f[C]MYSQL_FT_MIN_WORD_LEN\f[]
|
|
T}@T{
|
|
The minimum length of the word to be included in a FULLTEXT index
|
|
T}@T{
|
|
4
|
|
T}
|
|
T{
|
|
\f[C]MYSQL_FT_MAX_WORD_LEN\f[]
|
|
T}@T{
|
|
The maximum length of the word to be included in a FULLTEXT index
|
|
T}@T{
|
|
20
|
|
T}
|
|
T{
|
|
\f[C]MYSQL_AIO\f[]
|
|
T}@T{
|
|
Controls the \f[C]innodb_use_native_aio\f[] setting value in case the
|
|
native AIO is broken.
|
|
See http://help.directadmin.com/item.php?id=529
|
|
T}@T{
|
|
1
|
|
T}
|
|
T{
|
|
\f[C]MYSQL_TABLE_OPEN_CACHE\f[]
|
|
T}@T{
|
|
The number of open tables for all threads
|
|
T}@T{
|
|
400
|
|
T}
|
|
T{
|
|
\f[C]MYSQL_KEY_BUFFER_SIZE\f[]
|
|
T}@T{
|
|
The size of the buffer used for index blocks
|
|
T}@T{
|
|
32M (or 10% of available memory)
|
|
T}
|
|
T{
|
|
\f[C]MYSQL_SORT_BUFFER_SIZE\f[]
|
|
T}@T{
|
|
The size of the buffer used for sorting
|
|
T}@T{
|
|
256K
|
|
T}
|
|
T{
|
|
\f[C]MYSQL_READ_BUFFER_SIZE\f[]
|
|
T}@T{
|
|
The size of the buffer used for a sequential scan
|
|
T}@T{
|
|
8M (or 5% of available memory)
|
|
T}
|
|
T{
|
|
\f[C]MYSQL_INNODB_BUFFER_POOL_SIZE\f[]
|
|
T}@T{
|
|
The size of the buffer pool where InnoDB caches table and index data
|
|
T}@T{
|
|
32M (or 50% of available memory)
|
|
T}
|
|
T{
|
|
\f[C]MYSQL_INNODB_LOG_FILE_SIZE\f[]
|
|
T}@T{
|
|
The size of each log file in a log group
|
|
T}@T{
|
|
8M (or 15% of available available)
|
|
T}
|
|
T{
|
|
\f[C]MYSQL_INNODB_LOG_BUFFER_SIZE\f[]
|
|
T}@T{
|
|
The size of the buffer that InnoDB uses to write to the log files on
|
|
disk
|
|
T}@T{
|
|
8M (or 15% of available memory)
|
|
T}
|
|
T{
|
|
\f[C]MYSQL_DEFAULTS_FILE\f[]
|
|
T}@T{
|
|
Point to an alternative configuration file
|
|
T}@T{
|
|
/etc/my.cnf
|
|
T}
|
|
T{
|
|
\f[C]MYSQL_BINLOG_FORMAT\f[]
|
|
T}@T{
|
|
Set sets the binlog format, supported values are \f[C]row\f[] and
|
|
\f[C]statement\f[]
|
|
T}@T{
|
|
statement
|
|
T}
|
|
.TE
|
|
.PP
|
|
You can also set the following mount points by passing the
|
|
\f[C]\-v\ /host:/container\f[] flag to Docker.
|
|
.PP
|
|
.TS
|
|
tab(@);
|
|
l l.
|
|
T{
|
|
Volume mount point
|
|
T}@T{
|
|
Description
|
|
T}
|
|
_
|
|
T{
|
|
\f[C]/var/lib/mysql/data\f[]
|
|
T}@T{
|
|
MySQL data directory
|
|
T}
|
|
.TE
|
|
.PP
|
|
\f[B]Notice: When mouting a directory from the host into the container,
|
|
ensure that the mounted directory has the appropriate permissions and
|
|
that the owner and group of the directory matches the user UID or name
|
|
which is running inside the container.\f[]
|
|
.SS Usage
|
|
.PP
|
|
For this, we will assume that you are using the
|
|
\f[C]rhscl/mariadb\-100\-rhel7\f[] image.
|
|
If you want to set only the mandatory environment variables and not
|
|
store the database in a host directory, execute the following command:
|
|
.IP
|
|
.nf
|
|
\f[C]
|
|
$\ docker\ run\ \-d\ \-\-name\ mariadb_database\ \-e\ MYSQL_USER=user\ \-e\ MYSQL_PASSWORD=pass\ \-e\ MYSQL_DATABASE=db\ \-p\ 3306:3306\ rhscl/mariadb\-100\-rhel7
|
|
\f[]
|
|
.fi
|
|
.PP
|
|
This will create a container named \f[C]mariadb_database\f[] running
|
|
MySQL with database \f[C]db\f[] and user with credentials
|
|
\f[C]user:pass\f[].
|
|
Port 3306 will be exposed and mapped to the host.
|
|
If you want your database to be persistent across container executions,
|
|
also add a \f[C]\-v\ /host/db/path:/var/lib/mysql/data\f[] argument.
|
|
This will be the MySQL data directory.
|
|
.PP
|
|
If the database directory is not initialized, the entrypoint script will
|
|
first run
|
|
\f[C]mysql_install_db\f[] (https://dev.mysql.com/doc/refman/5.6/en/mysql-install-db.html)
|
|
and setup necessary database users and passwords.
|
|
After the database is initialized, or if it was already present,
|
|
\f[C]mysqld\f[] is executed and will run as PID 1.
|
|
You can stop the detached container by running
|
|
\f[C]docker\ stop\ mariadb_database\f[].
|
|
.SS MariaDB auto\-tuning
|
|
.PP
|
|
When the MySQL image is run with the \f[C]\-\-memory\f[] parameter set
|
|
and you didn\[aq]t specify value for some parameters, their values will
|
|
be automatically calculated based on the available memory.
|
|
.PP
|
|
.TS
|
|
tab(@);
|
|
l l l.
|
|
T{
|
|
Variable name
|
|
T}@T{
|
|
Configuration parameter
|
|
T}@T{
|
|
Relative value
|
|
T}
|
|
_
|
|
T{
|
|
\f[C]MYSQL_KEY_BUFFER_SIZE\f[]
|
|
T}@T{
|
|
\f[C]key_buffer_size\f[]
|
|
T}@T{
|
|
10%
|
|
T}
|
|
T{
|
|
\f[C]MYSQL_READ_BUFFER_SIZE\f[]
|
|
T}@T{
|
|
\f[C]read_buffer_size\f[]
|
|
T}@T{
|
|
5%
|
|
T}
|
|
T{
|
|
\f[C]MYSQL_INNODB_BUFFER_POOL_SIZE\f[]
|
|
T}@T{
|
|
\f[C]innodb_buffer_pool_size\f[]
|
|
T}@T{
|
|
50%
|
|
T}
|
|
T{
|
|
\f[C]MYSQL_INNODB_LOG_FILE_SIZE\f[]
|
|
T}@T{
|
|
\f[C]innodb_log_file_size\f[]
|
|
T}@T{
|
|
15%
|
|
T}
|
|
T{
|
|
\f[C]MYSQL_INNODB_LOG_BUFFER_SIZE\f[]
|
|
T}@T{
|
|
\f[C]innodb_log_buffer_size\f[]
|
|
T}@T{
|
|
15%
|
|
T}
|
|
.TE
|
|
.SS MySQL root user
|
|
.PP
|
|
The root user has no password set by default, only allowing local
|
|
connections.
|
|
You can set it by setting the \f[C]MYSQL_ROOT_PASSWORD\f[] environment
|
|
variable.
|
|
This will allow you to login to the root account remotely.
|
|
Local connections will still not require a password.
|
|
.PP
|
|
To disable remote root access, simply unset \f[C]MYSQL_ROOT_PASSWORD\f[]
|
|
and restart the container.
|
|
.SS Changing passwords
|
|
.PP
|
|
Since passwords are part of the image configuration, the only supported
|
|
method to change passwords for the database user (\f[C]MYSQL_USER\f[])
|
|
and root user is by changing the environment variables
|
|
\f[C]MYSQL_PASSWORD\f[] and \f[C]MYSQL_ROOT_PASSWORD\f[], respectively.
|
|
.PP
|
|
Changing database passwords through SQL statements or any way other than
|
|
through the environment variables aforementioned will cause a mismatch
|
|
between the values stored in the variables and the actual passwords.
|
|
Whenever a database container starts it will reset the passwords to the
|
|
values stored in the environment variables.
|
|
.SS Default my.cnf file
|
|
.PP
|
|
With environment variables we are able to customize a lot of different
|
|
parameters or configurations for the mysql bootstrap configurations.
|
|
If you\[aq]d prefer to use your own configuration file, you can override
|
|
the \f[C]MYSQL_DEFAULTS_FILE\f[] env variable with the full path of the
|
|
file you wish to use.
|
|
For example, the default location is \f[C]/etc/my.cnf\f[] but you can
|
|
change it to \f[C]/etc/mysql/my.cnf\f[] by setting
|
|
\f[C]MYSQL_DEFAULTS_FILE=/etc/mysql/my.cnf\f[]
|
|
.SS Changing the replication binlog_format
|
|
.PP
|
|
Some applications may wish to use \f[C]row\f[] binlog_formats (for
|
|
example, those built with change\-data\-capture in mind).
|
|
The default replication/binlog format is \f[C]statement\f[] but to
|
|
change it you can set the \f[C]MYSQL_BINLOG_FORMAT\f[] environment
|
|
variable.
|
|
For example \f[C]MYSQL_BINLOG_FORMAT=row\f[].
|
|
Now when you run the database with \f[C]master\f[] replication turned on
|
|
(ie, set the Docker/container \f[C]cmd\f[] to be
|
|
\f[C]run\-mysqld\-master\f[]) the binlog will emit the actual data for
|
|
the rows that change as opposed to the statements (ie, DML like
|
|
insert...) that caused the change.
|
|
.SH AUTHORS
|
|
Red Hat.
|