使用shell检查并修复mysql数据库表的脚本
#!/bin/sh
#code by scpman
#功能:检查并修复mysql数据库表
#将此脚本加到定时中,脚本执行时,等会读库,列出要修复的所有表,然后计时,开始修复
#修复过程中将损坏的表记录下来,修复完成后,将损坏的表,发邮件通知。
fix_logs='/tmp/fix.log'
user=''
pass=''
check_fix()
{
dblist=`/usr/bin/find /usr/dlm_db/mysql/ -type d | grep -vE "logs|_[1-9]|*bak|test"| sed -e "s#/usr/dlm_db/mysql/##g"`
echo start `date`>$fix_logs
for dbname in $dblist
do
echo $dbname
for tb_name in `/usr/bin/find /usr/dlm_db/mysql/$dbname -type f | awk -F'/' '{print $NF}' | awk -F'.' '{print $1}' | sort -
u`
do
mysql -u$user -p$pass $dbname<<fff>>$fix_logs
check table $tb_name;
repair table $tb_name;
FFF
done
done
echo `date` done>>$fix_logs
}
send_logs()
{
msgip=10.0.7.44
IP=`cat /etc/rc.conf | grep -E "ifconfig_[em1|bce1]" | awk '{print "IP:"$2}'| sed -n 1p `
fix_info=`grep -rE "Error|start|done" $fix_logs`
/usr/bin/logger -p local1.info -h $msgip "the services: $IP mysql_table_fix_info:$fix_info"
}
check_fix
send_logs
shell使用mysqld_multi自动做多实例从库脚本
#catdoallslave.sh#!/bin/sh#codebyscpman#mail:scpman@live.com#blog:http://www.scpman.com#name:"doallslave.sh"helpinfo(){echo-e'tthelp查看帮助信息'echo-e'tt自动做allslave从库脚本使用
shell对比文件内容脚本分享
#!/bin/shfunction_diffab(){x=0foriin`cat$1`;doforjin`cat$2`;doif[$i==$j];thenx=1break;fidoneif[$x-ne1];thenecho$ifix=0done}if["$1"==""]||["$2"==""];thenecho"uselikethis:$0fileafileb"else{_diffab$1$2_d
shell脚本操作oracle删除表空间、创建表空间、删除用户
oracle下表空间的导出,用户的删除,表空间删除,用户新建,表空间新建,数据导入的shell使用非oracle用户执行该脚本参数说名$1:base表空间的用户名$2