lamp架构中数据库mariadb服务中配置文件my.cnf之[mysqld_safe]选项组(Option Groups)分析

lamp架构中数据库mariadb服务中配置文件my.cnf之[mysqld_safe]选项组(Option Groups)分析

分析:我们发现,当我们启动mariadb服务后,会默认开启2个进程,一个是mysqld_safe,一个是mysqld进程。mysqld_safe进程就是本节点要叙述的对象。该服务进程一般在systemctl start mariadb.service的时候会自动开启2个进程mysqld_safe进程和mysqld进程。
该进程是安全进程,比如当主进程mysqld进程崩溃后,会自动重启mysqld服务。

[root@localhost ~]# systemctl start  mariadb.service
[root@localhost ~]# ps axu |grep mysql
mysql     89280  0.6  0.1 113320  1600 ?        Ss   14:10   0:00 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
mysql     89482  2.7  8.3 968800 82728 ?        Sl   14:11   0:00 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mariadb/mariadb1.log --pid-file=/var/run/mariadb/mariadb.pid --socket=/var/lib/mysql/mysql.sock --port=3306
root      89572  0.0  0.0 112712   964 pts/0    S+   14:11   0:00 grep --color=auto mysql

1.mysqld_safe读取配置文件/etc/my.cnf的时候,优先级最高的group option是[mysqld_safe],下面列表中有该选项组支持的具体选项,同时也会读取其它组,如[mysqld][mariadb][server]等(详细参见下面的列表),但是[mysqld_safe]优先级最高,如果与其他组都定义了某个参数,那么以[mysqld_safe]为准。

2.开启的mysqld和mysqld_safe进程,这2个进程都会读取[mysqld_safe]组,且都以该组优先级最高。

下面是官网文档中选项组部分内容,更详细分析参见官网文档地址mysqld_safe官网文档:
Option Groups
mysqld_safe reads options from the following option groups from option files:

Group Description
[mysqld_safe] Options read by mysqld_safe, which includes both MariaDB Server and MySQL Server.
[safe_mysqld] Options read by mysqld_safe, which includes both MariaDB Server and MySQL Server.
[mariadb_safe] Options read by mysqld_safe from MariaDB Server.
[mariadb-safe] Options read by mysqld_safe from MariaDB Server. Available starting with MariaDB 10.4.6.

The [safe_mysqld] option group is primarily supported for backward compatibility. You should rename such option groups to [mysqld_safe] in MariaDB installations to prevent breakage in the future if this compatibility is removed.

mysqld_safe also reads options from the following server option groups from option files:

Group Description
[mysqld] Options read by mysqld, which includes both MariaDB Server and MySQL Server.
[server] Options read by MariaDB Server.
[mysqld-X.Y] Options read by a specific version of mysqld, which includes both MariaDB Server and MySQL Server. For example, [mysqld-5.5].
[mariadb] Options read by MariaDB Server.
[mariadb-X.Y] Options read by a specific version of MariaDB Server.
[client-server] Options read by all MariaDB client programs and the MariaDB Server. This is useful for options like socket and port, which is common between the server and the clients.
[galera] Options read by a galera-capable MariaDB Server. Available on systems compiled with Galera support.

For example, if you specify the log_error option in a server option group in an option file, like this:

[mariadb]
log_error=error.log

Then mysqld_safe will also use this value for its own --log-error option:

你可能感兴趣的:(mysql,mysql,linux,mariadb)