| 订阅 | 在线投稿
分享
 
 
 

带你轻松接触一个检测MySQL状态的脚本

来源:互联网  宽屏版  评论
2008-06-01 02:13:22

本文为【带你轻松接触一个检测MySQL状态的脚本】的汉字拼音对照版显示拼音

xiamiandezhegejiaobenyongdaolenampsaomiaogongju,suoyi,xitongzhongruguomeianzhuangnmapsaomiaogongjude,xuyaoxiananzhuanggaigongju

jiaobendegongneng:

shouxian,jiancemysqlduankoushifouzhengchangcunzai,duankoubucunzaijiuzhixingqidongmysqlfuwu,dangran,qidongdejiaobendeweizhigenjunideanzhuanglujinghuiyoubutong,ranhouruguoduankoucunzai,zeyoumysqlfuwuzaiyunxing,namejiancemysqlzhuangtai,nengbunengzhengchanglianjie,runengzhengchanglianjieshuomingmysqlzhengchang,buzuorenhechuli,ruguobunengzhengchanglianjie,zeshadiaosuoyoumysqljincheng,ranhouqidongmysqlfuwu,weishenmeyaoshadiaojinchengerbujinxingzhengchangdechongqine,shiyinweiyoushihoumysqlshibunengzhengchangguanbide,suoyibunengzhengchangchongqi,suoyibaoxiandezuofashishadiaojincheng,ranhouqidongfuwu

#!/bin/bash

/usr/bin/nmap localhost |grep 3306

if [ $? -eq 0 ]

then

/usr/local/mysql/bin/mysql -uxxxxx -pxxxxxx --connect_timeout=5 -e "show databases;"

if [ $? -ne 0 ]

then

/bin/ps aux |grep mysql |grep -v grep | awk '{print $2}' | xargs kill -9

/usr/local/mysql/bin/mysqld_safe --user=mysql & > /dev/null

fi

else

/usr/local/mysql/bin/mysqld_safe --user=mysql & > /dev/null

fi

原文
 
下面的这个脚本用到了namp扫描工具,所以,系统中如果没安装nmap扫描工具的,需要先安装该工具。 脚本的功能: 首先,检测mysql端口是否正常存在,端口不存在就执行启动mysql服务,当然,启动的脚本的位置根据你的安装路径会有不同,然后如果端口存在,则有mysql服务在运行,那么检测mysql状态,能不能正常连接,如能正常连接说明mysql正常,不做任何处理,如果不能正常连接,则杀掉所有mysql进程,然后启动mysql服务,为什么要杀掉进程而不进行正常的重起呢,是因为有时候mysql是不能正常关闭的,所以不能正常重起,所以保险的做法是杀掉进程,然后启动服务。( #!/bin/bash /usr/bin/nmap localhost |grep 3306 if [ $? -eq 0 ] then /usr/local/mysql/bin/mysql -uxxxxx -pxxxxxx --connect_timeout=5 -e "show databases;" if [ $? -ne 0 ] then /bin/ps aux |grep mysql |grep -v grep | awk '{print $2}' | xargs kill -9 /usr/local/mysql/bin/mysqld_safe --user=mysql & > /dev/null fi else /usr/local/mysql/bin/mysqld_safe --user=mysql & > /dev/null fi
󰈣󰈤
 
 
 
>>返回首页<<
 
 热帖排行
 
 
 
静静地坐在废墟上,四周的荒凉一望无际,忽然觉得,凄凉也很美
©2005- 王朝网络 版权所有