Script to kill mysql when connections increase
===========
If more mysql connections are causing high load, here is a script to restrict the mysql connections.
#!/bin/bash
a=`mysqladmin extended-status |grep Max_used_connections |cut -d"|" -f3`
if [ $a -ge 60 ]
then
pkill -9 mysqld
pkill -9 mysqld
/etc/init.d/mysql start
fi
By this script if the mysql connections exceeds 60, it kills current mysql connections and then restarts mysql. You can also set this script as a cron as below:
*/5 * * * * sh /root/mysqlrestart.sh >/dev/null 2>&1
===========
If more mysql connections are causing high load, here is a script to restrict the mysql connections.
#!/bin/bash
a=`mysqladmin extended-status |grep Max_used_connections |cut -d"|" -f3`
if [ $a -ge 60 ]
then
pkill -9 mysqld
pkill -9 mysqld
/etc/init.d/mysql start
fi
By this script if the mysql connections exceeds 60, it kills current mysql connections and then restarts mysql. You can also set this script as a cron as below:
*/5 * * * * sh /root/mysqlrestart.sh >/dev/null 2>&1
No comments:
Post a Comment
Note: only a member of this blog may post a comment.