记一次配置mariadb慢查询日志后,mariadb无法重启

配置mariadb慢查询日志一定要配置完整路径(包括文件名)不然无法重启mariadb(/usr/local/mysql/data/slow.log)

配置mariadb日志审计的文件路径可以不加文件名,但这个不可以。
Jan 28 10:22:29 system mariadb-prepare-db-dir: Database MariaDB is probably initialized in /var/lib/mysql already, nothing is done.
Jan 28 10:22:29 system mariadb-prepare-db-dir: If this is not the case, make sure the /var/lib/mysql is empty before running mariadb-prepare-db-dir.
Jan 28 10:22:29 system mysqld_safe: 180128 10:22:29 mysqld_safe Logging to '/var/log/mariadb/mariadb.log'.
Jan 28 10:22:29 system mysqld_safe: 180128 10:22:29 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
Jan 28 10:27:29 system systemd: mariadb.service start-post operation timed out. Stopping.
Jan 28 10:30:01 system systemd: Started Session 9063 of user root.
Jan 28 10:30:01 system systemd: Starting Session 9063 of user root.
Jan 28 10:32:29 system systemd: mariadb.service stop-sigterm timed out. Killing.
Jan 28 10:32:29 system systemd: mariadb.service: main process exited, code=killed, status=9/KILL
Jan 28 10:32:29 system systemd: Failed to start MariaDB database server.
Jan 28 10:32:29 system systemd: Unit mariadb.service entered failed state.
Jan 28 10:32:29 system systemd: mariadb.service failed.
Jan 28 10:37:04 system systemd: Starting MariaDB database server...
Jan 28 10:37:04 system mariadb-prepare-db-dir: Database MariaDB is probably initialized in /var/lib/mysql already, nothing is done.
Jan 28 10:37:04 system mariadb-prepare-db-dir: If this is not the case, make sure the /var/lib/mysql is empty before running mariadb-prepare-db-dir.
Jan 28 10:37:05 system mysqld_safe: 180128 10:37:05 mysqld_safe Logging to '/var/log/mariadb/mariadb.log'.
Jan 28 10:37:05 system mysqld_safe: 180128 10:37:05 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
Jan 28 10:37:07 system systemd: Started MariaDB database server.
Jan 28 10:40:01 system systemd: Started Session 9064 of user root.
Jan 28 10:40:01 system systemd: Starting Session 9064 of user root.

配置后,systemctl restart mariadb 一直挂着,但起不来一开始判断是用于mysql_safe,(以前遇到过mysql没有完全退出,

启动mariadb提示,已经重启。把mysql彻底杀死后就能重启了)

由于MySQL有一个守护进程,MySQL_safe这样的,所以每次强制杀死,他都会自动启动

可以通过下面的方式来杀死MySQL服务:

service mysqld stop

ps -ef|grep mysql | grep -v grep |awk '{print $2}' | xargs kill -9 批量杀死mysql进程,但还是无法把所有mysql进程杀死。

后来发现是/etc/my.cnf

中慢查询的路径没有是全路径造成的

slow_query_log=ON
slow_query_log_file=/data/mysql/auditlogs/
long_query_time=1

修改后:

slow_query_log=ON
slow_query_log_file=/data/mysql/auditlogs/slow.log
long_query_time=1

顺利重启

补充:

配置mysql日志审计是并不需要全路径

server_audit_events='CONNECT,QUERY,TABLE,QUERY_DDL,QUERY_DML,QUERY_DCL'
server_audit_logging=on
server_audit_file_path =/data/mysql/auditlogs/
server_audit_file_rotate_size=2000000
server_audit_file_rotations=200
server_audit_file_rotate_now=ON



你可能感兴趣的:(mysql)