背景
搭建了mysql的主从环境,然后在从上面kill -9杀死了mysql进程。之后在slave上面重启mysql服务,端口起来后无法登陆数据库。过了好一会才能登陆上去。
查看mysql.err错误日志发现如下信息
2020-04-22T10:27:16.091165Z 0 [Note] InnoDB: Doing recovery: scanned up to log sequence number 78607991370
之后打印
[Note] InnoDB: Database was not shutdown normally!
[Note] InnoDB: Starting crash recovery.
提示说mysql没有正常关闭。那么怎么才算正常关闭呢,正常关闭和非正常关闭有啥区别呢?
带着这些疑问,去查一下资料。
资料
(1)mysql正常关闭方法: bin/mysqladmin -u ${user} -p ${password} -S ${mysql.sock} shutdown
举例:
/kingdb/usr/local/nestdb_master/bin/mysqladmin -uroot -p123456 -S /kingdb/usr/local/nestdb_master/tmp/mysql.sock shutdown
查看mysql.err日志,发现记录了shutdown之后都干了什么事:
[Note] Giving 0 client threads a chance to die gracefully ---gracefully,应该就表示是温和不失礼貌的关闭方式
Shutting down slave threads
Forcefully disconnecting 0 remaining clients
Binlog end
Shutting down plugin 'ngram'
InnoDB: FTS optimize thread exiting.
InnoDB: Starting shutdown...
InnoDB: Dumping buffer pool(s) to /kingdb/usr/local/nestdb_master/var/ib_buffer_pool
InnoDB: Buffer pool(s) dump completed at 200422 20:59:40
InnoDB: shut down release done
InnoDB: shut down all bg threads
[Warning] InnoDB: Some (1) threads are still active
[Note] InnoDB: Shutdown completed; log sequence number 4522278
[Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
[Note] Shutting down plugin 'binlog'
[Note] /kingdb/usr/local/nestdb_master/bin/mysqld: Shutdown complete
上面的日志,大致看出流程为: 关闭插件-->dumping buffer pool--->杀掉进程--->删掉了临时表空间文件ibtmp1---->关闭binlog插件等