将mysqlhotcopy用起来
这篇文章其实满简单,只是我自己的使用心得.其实更主要的目的是列出了一些在linux下调试安装程序的一些基本排错方法.经常看见某某碰到问题就立刻找高手求救.其实有很多问题都是很简单也很普遍的.稍微baidu一下就可以找到答案.我自己也是新手,也常常有这样的冲动,但是时间长了就发现其实这样”一碰到问题向高手求救”的效果并不好,一则高手很少,并且多很忙,不一定有时间来解答,二则高手告诉了你方法估计解决了眼前的问题也很难告诉你为什么这么做.正所谓受人以渔才是正道.有一条原则,求人不如求己,readme,install,--help,man,以及官方的doc都是最好的老师,对了还有baidu和google.在这些都用过以后还找不到答案的话再来找高手,我看高手也是这样慢慢练成的把.(当然如果时间很紧,没时间看doc的话,也只能想立刻蹦出个高手来救自己了.祝福我和大家都能及时得到高手指点哈)
此文参考了[url]http://www.neo.com.tw/archives/000136.html[/url]
mysqlhotcopy是perl语言写的备份脚本,作为命令安装在mysql的bin目录下.
与mysqldump将数据库导成sql文件不同,他的机制是copy数据库文件
官方说明如下
mysqlhotcopy is a Perl script that was originally written and contributed by Tim Bunce. It uses LOCK TABLES, FLUSH TABLES, and cp or scp to make a database backup quickly. It is the fastest way to make a backup of the database or single tables, but it can be run only on the same machine where the database directories are located. mysqlhotcopy works only for backing up MyISAM and ARCHIVE tables.
我的mysql是源码安装的,安装路径为/usr/local/mysql,执行时报错
# /usr/local/mysql/bin/mysqlhotcopy –u root –p 密码 数据库名 备份目录
Can't locate DBI.pm in @INC (@INC contains: /usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0 /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl5/vendor_perl /usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0 .) at /usr/local/mysql/bin/mysqlhotcopy line 8.
BEGIN failed--compilation aborted at /usr/local/mysql/bin/mysqlhotcopy line 8.
按照出错信息查看/usr/local/mysql/bin/mysqlhotcopy的第8行,内容如下
use DBI;
通过网上说明需要安装DBD-mysql-2.9007.tar.gz
生成makefile文件
# perl Makefile.PL
Can't locate DBI/DBD.pm in @INC (@INC contains: /usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0 /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl5/vendor_perl /usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0 .) at Makefile.PL line 24.
查看Makefile.PL 第24行,内容如下
require DBI::DBD;
安装DBI和DBD,所需要的包如下:
perl-DBD-Pg-1.21-2
perl-DBI-1.32-5(这个先装)
执行
rpm -ivh perl-DBI-1.32-5.i386.rpm
rpm -ivh perl-DBD-Pg-1.21-2.i386.rpm
生成makefile文件
# perl Makefile.PL
产生信息如下
I will use the following settings for compiling and testing:
cflags (mysql_config) = -I/usr/local/mysql/include
libs (mysql_config) = -L/usr/local/mysql/lib -lmysqlclient -lz -lcrypt -lnsl -lm
mysql_config (guessed ) = mysql_config
nocatchstderr (default ) = 0
nofoundrows (default ) = 0
ssl (guessed ) = 0
testdb (default ) = test
testhost (default ) =
testpassword (default ) =
testsocket (default ) =
testuser (default ) =
To change these settings, see 'perl Makefile.PL --help' and
'perldoc INSTALL'.
Checking if your kit is complete...
Looks good
Using DBI 1.32 installed in /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi/auto/DBI
Writing Makefile for DBD::mysql
编译安装
make
make test //这一步只是测试,有小错误也没关系
make install
执行备份
# /usr/local/mysql/bin/mysqlhotcopy –u root –p 密码 数据库名 备份目录
©著作权归作者所有:来自51CTO博客作者yahoon的原创作品,如需转载,请注明出处,否则将追究法律责任
备份mysql数据库mysql
共同学习,写下你的评论
评论加载中...
作者其他优质文章