在进行主从同步时重启MySQL失败了,总结一下排查错误的步骤
首先按照提示输入
systemctl status mysql.service
获得如下日志
● mysql.service - MySQL Community Server Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled) Active: activating (start-post) (Result: exit-code) since Sun 2019-07-21 15:42:36 CST; 26s ago Process: 8007 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE) Process: 7998 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS) Main PID: 8007 (code=exited, status=1/FAILURE); : 8008 (mysql-systemd-s) CGroup: /system.slice/mysql.service └─control ├─8008 /bin/bash /usr/share/mysql/mysql-systemd-start post └─8139 sleep 1 Jul 21 15:42:36 VM-0-9-ubuntu systemd[1]: Starting MySQL Community Server... Jul 21 15:42:38 VM-0-9-ubuntu systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE
然后去查看mysql的error日志,从conf里找到error的路径
locate mysql.conf
得到如下输出
/etc/init/mysql.conf /etc/mysql/mysql.conf.d /etc/mysql/mysql.conf.d/mysqld.cnf /etc/mysql/mysql.conf.d/mysqld_safe_syslog.cnf
然后找到对应的log_error的文件路径
cat /etc/mysql/mysql.conf.d/mysqld.cnf|grep log_error
得到如下输出
log_error = /var/log/mysql/error.log
然后打开log文件
vim /var/log/mysql/error.log
然后使用Shift+g跳到最后一行,得到如下日志
2019-07-21T07:49:09.486329Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier 2019-07-21T07:49:09.486332Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.8 2019-07-21T07:49:09.486336Z 0 [Note] InnoDB: Using Linux native AIO 2019-07-21T07:49:09.486594Z 0 [Note] InnoDB: Number of pools: 1 2019-07-21T07:49:09.486711Z 0 [Note] InnoDB: Using CPU crc32 instructions 2019-07-21T07:49:09.488493Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M 2019-07-21T07:49:09.497153Z 0 [Note] InnoDB: Completed initialization of buffer pool 2019-07-21T07:49:09.499558Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority(). 2019-07-21T07:49:09.511979Z 0 [Note] InnoDB: Highest supported file format is Barracuda. 2019-07-21T07:49:09.534179Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables 2019-07-21T07:49:09.534280Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ... 2019-07-21T07:49:09.764578Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB. 2019-07-21T07:49:09.765494Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active. 2019-07-21T07:49:09.765510Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active. 2019-07-21T07:49:09.765753Z 0 [Note] InnoDB: Waiting for purge to start 2019-07-21T07:49:09.815985Z 0 [Note] InnoDB: 5.7.26 started; log sequence number 4113855 2019-07-21T07:49:09.816359Z 0 [Note] Plugin 'FEDERATED' is disabled. 2019-07-21T07:49:09.821278Z 0 [ERROR] unknown option '--skip-external-lockin' 2019-07-21T07:49:09.821302Z 0 [ERROR] Aborting
发现是因为多了一个未识别的参数 '--skip-external-lockin'
打开配置文件找到'skip-external-lockin',注释掉重启MySQL,就能够成功了
总结
- 修改mysql配置文件的时候需要注意