修改了MariaDB的binlog目录后,重启数据库时,数据库无法启动:
[root@www.cndba.cn/dave binlog]# cat /etc/my.cnf |grep log-bin
log-bin=/mysql/binlog/mysql-bin
#log-bin=mysql-bin
[root@www.cndba.cn/dave binlog]#
[root@www.cndba.cn/dave ~]# service mysql start
Starting MySQL.180209 06:28:38 mysqld_safe Logging to '/mysql/log/www.cndba.cn-error.log'.
180209 06:28:38 mysqld_safe Starting mysqld daemon with databases from /mysql/data
[FAILED]
[root@www.cndba.cn/dave ~]# tail -100 /mysql/log/www.cndba.cn-error.log
……
2018-02-09 0:43:23 139625775822624 [Note] InnoDB: Completed initialization of buffer pool
2018-02-09 0:43:23 139624759187200 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2018-02-09 0:43:23 139625775822624 [Note] InnoDB: Highest supported file format is Barracuda.
2018-02-09 0:43:23 139625775822624 [Note] InnoDB: 128 out of 128 rollback segments are active.
2018-02-09 0:43:23 139625775822624 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
2018-02-09 0:43:23 139625775822624 [Note] InnoDB: Creating shared tablespace for temporary tables
2018-02-09 0:43:23 139625775822624 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2018-02-09 0:43:23 139625775822624 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2018-02-09 0:43:23 139625775822624 [Note] InnoDB: 5.7.20 started; log sequence number 3637288
2018-02-09 0:43:23 139624569612032 [Note] InnoDB: Loading buffer pool(s) from /mysql/data/ib_buffer_pool
2018-02-09 0:43:23 139625775822624 [Note] Plugin 'FEEDBACK' is disabled.
2018-02-09 0:43:23 139624569612032 [Note] InnoDB: Buffer pool(s) load completed at 180209 0:43:23
2018-02-09 0:43:23 139625775822624 [Note] Server socket created on IP: '::'.
2018-02-09 0:43:23 139625775822624 [Note] Reading of all Master_info entries succeded
2018-02-09 0:43:23 139625775822624 [Note] Added new Master_info '' to hash table
2018-02-09 0:43:23 139625775822624 [Note] /usr/local/mysql/bin/mysqld: ready for connections.
Version: '10.2.12-MariaDB-log' socket: '/tmp/mysql.sock' port: 3306 MariaDB Server
2018-02-09 3:52:00 139625710143232 [Warning] Access denied for user 'root-p'@'localhost' (using password: NO)
2018-02-09 3:52:06 139625710143232 [Warning] Access denied for user 'root-p'@'localhost' (using password: NO)
2018-02-09 3:52:49 139625710143232 [Warning] Access denied for user 'root'@'localhost' (using password: YES)
2018-02-09 4:23:13 139625710143232 [Warning] Access denied for user 'root'@'localhost' (using password: YES)
2018-02-09 6:22:48 140098576807712 [ERROR] mysqld: File '/mysql/binlog/mysql-bin.index' not found (Errcode: 13 "Permission denied")
2018-02-09 6:22:48 140098576807712 [ERROR] Aborting
2018-02-09 6:26:58 139977038448416 [ERROR] mysqld: File '/mysql/binlog/mysql-bin.index' not found (Errcode: 13 "Permission denied")
2018-02-09 6:26:58 139977038448416 [ERROR] Aborting
2018-02-09 6:27:03 139645294339872 [ERROR] mysqld: File '/mysql/binlog/mysql-bin.index' not found (Errcode: 13 "Permission denied")
2018-02-09 6:27:03 139645294339872 [ERROR] Aborting
2018-02-09 6:28:38 139904265774880 [ERROR] mysqld: File '/mysql/binlog/mysql-bin.index' not found (Errcode: 13 "Permission denied")
2018-02-09 6:28:38 139904265774880 [ERROR] Aborting
从上面的日志看,向是文件不存在的问题,实际上文件确实不存在,这里的关键问题还是文件权限的问题,修改之后的binlog目录是root用户的,而我们的MariaDB是用mysql用户运行的,修改binlog目录的权限到mysql用户后,重启就正常了:
[root@www.cndba.cn/dave ~]# cd /mysql
[root@www.cndba.cn/dave mysql]# ll
total 12
drwxr-xr-x 2 root root 4096 Feb 9 05:54 binlog
drwx------ 6 mysql mysql 4096 Feb 9 06:28 data
drwxr-xr-x 2 mysql mysql 4096 Feb 8 11:47 log
[root@www.cndba.cn/dave mysql]# chown mysql:mysql binlog/
[root@www.cndba.cn/dave mysql]# service mysql start
Starting MySQL.180209 06:30:07 mysqld_safe Logging to '/mysql/log/www.cndba.cn-error.log'.
180209 06:30:07 mysqld_safe Starting mysqld daemon with databases from /mysql/data
[ OK ]
[root@www.cndba.cn/dave mysql]# cd binlog
[root@www.cndba.cn/dave binlog]# ls
mysql-bin.000001 mysql-bin.index
[root@www.cndba.cn/dave binlog]#
实际上,修改binlog目录位置也会导致序列从1开始:
[root@Dave binlog]# ll
total 12
-rw-rw---- 1 mysql mysql 351 Feb 9 06:36 mysql-bin.000001
-rw-rw---- 1 mysql mysql 328 Feb 9 06:36 mysql-bin.000002
-rw-rw---- 1 mysql mysql 62 Feb 9 06:36 mysql-bin.index
[root@Dave binlog]#
版权声明:本文为博主原创文章,未经博主允许不得转载。