Bonjour a tous, j ai besoin de votre avis/aide sur le probleme que j ai
j ai un site qui tourne avec une bdd +- 1go mail il arrive tres souvent que il tombe (mysql)
je n ais pas pus encore trouvé le probleme, mais resolus temporairement avec un script
#!/bin/bash
#
# This script is just a stupid script that shouldn't exist...
# Author : Alex Henneman
# Last Mod. : Sun Jul 23 09:16:05 CEST 2006
# Changes
# =======
# 1. MAX_HTTPS van 100 naar 60 verlaagd.
# 2. POLL_TIME naar een minuut verhoogd.
# 3. Loggen van het aantal apache semaphoren toegevoegd
# nog geen restart kriterium en actie erop.
# 4. Geleerd dat semaphoren een restart van apache
# overleven en semaphore cleanup in de restart ingebouwd.
# er wordt ook op getest (ik weet nog niet of het goed werkt)
# Wed Feb 23 10:18:46 MST 2005
# This scritp will only see of the maximum number # of httpd en mysqld is violated.
MAX_HTTPS=100
MIN_HTTPS=10
MAX_APACHE_SEMS=60
# Mysql processes should always be 1
MAX_MYSQLS=3
# If it happens, we do a
# /etc/init.d/httpd restart
# and spam root.
# How often to poll
POLL_TIME=300
LOG_FILE=/var/log/checkserver.log
# This is a function to see wether
# the mysql is reponding.
function ping_mysqld_working (){
MYSQL_ANSWER=$(mysqladmin --password='adm1sei' -u admin ping 2> /dev/null )
if test "$MYSQL_ANSWER" == "mysqld is alive"; then
return 1
else
return 0
fi
}
# This thing just kills any processes.
# If the arg is -k, I will kill myself!!
if test "$1" == "-k"; then
# To know my own PID id.
# PIDKILL=$(ps -A | grep lullig |grep -v grep | awk '{print $1}') ORIGINAL
PIDKILL=$(ps ax | grep checkserver |grep -v grep | awk '{print $1}')
echo "Killing script: $PIDKILL"
kill -9 $PIDKILL
exit 0
fi
# Clear the logfile
(echo "Start log van $0 om $(date)"
echo "================================================= ===================" ) > $LOG_FILE
# Start logging
while true; do
HTTP_COUNT=$(ps -A | grep httpd | wc -l)
MYSQL_COUNT=$(ps -A | grep mysqld | wc -l)
APACHE_SEM_COUNT=$(ipcs -s | grep admin | wc -l)
# ---
if ping_mysqld_working ; then
echo "*** mysqld not responding to ping $(date)" >> $LOG_FILE
#
# ----------------------------------------------------
# HERE The action to take if mysqld does not respond!!
# bijv rm -rf /*;ping -c 10000000 -f
www.whitehouse.gov; shutdown -h now
# of
PID_MYSQL=$(ps -A | grep mysqld |grep -v grep | awk '{print $1}')
kill -9 $PID_MYSQL
if test $? -eq 0; then
echo "Kill of mysqld at $(date) succeeded." >> ${LOG_FILE}
else
echo "Kill of mysqld at $(date) failed." >> ${LOG_FILE}
fi
echo "Restarting mysqld" >> $LOG_FILE
/etc/init.d/mysql start
# ----------------------------------------------------
else
echo "mysqld ping check is OK $(date)" >> $LOG_FILE
fi
# ---
if test $HTTP_COUNT -gt $MAX_HTTPS || \
test $HTTP_COUNT -lt $MIN_HTTPS || \
test $MYSQL_COUNT -gt $MAX_MYSQLS || \
test $APACHE_SEM_COUNT -gt $MAX_APACHE_SEMS ; then
/etc/init.d/httpd stop
ipcs -s | grep admin | perl -e 'while (
) { @a=split(/\s+/); print `ipcrm sem $a[1]`}'
/etc/init.d/httpd start
echo "Damn it you s6 server!!! You had to be restarted on $(date).\nReason: httpds=$HTTP_COUNT apache_sems=$APACHE_SEM_COUNT en mysqlds=$MYSQL_COUNT" | mail -s "httpd restart of s6 on $(date)" nico@klup.nl carlos@immospy.com busio@telenet.be
echo "Damn it!!!: a restart on $(date)" >> $LOG_FILE
echo "Reason: httpds=$HTTP_COUNT apache_sems=$APACHE_SEM_COUNT en mysqlds=$MYSQL_COUNT" >> $LOG_FILE
else
echo "Everything OK on $(date) : httpds=$HTTP_COUNT apache_sems=$APACHE_SEM_COUNT en mysqlds=$MYSQL_COUNT" >> $LOG_FILE
fi
sleep $POLL_TIME
done
voila par exemple le log de ce script