{"id":3633,"date":"2018-08-22T15:15:07","date_gmt":"2018-08-22T07:15:07","guid":{"rendered":"https:\/\/dingxuan.info\/wp\/?p=3633"},"modified":"2018-08-22T15:16:20","modified_gmt":"2018-08-22T07:16:20","slug":"%e6%a3%80%e6%b5%8bmysql%e6%98%af%e5%90%a6%e8%bf%90%e8%a1%8c%ef%bc%8c%e5%a6%82%e5%b4%a9%e6%ba%83%e8%87%aa%e5%8a%a8%e9%87%8d%e5%90%af","status":"publish","type":"post","link":"https:\/\/dingxuan.info\/wp\/?p=3633","title":{"rendered":"\u68c0\u6d4bmysql\u662f\u5426\u8fd0\u884c\uff0c\u5982\u5d29\u6e83\u81ea\u52a8\u91cd\u542f"},"content":{"rendered":"<div>\n<div class=\"ennote\">\n<div>\u6700\u597d\u7684\u529e\u6cd5\uff0c\u5f53\u7136\u662f\u4ece\u6839\u6e90\u4e0a\u907f\u514d\u7a0b\u5e8f\u5d29\u6e83\u3002<\/div>\n<div>\u4f46\u662f\u5728\u4e00\u4e2a512M\u5185\u5b58\u7684\u5c0f\u670d\u52a1\u5668\u4e0a\uff0c\u6570\u636e\u5e93\u5d29\u6e83\u8fd8\u662f\u65e0\u6cd5\u5b8c\u5168\u907f\u514d\u3002<\/div>\n<div><\/div>\n<div><span style=\"font-size: 14pt\"><b>\u65b9\u6cd5\u4e00<\/b><\/span><\/div>\n<div>\u505a\u4e2a\u811a\u672c\u3002\u4e0d\u8fc7\u8fd9\u4e2a\u65b9\u6cd5\u6709\u70b9\u7ed5\u8fdc\u4e86\u3002<\/div>\n<div><\/div>\n<div style=\"padding: 8px;font-family: Monaco, Menlo, Consolas, 'Courier New', monospace;font-size: 12px;color: #333333;border-radius: 4px;background-color: #fbfaf8\">\n<div>#!\/bin\/bash<\/div>\n<div>if (( $(ps -ef | grep -v grep | grep mysqld | wc -l) &lt;= 0 ))<\/div>\n<div>then<\/div>\n<div>\u00a0 \u00a0echo &#8220;MySQL is currently not running and will be restarted!&#8221; | mail -s &#8220;MySQL may have crashed&#8221; -r <a href=\"mailto:from@dingxuan.info%C2%A0to\">from@dingxuan.info\u00a0to<\/a>@dingxuan.info<\/div>\n<div>\u00a0 \u00a0service mysqld restart<\/div>\n<div>else<\/div>\n<div>\u00a0 \u00a0echo &#8220;Running&#8221;<\/div>\n<div>fi<\/div>\n<\/div>\n<div><\/div>\n<div>\u52a0\u5165crontab<\/div>\n<div style=\"padding: 8px;font-family: Monaco, Menlo, Consolas, 'Courier New', monospace;font-size: 12px;color: #333333;border-radius: 4px;background-color: #fbfaf8\">\n<div>*\/5 * * * * \/root\/mysql_monitor.sh<\/div>\n<\/div>\n<div><\/div>\n<div><span style=\"font-size: 14pt;font-weight: bold\">\u65b9\u6cd5\u4e8c<\/span><\/div>\n<div>\u6bd4\u524d\u4e00\u79cd\u66f4\u7b80\u6d01\u3002\u9996\u5148\uff0c\u53ef\u4ee5\u6d4b\u8bd5\u4e00\u4e0b\u6570\u636e\u5e93\u8fd0\u884c\u72b6\u6001\u3002mysqld \u6216\u8005mariadb<\/div>\n<div style=\"padding: 8px;font-family: Monaco, Menlo, Consolas, 'Courier New', monospace;font-size: 12px;color: #333333;border-radius: 4px;background-color: #fbfaf8\">\n<div>\/sbin\/service mysqld status<\/div>\n<div>echo $?<\/div>\n<\/div>\n<div><\/div>\n<div>\u5982\u679c\u8fd4\u56de\u503c\u4e0d\u662f0\uff0c\u8bf4\u660e\u8fd0\u884c\u72b6\u6001\u5f02\u5e38\u3002\u6240\u4ee5\u53ef\u4ee5\u7528\u8fd9\u4e2a\u4f5c\u4e3a\u5224\u65ad\u4f9d\u636e\uff0c\u6765\u63a7\u5236\u662f\u5426\u6267\u884c\u542f\u52a8\u547d\u4ee4\u3002<\/div>\n<div><\/div>\n<div style=\"padding: 8px;font-family: Monaco, Menlo, Consolas, 'Courier New', monospace;font-size: 12px;color: #333333;border-radius: 4px;background-color: #fbfaf8\">\n<div>\/sbin\/service mysqld status || service mysqld start<\/div>\n<\/div>\n<div><\/div>\n<div><\/div>\n<div>\u52a0\u5230crontab\u91cc\uff0c\u6bcf\u5206\u949f\u8fd0\u884c\u4e00\u6b21\u3002<\/div>\n<div style=\"padding: 8px;font-family: Monaco, Menlo, Consolas, 'Courier New', monospace;font-size: 12px;color: #333333;border-radius: 4px;background-color: #fbfaf8\">\n<div>* * * * * \/sbin\/service mysqld status || service mysqld start<\/div>\n<\/div>\n<div><\/div>\n<div><\/div>\n<div><span style=\"font-size: 14pt;font-weight: bold\">\u5ef6\u4f38\uff1a\u6d4b\u8bd5apache\u8fd0\u884c\u72b6\u6001<\/span><\/div>\n<div><\/div>\n<div>\u540c\u7406\uff0c\u8981\u6d4b\u8bd5\u5982\u65e0\u6cd5\u8bbf\u95ee\u67d0\u7f51\u5740\uff0c\u5219\u91cd\u542fapache\uff1a<\/div>\n<div><\/div>\n<div style=\"padding: 8px;font-family: Monaco, Menlo, Consolas, 'Courier New', monospace;font-size: 12px;color: #333333;border-radius: 4px;background-color: #fbfaf8\">\n<div>*\/2\u00a0\u00a0\u00a0\u00a0\u00a0*\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0*\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0*\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0*\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0wget -q <a href=\"http:\/\/dingxuan.info\">dingxuan.info<\/a> || service httpd restart<\/div>\n<\/div>\n<div><\/div>\n<\/div>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>\u6700\u597d\u7684\u529e\u6cd5\uff0c\u5f53\u7136\u662f\u4ece\u6839\u6e90\u4e0a\u907f\u514d\u7a0b\u5e8f\u5d29\u6e83\u3002 \u4f46\u662f\u5728\u4e00\u4e2a512M\u5185\u5b58\u7684\u5c0f\u670d\u52a1\u5668\u4e0a\uff0c\u6570\u636e\u5e93\u5d29\u6e83\u8fd8\u662f\u65e0\u6cd5\u5b8c\u5168\u907f\u514d\u3002 \u65b9 &hellip; <a href=\"https:\/\/dingxuan.info\/wp\/?p=3633\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u68c0\u6d4bmysql\u662f\u5426\u8fd0\u884c\uff0c\u5982\u5d29\u6e83\u81ea\u52a8\u91cd\u542f<\/span><\/a><\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[79,127,78],"class_list":["post-3633","post","type-post","status-publish","format-standard","hentry","category-live","tag-centos","tag-email","tag-linux"],"_links":{"self":[{"href":"https:\/\/dingxuan.info\/wp\/index.php?rest_route=\/wp\/v2\/posts\/3633","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dingxuan.info\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dingxuan.info\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dingxuan.info\/wp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dingxuan.info\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3633"}],"version-history":[{"count":0,"href":"https:\/\/dingxuan.info\/wp\/index.php?rest_route=\/wp\/v2\/posts\/3633\/revisions"}],"wp:attachment":[{"href":"https:\/\/dingxuan.info\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3633"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dingxuan.info\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3633"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dingxuan.info\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3633"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}