- 浏览: 828122 次
- 性别:
- 来自: lanzhou
文章分类
最新评论
-
liu346435400:
楼主讲了实话啊,中国程序员的现状,也是只见中国程序员拼死拼活的 ...
中国的程序员为什么这么辛苦 -
qw8226718:
国内ASP.NET下功能比较完善,优化比较好的Spacebui ...
国内外开源sns源码大全 -
dotjar:
敢问兰州的大哥,Prism 现在在12.04LTS上可用么?我 ...
最佳 Ubuntu 下 WebQQ 聊天体验 -
coralsea:
兄弟,卫星通信不是这么简单的,单向接收卫星广播信号不需要太大的 ...
Google 上网 -
txin0814:
我成功安装chrome frame后 在IE地址栏前加上cf: ...
IE中使用Google Chrome Frame运行HTML 5
I had a call from a new customer last week. They had issues with their MySQL server. Apparently, it was repeatingly crashing, every few hours. To have their production system kept alive, they used a script to periodically see if MySQL was still alive, and if not – start it. I was first thinking in directions of old installations; wrong memory allocations (too little memory for large content; to large memory allocation for weak machine). When I reached the customer’s premises, I quickly reviewed general settings, while explaining some basic configuration guidelines. There were peculiarities (e.g. query_cache_limit being larger than query_cache_size), but nothing to obviously suggest a reason for crash. I then observed the error log. Took some time to find it, since the log_error parameter appeared twice in the my.cnf file; first one appearing at the very beginning, the second (overwriting the first) was far into the file. Sure enough, there were a lot of startup messages. And… shutdown messages. In fact, the log looked something like: (The above is just a sample, not the original file). Well, the log says there’s a lot of normal shutdowns. Next it was time to look at the script which was supposed to verify MySQL was up and running – else wise start it. And it went something like this: The script was looking for all processes, then grepping for mysqld, counting number of lines in output. It expected 2 lines: one for the mysqld process, one for the grep mysqld process itself. If you don’t know what’s wrong with this, a very brief explanation about how pipelines work in unix work it at place: Pipelined processes do not execute one after another, or one before another. They are all executed at once. So, “ps aux | grep mysqld | wc -l” immediately spawns ps, grep, wc, then sets the standard output of one to the standard input of the other (most simplified description I could think of). It is likely that grep will outrun ps in the race for starting up. So grep is started, already waiting for input from ps, which then notices both mysqld is alive, but also grep mysqld, lists them both along with other processes, to be filtered by grep, to be counted by wc (returning two lines count). But this is just because ps is heavier than grep. It doesn’t have to be like that. Every once and again, ps outruns grep in the race for starting up. It would list the active processes, and no “grep” would appear in the listing. grep would then run, filtering the result of ps, then to be counted by wc — oh, there is only one line now! The script assumes this means mysqld is down (since it assumed grep is always there), and restarts mysqld. So, the script which was supposed to take care of MySQL crashes, was actually causing them (though no crash occurred). Look for the pid file. This is the standard (that’s how the mysql service works). Look for the unix socket file. Both require that you parse the my.cnf file to learn where these files are. If you’re reluctant to read the configuration files, other options are at hand. OK, look for the process; but use pgrep mysqld. No need to list all processes, then grep them. And best way, that will set your mind at ease even if you’re worried that “mysql is running but not responding; it is stuck”: connect to MySQL and issue SELECT 1, SELECT NOW(), SELECT something. This would be the ultimate test that MySQL is up, listening, responding and valid.
090923 17:38:15 mysqld started
090923 17:38:16 InnoDB: Started; log sequence number 0 3707779031
090923 17:38:16 [Note] /usr/local/mysql/bin/mysqld: ready for connections.
Version: '5.0.77-log' socket: '/tmp/mysql50.sock' port: 3306 MySQL Community Server (GPL)
090923 19:53:41 [Note] /usr/local/mysql/bin/mysqld: Normal shutdown
090923 19:53:56 mysqld started
090923 19:53:56 InnoDB: Started; log sequence number 0 5288400927
090923 19:53:56 [Note] /usr/local/mysql/bin/mysqld: ready for connections.
Version: '5.0.77-log' socket: '/tmp/mysql50.sock' port: 3306 MySQL Community Server (GPL)
090929 22:38:48 [Note] /usr/local/mysql/bin/mysqld: Normal shutdown
090923 22:38:58 mysqld started
090923 22:38:58 InnoDB: Started; log sequence number 0 7102832776
090923 22:38:58 [Note] /usr/local/mysql/bin/mysqld: ready for connections.
Version: '5.0.77-log' socket: '/tmp/mysql50.sock' port: 3306 MySQL Community Server (GPL)
...
Looking at the script
while [ 1 ];
if [`ps aux | grep mysqld | wc -l` -lt 2]
then /etc/init.d/mysql restart
...
sleep 60
The less common scenario
Better ways to test that MySQL is alive
发表评论
-
为什么中国出不了扎克伯格
2010-03-12 08:01 1077他们已基本失去成为互 ... -
不会编程的程序员
2010-03-06 12:39 883我想这让人难以置信, ... -
让代码更美:10大编程字体
2010-01-21 13:36 1712日复一日的编写代码, ... -
Everything you need to know about Android 2.0
2009-11-07 21:03 1047Android 2.0 (formerly codenamed ... -
Linux: still better for coding
2009-11-05 08:01 790Something like one year ago I s ... -
Top 10 Programming Fonts
2009-11-01 09:20 1535I’m a typeface geek, and when i ... -
Speed Up and Back Up Your Rooted Android Phone
2009-10-31 15:16 1031If you've rooted your Android p ... -
Five Favorite Web Applications of Designers
2009-10-18 08:36 893Webapps –compared to their des ... -
The Best Programming Language for a Lean Startup
2009-10-18 08:31 1162Think arguments between religio ... -
5 Excuses Bad Programmers Make
2009-10-16 16:51 665It’s a common problem, there’s ... -
How to Create a Twitter Feed on Your Web Site
2009-10-08 08:50 970Twitter has quickly become one ... -
CodeThatDocumentsItselfSoWellItDoesNotNeedComments
2009-10-06 07:56 675“When I first met the lead de ... -
The Evolution of a Programmer
2009-10-06 07:54 663High School/Jr.High 10 PRI ... -
将Web入侵消灭在萌芽之中——预防SQL注入
2009-10-05 08:38 1027国家互联网应急中心CN-S ... -
阿里要走102年 阿里的工程师能走多远?
2009-10-04 08:46 630很高兴看到阿里云的 ... -
支持云应用程序服务的PHP API
2009-10-03 08:14 979自称“PHP公司”的Zend Technologies发起 ... -
Java is dead, but you'll learn to love it
2009-10-02 08:32 1038A favorite hobby-hors ... -
程序员需要知道的97件事
2009-10-02 08:24 1404继架构师需要知道的97件事(参看InfoQ此前的报道)之后,该 ... -
Google Wave: There Will Be Backlash
2009-10-01 08:11 701Have you gotten your Google W ... -
A Letter To The Programmer
2009-09-30 08:25 794This is a letter that I would n ...
相关推荐
mysqld_exporter是Prometheus用于监控MySQL指标的一个导出器,支持对MySQL 5.5以上进行监控。下面是mysqld_exporter的安装与配置: 1、登录MySQL,创建一个账号用于Prometheus监控获取数据 CREATE USER 'exporter'...
mysqld_exporter安装包
mysqld数据库的编码设置,亲测,可用,设置成utf-8编码。
mysqld_exporter安装包mysqld_exporter-0.12.0.linux-amd64.tar.gz
mysql 5.7.x 所需mysqld.service文件
ERROR 1130 (HY000): Host ‘localhost’ is not allowed to connect to this MySQL server www.jb51.net 出现原因: mysql只有一个root用户,修改root密码后选了MD5,提交后,重新 登陆出现“Host ‘localhost’ is...
主要给大家介绍了关于MySQL不停地自动重启的解决方法,文中通过示例代码介绍的非常详细,对大家学习或者使用MySQL具有一定的参考学习价值,需要的朋友们下面来一起学习学习吧
解决没有mysqld.exe -install的问题,下载直接打开可以开启mysql服务,如果不小心删除mysql服务用这个也可以。
prometheus mysql exporter 节点安装 mysqld_exporter-0.12.1.linux-amd64.tar.gz 资源下载
mysqld完全卸载!mysqld完全卸载!mysqld完全卸载!mysqld完全卸载!mysqld完全卸载!
2、用另外一种方式启动Mysql:在命令行进入到mysql的安装路径下的bin目录下使用mysqld-nt.exe启动:mysqld-nt –skip-grant-tables 注意:此时CMD窗口不能关闭。 mysqld-nt.exe文件下载 3、进入Mysql:另外打开一个...
mysqld_exporter-0.14.0.windows-amd64.zip
mysqld_exporter-0.14.0.linux-amd64.tar.gz
用于docker配置mysql数据库需要的配置文件
本文中的配置都是从《MySQL5权威指南(3rd)》中摘抄出来的,个人认为对于使用MySQL十分有用。放在此处方便自己随时查阅,也希望对其他朋友有所助益。
MySQL Server Exporter Build Status CircleCI Docker Repository on Quay Docker Pulls Go Report Card Prometheus exporter for MySQL ...NOTE: Not all collection methods are supported on MySQL/MariaDB < 5.6
NULL 博文链接:https://rdman.iteye.com/blog/1521122
用于python的mysql支持
2016-03-03T00:02:30.483100Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files. 终端不断地重复打印上面的错误日志,从错误日志看起来似乎有...
将character_set_system修改为gbk