首先系统的perl包和DBD/DBI一定要全,并且版本要对应好,不然调用Mysqlhotcopy很容易出错。特别有名的错误就是:Can't locate DBI.pm in @INC另外要注意,OS和mys
首先系统的perl包和DBD/DBI一定要全,并且版本要对应好,不然调用Mysqlhotcopy很容易出错。特别有名的错误就是:
Can't locate DBI.pm in @INC
另外要注意,OS和mysql的位数要一致,否则Mysqlhotcopy调用perl时会发生错误。
[@more@]以mysql 4.0.27为例,DBI我们选用DBI-1.53,DBD则为DBD-mysql-3.0008
将2个包上传到服务器,用yum直接安装也可以,但是有的情况下版本对应会出现错误导致hotcopy不可用。
tar zxvf DBI.tar.gz
cd DBI-1.53
perl Makefile.PL
make
make test
make install
tar zxvf DBD-mysql-3.0008.tar.gz
cd DBD-mysql-3.0008
perl Makefile.PL --mysql_config=/usr/local/mysql/bin/mysql_config
make
make test
make install
结束了安装就可以测试拉
下面是备份脚本:
#!/bin/bash
#
# Use mysqlhotcopy backup mysql database
#
cmd='/usr/local/mysql/bin/mysqlhotcopy -q'
BackupPatch='/usr/backup/data'
logfile='/usr/backup/data/backup.log'
DBNAME=`ls -l /usr/local/mysql/data/ | grep '^d' | awk '{print $9}'`
error (){
case "${1}" in
1)
echo "mysqlhotcoyp error"
exit 1
;;
2)
exit 2
;;
*)
useage
;;
esac
}
do_check(){
for loop in $DBNAME
do
[ -d $loop ]&& rm -rf $BackupPatch/$loop
done
}
do_backup (){
$cmd $DBNAME $BackupPatch 2>>$logfile||{ date >>$logfile;error 1; }
}
do_compress (){
cd $BackupPatch
ts=`date +%Y%m%d`
fname=db.$ts.tgz
[ -f $fname ]&& rm $BackupPatch/$fname
tar czvf $fname $DBNAME
}
check_3 (){
num=`ls *.tgz|wc -l`
if [ $num -gt 3 ];then
do_delold
check_3
fi
}
do_delold () {
old=`ls *.tgz|sort|head -n 1`
rm -f $BackupPatch/$old
}
### Main###
cd $BackupPatch
echo "--------backup start at $(date +"%y-%m-%d %H:%M:%S")----------" >> $logfile
do_check
do_backup
do_compress
check_3
do_check
chown -R backup.backup $BackupPatch/
echo "--------backup finish at $(date +"%y-%m-%d %H:%M:%S")--------" >> $logfile
exit 0
备份完可以使用md5sum来生成校验码,作用是一旦需要进行远程备份传递,可以进行校验
--结束END--
本文标题: 使用mysqlhotcopy
本文链接: https://lsjlt.com/news/49639.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-10-23
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0