免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2916 | 回复: 7
打印 上一主题 下一主题

请教,mysql负载高,网页打开出现Can not connect to MySQL server [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2013-05-20 14:20 |只看该作者 |倒序浏览
请教一mysql的问题:
最近,网站打开的时候提示:Can not connect to MySQL server,登录mysql服务器,发现负载很高,查看mysql的错误日志,有大量如下错误报告:
130520 14:02:53 [ERROR] /usr/local/mysql/bin/mysqld: Incorrect key file for table '/tmp/#sql_491d_19.MYI'; try to repair it
130520 14:02:53 [ERROR] Got an error from unknown thread, /home/like/src/mysql-5.5.30/storage/myisam/mi_write.c:223
130520 14:02:54 [ERROR] /usr/local/mysql/bin/mysqld: Incorrect key file for table '/tmp/#sql_491d_1.MYI'; try to repair it
130520 14:02:54 [ERROR] Got an error from unknown thread, /home/like/src/mysql-5.5.30/storage/myisam/mi_write.c:223
130520 14:02:55 [ERROR] /usr/local/mysql/bin/mysqld: Incorrect key file for table '/tmp/#sql_491d_35.MYI'; try to repair it
130520 14:02:55 [ERROR] Got an error from unknown thread, /home/like/src/mysql-5.5.30/storage/myisam/mi_write.c:223
130520 14:02:57 [ERROR] /usr/local/mysql/bin/mysqld: Incorrect key file for table '/tmp/#sql_491d_41.MYI'; try to repair it
130520 14:02:57 [ERROR] Got an error from unknown thread, /home/like/src/mysql-5.5.30/storage/myisam/mi_write.c:223
130520 14:02:57 [ERROR] /usr/local/mysql/bin/mysqld: Incorrect key file for table '/tmp/#sql_491d_16.MYI'; try to repair it
130520 14:02:57 [ERROR] Got an error from unknown thread, /home/like/src/mysql-5.5.30/storage/myisam/mi_write.c:223
130520 14:02:58 [ERROR] /usr/local/mysql/bin/mysqld: Incorrect key file for table '/tmp/#sql_491d_9.MYI'; try to repair it
130520 14:02:58 [ERROR] Got an error from unknown thread, /home/like/src/mysql-5.5.30/storage/myisam/mi_write.c:223

百度了一下,说是表有问题,修复表就行了,但是/tmp下是临时产生的文件,怎么修复呢???

请给予指点,不胜感激!!!!

论坛徽章:
0
2 [报告]
发表于 2013-05-20 14:37 |只看该作者
/tmp下的有如下文件:
-rw-rw---- 1 mysql mysql 385875968 May 20 14:36 #sql_491d_6.MYD
-rw-rw---- 1 mysql mysql      1024 May 20 14:35 #sql_491d_6.MYI
-rw-rw---- 1 mysql mysql 452984832 May 20 14:36 #sql_491d_7.MYD
-rw-rw---- 1 mysql mysql      1024 May 20 14:35 #sql_491d_7.MYI
-rw-rw---- 1 mysql mysql 369098752 May 20 14:35 #sql_491d_8.MYD
-rw-rw---- 1 mysql mysql      1024 May 20 14:35 #sql_491d_8.MYI
-rw-rw---- 1 mysql mysql 352321536 May 20 14:35 #sql_491d_9.MYD
-rw-rw---- 1 mysql mysql      1024 May 20 14:35 #sql_491d_9.MYI

这些文件是临时的,一会有很多,一会可能就自动消失了!!!

论坛徽章:
93
2015年辞旧岁徽章
日期:2019-10-10 10:51:15CU大牛徽章
日期:2014-02-21 14:21:56CU十二周年纪念徽章
日期:2020-10-15 16:55:55CU大牛徽章
日期:2014-02-21 14:22:07羊年新春福章
日期:2019-10-10 10:51:39CU大牛徽章
日期:2019-10-10 10:55:38季节之章:春
日期:2020-10-15 16:57:40ChinaUnix元老
日期:2019-10-10 10:54:42季节之章:冬
日期:2019-10-10 10:57:17CU大牛徽章
日期:2014-02-21 14:22:52CU大牛徽章
日期:2014-03-13 10:40:30CU大牛徽章
日期:2014-02-21 14:23:15
3 [报告]
发表于 2013-05-20 16:14 |只看该作者
临时表或查询的中间结果文件,不需要处理吧。

论坛徽章:
0
4 [报告]
发表于 2013-05-20 17:08 |只看该作者
1。错误貌似是write时发生的,因为myisam是表锁,容易在高并发时出问题, myisam对并发支持不好,不如换成innodb
2。show variables like '%connect%';看一下,连接数是否满了,或是其它的配置

论坛徽章:
0
5 [报告]
发表于 2013-05-20 17:42 |只看该作者
mysql > show full processlist ;
看下负载高峰时刻的sql,大概就有眉目了.
你这个是有大量排序的sql, 临时表会占据 /tmp空间的. 缓解的办法可以暂时把 临时目录放到更大的磁盘上 ,根本的解决还是要调优.
把那些sql给研发吧.
慢查询也给研发吧.

论坛徽章:
224
2022北京冬奥会纪念版徽章
日期:2015-08-10 16:30:32操作系统版块每日发帖之星
日期:2016-02-18 06:20:00操作系统版块每日发帖之星
日期:2016-03-01 06:20:00操作系统版块每日发帖之星
日期:2016-03-02 06:20:0015-16赛季CBA联赛之上海
日期:2019-09-20 12:29:3219周年集字徽章-周
日期:2019-10-01 20:47:4815-16赛季CBA联赛之八一
日期:2020-10-23 18:30:5320周年集字徽章-20	
日期:2020-10-28 14:14:2615-16赛季CBA联赛之广夏
日期:2023-02-25 16:26:26CU十四周年纪念徽章
日期:2023-04-13 12:23:1015-16赛季CBA联赛之四川
日期:2023-07-25 16:53:45操作系统版块每日发帖之星
日期:2016-05-10 19:22:58
6 [报告]
发表于 2013-05-20 18:31 |只看该作者
调优也不是什么高深的技术活,还是看经验吧

论坛徽章:
0
7 [报告]
发表于 2013-05-21 09:49 |只看该作者
非常感谢!!!
回复 5# 闪电松鼠


   

论坛徽章:
0
8 [报告]
发表于 2013-05-21 09:55 |只看该作者
今天看mysql错误日志,发现只要出现负载高的时候,就有下面这样的日志:
130521  4:12:19 [ERROR] /usr/local/mysql/bin/mysqld: Incorrect key file for table '/tmp/#sql_6117_146.MYI'; try to repair it
130521  4:12:19 [ERROR] Got an error from unknown thread, /home/like/src/mysql-5.5.30/storage/myisam/mi_write.c:223
130521  4:12:20 [ERROR] /usr/local/mysql/bin/mysqld: Incorrect key file for table '/tmp/#sql_6117_5.MYI'; try to repair it
130521  4:12:20 [ERROR] Got an error from unknown thread, /home/like/src/mysql-5.5.30/storage/myisam/mi_write.c:223
130521  4:12:20 [ERROR] /usr/local/mysql/bin/mysqld: Incorrect key file for table '/tmp/#sql_6117_3.MYI'; try to repair it
130521  4:12:20 [ERROR] Got an error from unknown thread, /home/like/src/mysql-5.5.30/storage/myisam/mi_write.c:223
130521  4:12:20 [ERROR] /usr/local/mysql/bin/mysqld: Incorrect key file for table '/tmp/#sql_6117_9.MYI'; try to repair it
130521  4:12:20 [ERROR] Got an error from unknown thread, /home/like/src/mysql-5.5.30/storage/myisam/mi_write.c:223
130521  4:12:20 [ERROR] /usr/local/mysql/bin/mysqld: Incorrect key file for table '/tmp/#sql_6117_124.MYI'; try to repair it
130521  4:12:20 [ERROR] Got an error from unknown thread, /home/like/src/mysql-5.5.30/storage/myisam/mi_write.c:223
130521  4:12:21 [ERROR] /usr/local/mysql/bin/mysqld: Incorrect key file for table '/tmp/#sql_6117_97.MYI'; try to repair it
130521  4:12:21 [ERROR] Got an error from unknown thread, /home/like/src/mysql-5.5.30/storage/myisam/mi_write.c:223
130521  4:12:21 [ERROR] /usr/local/mysql/bin/mysqld: Incorrect key file for table '/tmp/#sql_6117_273.MYI'; try to repair it
130521  4:12:21 [ERROR] Got an error from unknown thread, /home/like/src/mysql-5.5.30/storage/myisam/mi_write.c:223
130521  4:12:21 [ERROR] /usr/local/mysql/bin/mysqld: Sort aborted: Error writing file '/tmp/MYjU3qtZ' (Errcode: 2
130521  4:12:21 [ERROR] /usr/local/mysql/bin/mysqld: Sort aborted: Error writing file '/tmp/MYNiHwBp' (Errcode: 2
130521  4:12:21 [ERROR] /usr/local/mysql/bin/mysqld: Sort aborted: Error writing file '/tmp/MYf0gut3' (Errcode: 2
130521  4:12:21 [ERROR] /usr/local/mysql/bin/mysqld: Sort aborted: Error writing file '/tmp/MYgayVo0' (Errcode: 2
130521  4:12:21 [ERROR] /usr/local/mysql/bin/mysqld: Sort aborted: Error writing file '/tmp/MYE04liE' (Errcode: 2


网上说的正如5楼闪电松鼠说的那样,应该是临时目录满了导致,先把临时目录放到别的地方吧,看看效果!!
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP