MySQL faulty restart: Skirtumas tarp puslapio versijų

Iš Žinynas.
Jump to navigation Jump to search
 
(Jokio skirtumo)

Dabartinė 14:32, 6 sausio 2018 versija

Kai niekas nebepadeda, tuomet padeda šis scriptas. AutoStart/Recovery etc...

#!/bin/bash
PROC="mysqld"
COMD="/etc/init.d/mysqld start"
MAIL="justinas@eofnet.lt"
LOG="/var/log/check_mysql.log"
echo -n "Checking if mysql service is running.. "
if [[ -z $(ps -ef |grep -v grep |grep $PROC) ]]
then 
   echo "[Dead]"
   echo "Restarting..."
   killall -9 mysqld
   echo "`date` - $PROC neveikia, restartuojame" >> $LOG
   sed -i '/innodb_force_recovery/s/^#//g' /etc/my.cnf
   $COMD
   sed -i '/innodb_force_recovery/s/^/#/g' /etc/my.cnf 
   [ $?  -eq "0" ] && echo "Process $COMD restart complete!" || echo "`hostname` - process - $PROC - unable to sart" | mail -n -s "Server status `hostname`" $MAIL && echo "`date` - Perkrovimas $PROC nepavyko" >> $LOG
   mysqlcheck -A --auto-repair
else
   echo "[Running]"
   if tail -n1 /var/log/mysqld.log |grep -q "is marked as crashed and should be repaired"; then mysqlcheck -A --auto-repair&& echo "Fix to mysql applied" >> /var/log/mysqld.log; else echo "Log file seems to be ok"; fi
fi