Frage

In addition to the formal documentation (i.e. https://mariadb.com/resources/blog/installing-mariadb-10-centos-7-rhel-7, etc), there are countless tutorials on installing MariaDB, however, not one of them goes on to say that additional steps maybe be needed for the specific installation requirements. Is the next unwritten and assumed step to modify /etc/my.cnf as needed? When I set out to do so, I am surprise to find that mine is practically empty unlike the typical long winded configuration files with various configuration settings commented out. Is this /etc/my.cnf file the one I should be editing, or is this some common MySQL/MariaDB file and there is some other MariaDB specific file located elsewhere? Or is there potentially no configuration file as https://mariadb.com/kb/en/library/configuring-mariadb-with-mycnf/ hints? What is the next step if I wish to make various changes such as timezone, etc?

cat /etc/os-release:

NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"

PHP version: 7.1.14
cat /etc/yum.repos.d/MariaDB.repo (Gives information on how package was installed.):

# MariaDB 10.2 CentOS repository list - created 2017-07-17 12:45 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.2/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
ls -l /etc | grep sql (Nothing):

ls -l /etc | grep maria (Nothing):

ls -l /etc | grep my:

-rw-r--r--   1 root root      202 Feb 12 15:01 my.cnf
drwxr-xr-x   2 root root       78 Feb 19 12:05 my.cnf.d
cat /etc/my.cnf:

#
# This group is read both both by the client and the server
# use it for options that affect everything
#
[client-server]

#
# include all files from the config directory
#
!includedir /etc/my.cnf.d

ls -l /etc/my.cnf.d:

total 12
-rw-r--r-- 1 root root  763 Feb 12 15:01 enable_encryption.preset
-rw-r--r-- 1 root root  232 Feb 12 15:01 mysql-clients.cnf
-rw-r--r-- 1 root root 1080 Feb 12 15:01 server.cnf
tail -n +1 -- /etc/my.cnf.d/*:

==> /etc/my.cnf.d/enable_encryption.preset <==
#
# !include this file into your my.cnf (or any of *.cnf files in /etc/my.cnf.d)
# and it will enable data at rest encryption. This is a simple way to
# ensure that everything that can be encrypted will be and your
# data will not leak unencrypted.
#
# DO NOT EDIT THIS FILE! On MariaDB upgrades it might be replaced with a
# newer version and your edits will be lost. Instead, add your edits
# to the .cnf file after the !include directive.
#
# NOTE that you also need to install an encryption plugin for the encryption
# to work. See https://mariadb.com/kb/en/mariadb/data-at-rest-encryption/#encryption-key-management
#
[mariadb]
aria-encrypt-tables
encrypt-binlog
encrypt-tmp-disk-tables
encrypt-tmp-files
loose-innodb-encrypt-log
loose-innodb-encrypt-tables

==> /etc/my.cnf.d/mysql-clients.cnf <==
#
# These groups are read by MariaDB command-line tools
# Use it for options that affect only one utility
#

[mysql]

[mysql_upgrade]

[mysqladmin]

[mysqlbinlog]

[mysqlcheck]

[mysqldump]

[mysqlimport]

[mysqlshow]

[mysqlslap]


==> /etc/my.cnf.d/server.cnf <==
#
# These groups are read by MariaDB server.
# Use it for options that only the server (but not clients) should see
#
# See the examples of server my.cnf files in /usr/share/mysql/
#

# this is read by the standalone daemon and embedded servers
[server]

# this is only for the mysqld standalone daemon
[mysqld]

#
# * Galera-related settings
#
[galera]
# Mandatory settings
#wsrep_on=ON
#wsrep_provider=
#wsrep_cluster_address=
#binlog_format=row
#default_storage_engine=InnoDB
#innodb_autoinc_lock_mode=2
#
# Allow server to accept connections on all interfaces.
#
#bind-address=0.0.0.0
#
# Optional setting
#wsrep_slave_threads=1
#innodb_flush_log_at_trx_commit=0

# this is only for embedded server
[embedded]

# This group is only read by MariaDB servers, not by MySQL.
# If you use the same .cnf file for MySQL and MariaDB,
# you can put MariaDB-only options here
[mariadb]

# This group is only read by MariaDB-10.1 servers.
# If you use the same .cnf file for MariaDB of different versions,
# use this group for options that older servers don't understand
[mariadb-10.1]

ls -l /usr/share/mysql | grep cnf (Should I be swapping out /etc/my.cnf with one of these?):

-rw-r--r-- 1 root root   4920 Feb 12 16:58 my-huge.cnf
-rw-r--r-- 1 root root  20441 Feb 12 16:58 my-innodb-heavy-4G.cnf
-rw-r--r-- 1 root root   4907 Feb 12 16:58 my-large.cnf
-rw-r--r-- 1 root root   4920 Feb 12 16:58 my-medium.cnf
-rw-r--r-- 1 root root   2846 Feb 12 16:58 my-small.cnf
-rw-r--r-- 1 root root   3452 Feb 12 16:58 wsrep.cnf

EDIT. Ah, mysqld --help --verbose and mysqladmin variables is partially what I was looking for. But the question remains. Where are these default settings defined, and why can't I find any documentation/tutorial/blog recommending that they be modified?

mysqld  Ver 10.2.13-MariaDB for Linux on x86_64 (MariaDB Server)
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Starts the MariaDB database server.

Usage: mysqld [OPTIONS]

Default options are read from the following files in the given order:
/etc/my.cnf ~/.my.cnf
The following groups are read: mysqld server mysqld-10.2 mariadb mariadb-10.2 client-server galera
The following options may be given as the first argument:
--print-defaults        Print the program argument list and exit.
--no-defaults           Don't read default options from any option file.

....

Variables (--variable-name=value)
and boolean options {FALSE|TRUE}                           Value (after reading options)
---------------------------------------------------------- ---------------
allow-suspicious-udfs                                      FALSE
aria                                                       ON
aria-block-size                                            8192
aria-checkpoint-interval                           

PS. The following was used to generate the above content and is provided for reference only.

<?php
function execute($cmd, $extra=null) {
    echo '<p>'.$cmd.($extra?'   ('.$extra.')':'').':</p><pre>'.shell_exec($cmd).'</pre>';
}

echo execute('cat /etc/os-release');
echo 'PHP version: ' . phpversion().'<br>';
echo execute('cat /etc/yum.repos.d/MariaDB.repo','Gives information on how package was installed.');
echo execute('ls -l /etc | grep sql','Nothing');
echo execute('ls -l /etc | grep maria','Nothing');
echo execute('ls -l /etc | grep my');
echo execute('cat /etc/my.cnf');
echo execute('ls -l /etc/my.cnf.d');
echo execute('tail -n +1 -- /etc/my.cnf.d/*');
echo execute('ls -l /usr/share/mysql | grep cnf','Should I be swapping out /etc/my.cnf with one of these?');
War es hilfreich?

Lösung

The my.cnf settings (including my.cnf.d/*), if any, are in front of built-in defaults. All of this is "reasonable" for a generic install.

Adding to them (or changing them) is important only after you find that your application is not 'average'.

The most important setting (for performance) is innodb_buffer_pool_size; it should be set to about 70% of available memory. Almost everything else (there are hundreds of "variables") does not need changing without a good reason.

True, this forum is loaded with questions relating to settings in my.cnf. I find that they fall into these categories:

  • "Bigger is better" -- users who get into trouble by increasing various settings without understanding the negative ramifications (such as running out of RAM).
  • "My site is slow; help me tune" -- The answer almost always involves INDEXes and/or query formulation, not tuning.
  • "I think ..." -- Many of the tunables are subtle, ambiguous, difficult to understand, etc. And it is rarely obvious how this tunable relates to that problem.

To get the full list (from, for example, the commandline tool "mysql"):

SHOW VARIABLES;

I gave you the one thing to change; don't worry about changing any others until you get specific advice.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit dba.stackexchange
scroll top