您现在的位置是:首页» windows系统» mysql启动后停止的解决方法,mysql启动超时

mysql启动后停止的解决方法,mysql启动超时

2024-07-13 01:51:14
本内容由系统网小编为大家分享,Windows系统安装教程、办公系统、软件怎么使用、软件使用教程、办公软件攻略等信息。现象,通过查看 日志,220201 13:48:56 mysqld_safe mysqld from pid file /v

本内容由系统网小编为大家分享,Windows系统安装教程、办公系统、软件怎么使用、软件使用教程、办公软件攻略等信息。

现象,通过查看 日志,

220201 13:48:56 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended220201 13:58:54 mysqld_safe Logging to ‘/var/log/mysqld.log’.

可以看到,这里经过了10分钟,MySQL才进行了第二次尝试启动,在这里卡了10分钟之久,查看,/etc/my.cnf [root@bogon ~]#cat /etc/my.cnf

[mysqld]datadir=/var/lib/mysqlsocket=/var/lib/mysql/mysql.sock symbolic-links=0 sql_mode=NO_ENGINE_SUBSTITUTION [mysqld_safe]log-error=/var/log/mysqld.logpid-file=/var/run/mysqld/mysqld.pid

是否支持符号链接,即数据库或表可以存储在my.cnf中指定datadir之外的分区或目录,为0不开启

“STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER”sql_mode 模式,定义了你MySQL应该支持的sql语法,对数据的校验等等,限制一些所谓的‘不合法’的操作对于STRICT_TRANS_TABLES,MySQL将非法值转换为最接近该列的合法值并插入调整后的值。“NO_ENGINE_SUBSTITUTION”,表示不进行引擎替换.

symbolic-links=0 sql_mode=NO_ENGINE_SUBSTITUTION 这两货,在网上查了一下,似乎对MySQL启动并没有什么关系,只是在使用 mysql的时候会有影响

但,神奇的是,我把这两货删除之后,重启服务器,MySQL秒启动,一点也不卡了.

回过头,咱们再来研究日志,

2022-02-0114:01:485660 [Note] /usr/sbin/mysqld:Normal shutdown

2022-02-0114:01:485660 [Note] Giving 0 client threads a chance to die gracefully

这是我重启服务器的日志描述,normal shutdown 正常关闭MySQL

2022-02-0114:02:040[Warning]TIMESTAMP with implicit DEFAULTvalue is deprecated. Please use --explicit_defaults_for_timestampserver option (see documentation for more details). 2022-02-0114:02:04 0 [Note] /usr/sbin/mysqld (mysqld 5.6.51) starting as process1789 … 2022-02-0114:02:041789[Warning]Buffered warning:Changed limits: max_open_files: 1024 (requested 5000)

2022-02-0114:02:041789[Warning]Buffered warning: Changed limits:table_open_cache: 431 (requested 2000)

到这里,出现了[Warning]但不是ERROR,所以忽略继续往下看

2022-02-0114:02:041789[ERROR]Can’t start server: Bind on TCP/IP port: Address already in use2022-02-0114:02:041789[ERROR]Do youalready have another mysqld server running on port: 3306 ? 2022-02-0114:02:041789[ERROR]Aborting

到这里,出了3个ERROR, 但没卡住,还在继续往下走,

2022-02-01 14:02:06 1789 [Note] /usr/sbin/mysqld: Shutdown complete

220201 14:02:06 mysqld_safe mysqld from pid file/var/run/mysqld/mysqld.pid ended220201 14:12:04 mysqld_safe Loggingto ‘/var/log/mysqld.log’.

注意这里,02到12,卡了10分钟,然后没停顿继续往下走,

220201 14:12:04 mysqld_safe Starting mysqld daemon with databases from/var/lib/mysql 2022-02-0114:12:050 [Warning] TIMESTAMP with implicitDEFAULT value is deprecated. Please use–explicit_defaults_for_timestamp server option (see documentation for more details). 2022-02-01 14:12:05 0 [Note] /usr/sbin/mysqld (mysqld 5.6.51) starting as process 5836 … 2022-02-0114:12:055836 [Warning] Buffered warning: Changed limits: max_open_files: 1024(requested 5000)

2022-02-0114:12:055836 [Warning] Buffered warning: Changed limits:table_open_cache: 431 (requested 2000)

虽然这里又出了3个 [Warning] ,但没卡继续往下走

2022-02-0114:12:055836 [Note] /usr/sbin/mysqld:ready forconnections. Version: ‘5.6.51’ socket: ‘/var/lib/mysql/mysql.sock’port: 3306 MySQL Community Server (GPL)

直接启动成功,

这里拦一下 一个循环结束 接着分析 下面的日志

这里,在下一个循环开始之前,

手工到/etc/my.cnf里把 symbolic-links=0 sql_mode=NO_ENGINE_SUBSTITUTION 这两个东西删了,保存退出,然后,开始下一个循环 ,重启服务器,

2022-02-01 15:03:00 5836 [Note] /usr/sbin/mysqld:Normal shutdown

2022-02-01 15:03:00 5836 [Note] Giving 0 client threads a chance to die gracefully

一个新的重启,

2022-02-01 15:03:17 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp serveroption (see documentation for more details). 2022-02-01 15:03:17 0[Note] /usr/sbin/mysqld (mysqld 5.6.51) starting as process 1660 …2022-02-01 15:03:17 1660 [Warning] Buffered warning: Changed limits:max_open_files: 1024 (requested 5000)

2022-02-01 15:03:17 1660 [Warning] Buffered warning: Changed limits:table_open_cache: 431 (requested 2000)

又出现了3个 [Warning] ,但没卡,继续往下走,

2022-02-01 15:03:17 1660 [Note] /usr/sbin/mysqld:ready for connections. Version: ‘5.6.51’ socket: ‘/var/lib/mysql/mysql.sock’port: 3306 MySQL Community Server (GPL)

一点也没卡,直接秒起,第二个循环的 服务器重启时间是:15:03:00,数据库就位的时间是: 15:03:17,时间采用了170毫秒,和刚才的 10分钟比起来,天差地别.

这就是 /etc/my.cnf 文件影响的MySQL 启动

February the 01st 2022 tuesday

补充,重启服务器没问题,但是关闭服务器等半小时再开机,就又出现了之前的问题,卡在 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended 这里,然后过了10分钟才又开始执行下面的语句 mysqld_safe Logging to '/var/log/mysqld.log'. 卡在它俩中间了,

于是,继续研究,去看 交给 chkconfig 管理的 mysqld 的内容,[root@bogon ~]#cd /etc/rc.d/init.d [root@bogon init.d]#ll

总用量 44-rw-r–r--. 1 root root 17500 5月 3 2017 functions-rwxr-xr-x. 1 root root 1141 2月 1 13:58mysqld -rwxr-xr-x. 1 root root 4334 5月 3 2017 netconsole-rwxr-xr-x. 1 root root 7293 5月 3 2017 network-rw-r–r--. 1 root root 1160 8月 5 2017 README

[root@bogon init.d]#cat mysqld

# chkconfig: 2345320# description:February the 01st tuesday 2022

[Unit]Description=MySQL Community Server After=network.targetAfter=syslog.target

我设置的 mysqld 的启动顺位是3,但, [Unit] 写明了,要在 network 之后启动,所以还要去看一下 network 的启动顺位是多少,[root@bogon init.d]#cat network

# chkconfig: 23451090# description: Activates/Deactivates all network interfaces configured

可以看到,network 的启动顺位是 10,所以,需要将 mysqld 的启动顺位调整到 network 之后,[root@bogon init.d]#vi mysqld

# chkconfig: 23451191# description:February the 01st tuesday 2022

调整完毕,保存退出,再关机等待一段时间后,开启服务器,看结果,还是不行,

去查看MySQL 当前状态[root@bogon ~]#systemctl status mysqld

● mysqld.service - MySQL Community ServerLoaded:loaded(/usr/lib/systemd/system/mysqld.service; enabled; vendor preset:disabled)

可以看出,MySQL 启动的时候,是要去load/usr/lib/systemd/system/mysqld.service它的,去看看它里面都有啥,[root@bogon ~]#cd /usr/lib/systemd/system/ [root@bogon system]#ll |grep mysql

-rwxr-xr–. 1 root root 1073 1月 5 2021mysqld.service

打开看看[root@bogon system]#cat mysqld.service

TimeoutSec=600

有一行这个,600秒不就是10分钟嘛,不正好是卡住的时间长度么(mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended),既然我不知道问题出在哪里,要不我就给这个时间减少点,这样会不会能快点启动呢?着手实验,[root@bogon system]#vi mysqld.service

TimeoutSec=6

改成 6 秒,保存退出,关机 等待一段时间,再开机,看看效果.可以了,不用等10分钟以上了.但不知道,问题是不是彻底解决了,需要在以后的使用中验证,

February the 01st 2022 tuesday

XTw.com.Cn系统网专业应用软件下载教程,免费windows10系统,win11,办公软件,OA办公系统,OA软件,办公自动化软件,开源系统,移动办公软件等信息,解决一体化的办公方案。

免责声明:本文中引用的各种信息及资料(包括但不限于文字、数据、图表及超链接等)均来源于该信息及资料的相关主体(包括但不限于公司、媒体、协会等机构)的官方网站或公开发表的信息。内容仅供参考使用,不准确地方联系删除处理!

联系邮箱:773537036@qq.com