Files
svc.ems/bin/chkDb
2024-10-22 10:26:32 +08:00

42 lines
977 B
Bash

#!/bin/sh
# chkconfig: 2345 89 05
# description: as following
# For OMC to fix table
# Comments to support chkconfig on RedHat Linux
if [ `uname -r |grep -c '2.4.7-10'` -eq 1 ] ; then
dataDir="/usr/local/mysql/data"
mysqlBinDir="/usr/local/mysql/bin"
else
dataDir="/var/lib/mysql"
mysqlBinDir="/usr/bin/"
fi
confDir=/usr/local/omc/bin/conf
mode=$1
case "$mode" in
start)
if [ `grep -c "dbStopMode=1" $confDir/chkDb.conf` -eq 0 ] ; then
cd $mysqlBinDir
chown -R mysql:mysql $dataDir/*
./myisamchk -r -f -O sort_buffer_size=32M $dataDir/*/*.MYI
else
echo "It needn't to check database. "
echo "If you want to check database forcibly,please use \"$0 force\" "
fi
echo "dbStopMode=0" > $confDir/chkDb.conf
;;
force)
cd $mysqlBinDir
./myisamchk -r -f -O sort_buffer_size=32M $dataDir/*/*.MYI
;;
stop)
echo "dbStopMode=1" > $confDir/chkDb.conf
;;
*)
echo "Check and fix all database file"
echo "Usage: $0 start|force"
;;
esac