如何更改Mariadb 10.3的PID位置?

时间:2018-10-16 03:57:29

标签: mysql mariadb

我正在使用centos7.3,请通过yum install MariaDB-server MariaDB-client安装mariadb 10.3。
在my.cnf中,我将PID位置设置如下:

[mysqld_safe]
pid-file=/var/run/mariadb/mariadb.pid  

我可以登录mariadb,并且错误日志中没有错误。但是我找不到/var/run/mariadb/mariadb.pid
即使我触摸/var/run/mariadb/mariadb.pidchown mysql:mysql/var/run/mariadb/mariadb.pid中也没有任何内容。

根据olegsv的回答,PID位置为/var/lib/mysql/localhost.pid

MariaDB [(none)]> show variables like '%pid%';
+---------------+------------------------------+
| Variable_name | Value                        |
+---------------+------------------------------+
| pid_file      | /var/lib/mysql/localhost.pid |
+---------------+------------------------------+
1 row in set (0.001 sec)  

根据里克·詹姆斯(Rick James)的回答,我将pid-file=/var/run/mariadb/mariadb.pid移至[mysqld]systemctl restart mariadb,我发现mariadb无法重新启动,错误信息如下:

[root@localhost my.cnf.d]# systemctl status mariadb -l
● mariadb.service - MariaDB 10.3.10 database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
  Drop-In: /etc/systemd/system/mariadb.service.d
           └─migrated-from-my.cnf-settings.conf
   Active: failed (Result: exit-code) since Sun 2018-10-21 1:10:12 UTC; 30s ago
     Docs: man:mysqld(8)
           https://mariadb.com/kb/en/library/systemd/
  Process: 1502 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
  Process: 1610 ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION (code=exited, status=1/FAILURE)
  Process: 1517 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= ||   VAR=`/usr/bin/galera_recovery`; [ $? -eq 0 ]   && systemctl set-environment _WSREP_START_POSITION=$VAR || exit 1 (code=exited, status=0/SUCCESS)
  Process: 1515 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
 Main PID: 1610 (code=exited, status=1/FAILURE)

Oct 21 1:10:12 localhost.localdomain systemd[1]: Starting MariaDB 10.3.10 database server...
Oct 21 1:10:12 localhost.localdomain mysqld[1610]: 2018-10-21 1:10:12 0 [Note] /usr/sbin/mysqld (mysqld 10.3.10-MariaDB-log) starting as process 1610 ...
Oct 21 1:10:12 localhost.localdomain systemd[1]: mariadb.service: main process exited, code=exited, status=1/FAILURE
Oct 21 1:10:12 localhost.localdomain systemd[1]: Failed to start MariaDB 10.3.10 database server.
Oct 21 1:10:12 localhost.localdomain systemd[1]: Unit mariadb.service entered failed state.
Oct 21 1:10:12 localhost.localdomain systemd[1]: mariadb.service failed.  

并且:

[root@localhost my.cnf.d]# journalctl -xe
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mariadb.service has begun shutting down.
Oct 21 1:10:12 localhost.localdomain systemd[1]: Starting MariaDB 10.3.10 datab
-- Subject: Unit mariadb.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mariadb.service has begun starting up.
Oct 21 1:10:12 localhost.localdomain mysqld[1610]: 2018-10-21 1:10:12 0 [Note]
Oct 21 1:10:12 localhost.localdomain systemd[1]: mariadb.service: main process
Oct 21 1:10:12 localhost.localdomain systemd[1]: Failed to start MariaDB 10.3.1
-- Subject: Unit mariadb.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mariadb.service has failed.
--
-- The result is failed.
Oct 21 1:10:12 localhost.localdomain systemd[1]: Unit mariadb.service entered f
Oct 21 1:10:12 localhost.localdomain systemd[1]: mariadb.service failed.
Oct 21 1:10:12 localhost.localdomain polkitd[601]: Unregistered Authentication

如何更改Mariadb 10.3的PID位置?

2 个答案:

答案 0 :(得分:0)

从mariadb客户提示:

show variables like '%pid%';

答案 1 :(得分:0)

my.cnf(或配置文件所在的位置)中,添加[mysqld]部分:

pid-file = /path/to/filename