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:

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章