[trouble shooting] mysqlhotcopy 报错 Can't locate Data/Dumper.pm in @INC

问题

我想要用mysql的一个工具

[root@localhost bin]# ./mysqlhotcopy 
Can't locate Data/Dumper.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 
/usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at ./mysqlhotcopy line 22.
BEGIN failed--compilation aborted at ./mysqlhotcopy line 22.

google的结果是下载一个软件

yum是从固定配置好的”软件仓库reposity“下载软件

wget是从具体某个网址下载软件,详细参考官网:GUN wget

第一反应是用yum来下载wget这个工具

yum install wget

接着用wget下载需要的工具

[root@localhost bin]# wget http://www.cpan.org/modules/by-module/Data/Data-Dumper-2.121.tar.gz
--2016-01-07 17:05:06--  http://www.cpan.org/modules/by-module/Data/Data-Dumper-2.121.tar.gz
Resolving www.cpan.org (www.cpan.org)... 94.242.223.198
Connecting to www.cpan.org (www.cpan.org)|94.242.223.198|:80... connected.
HTTP request sent, awaiting response... 404 Not Found
2016-01-07 17:05:09 ERROR 404: Not Found.

发现没有找到想要的 ”Data-Dumper-2.121.tar.gz",亲自上去 “http://www.cpan.org/modules/by-module/Data/” 看看

原来名字已经更换了,重新下载就好了

[root@localhost bin]# wget http://www.cpan.org/modules/by-module/Data/Data-Dumper-2.154.tar.gz
--2016-01-07 17:09:15--  http://www.cpan.org/modules/by-module/Data/Data-Dumper-2.154.tar.gz
Resolving www.cpan.org (www.cpan.org)... 94.242.223.198, 2607:f238:3::91:1
Connecting to www.cpan.org (www.cpan.org)|94.242.223.198|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 100369 (98K) [application/x-gzip]
Saving to: ‘Data-Dumper-2.154.tar.gz.1’

100%[======================================================>] 100,369     25.4KB/s   in 3.9s   

2016-01-07 17:09:20 (25.4 KB/s) - ‘Data-Dumper-2.154.tar.gz’ saved [100369/100369]

下载的目录就是现在的目录

[root@localhost bin]# ls 
Data-Dumper-2.154.tar.gz  mysql_client_test_embedded  mysql_setpermission
innochecksum              mysql_config                mysqlshow
msql2mysql                mysql_convert_table_format  mysqlslap
myisamchk                 mysqld                      mysqltest
myisam_ftdump             mysqld-debug                mysqltest_embedded
myisamlog                 mysqld_multi                mysql_tzinfo_to_sql
myisampack                mysqld_safe                 mysql_upgrade
my_print_defaults         mysqldump                   mysql_waitpid
mysql                     mysqldumpslow               mysql_zap
mysqlaccess               mysql_embedded              perror
mysqlaccess.conf          mysql_find_rows             person.txt
mysqladmin                mysql_fix_extensions        replace
mysqlbinlog               mysqlhotcopy                resolveip
mysqlbug                  mysqlimport                 resolve_stack_dump
mysqlcheck                mysql_plugin
mysql_client_test         mysql_secure_installation

迁移到“默认的软件安装目录”

mv Data-Dumper-2.154.tar.gz /usr/local

把压缩包解开

tar xzvf Data-Dumper-2.154.tar.gz

接着开始编译安装了

[root@localhost Data-Dumper-2.154]# ls -l
total 308
-rw-r--r--. 1 lijunda lijunda   9612 Sep 18  2014 Changes
-rw-r--r--. 1 lijunda lijunda  44069 Sep 18  2014 Dumper.pm
-rw-r--r--. 1 lijunda lijunda  42804 Sep 18  2014 Dumper.xs
-rw-r--r--. 1 lijunda lijunda    740 Mar 15  2013 Makefile.PL
-rw-r--r--. 1 lijunda lijunda    501 Sep 18  2014 MANIFEST
-rw-r--r--. 1 lijunda lijunda    418 Mar 15  2013 MANIFEST.SKIP
-rw-r--r--. 1 lijunda lijunda    679 Sep 18  2014 META.yml
-rw-r--r--. 1 lijunda lijunda 187394 Mar  7  2014 ppport.h
drwxr-xr-x. 3 lijunda lijunda   4096 Sep 18  2014 t
-rw-r--r--. 1 lijunda lijunda    768 Dec 19  2011 Todo
[root@localhost Data-Dumper-2.154]# 
[root@localhost Data-Dumper-2.154]# 
[root@localhost Data-Dumper-2.154]# perl Makefile.PL 
Can't locate ExtUtils/MakeMaker.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at Makefile.PL line 2.
BEGIN failed--compilation aborted at Makefile.PL line 2.
[root@localhost Data-Dumper-2.154]# 

报出一个新的错误,google查了一下,原因是缺乏perl-devel 这个软件

[root@localhost Data-Dumper-2.154]# yum info perl-devel;
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.pubyun.com
 * epel: mirror01.idc.hinet.net
 * extras: mirrors.pubyun.com
 * updates: mirrors.163.com
Available Packages
Name        : perl-devel
Arch        : i686
Epoch       : 4
Version     : 5.16.3
Release     : 286.el7
Size        : 452 k
Repo        : base/7/x86_64
Summary     : Header #files for use in perl development
URL         : http://www.perl.org/
License     : GPL+ or Artistic
Description : This package contains header files and development modules.
            : Most perl packages will need to install perl-devel to build.

Name        : perl-devel
Arch        : x86_64
Epoch       : 4
Version     : 5.16.3
Release     : 286.el7
Size        : 452 k
Repo        : base/7/x86_64
Summary     : Header #files for use in perl development
URL         : http://www.perl.org/
License     : GPL+ or Artistic
Description : This package contains header files and development modules.
            : Most perl packages will need to install perl-devel to build.

顺利成章的安装一下,安装的过程中,有很多的依赖包自动处理了,难以想象如果一个一个手动安装的话得多累

Install  1 Package (+9 Dependent packages)

Total download size: 1.4 M
Installed size: 4.0 M
Is this ok [y/d/N]: y
Downloading packages:
(1/10): gdbm-devel-1.10-8.el7.x86_64.rpm                                 |  47 kB  00:00:00     
(2/10): perl-ExtUtils-Manifest-1.61-244.el7.noarch.rpm                   |  31 kB  00:00:00     
(3/10): perl-ExtUtils-Install-1.58-286.el7.noarch.rpm                    |  73 kB  00:00:00     
(4/10): libdb-devel-5.3.21-19.el7.x86_64.rpm                             |  38 kB  00:00:00     
(5/10): perl-ExtUtils-ParseXS-3.18-2.el7.noarch.rpm                      |  77 kB  00:00:00     
(6/10): perl-Test-Harness-3.28-3.el7.noarch.rpm                          | 302 kB  00:00:00     
(7/10): perl-ExtUtils-MakeMaker-6.68-3.el7.noarch.rpm                    | 275 kB  00:00:01     
(8/10): pyparsing-1.5.6-9.el7.noarch.rpm                                 |  94 kB  00:00:00     
(9/10): systemtap-sdt-devel-2.8-10.el7.x86_64.rpm                        |  65 kB  00:00:00     
(10/10): perl-devel-5.16.3-286.el7.x86_64.rpm                            | 452 kB  00:00:00  

再来一次编译

[root@localhost Data-Dumper-2.154]# perl Makefile.PL 
Checking if your kit is complete...
Looks good
Warning: prerequisite Test::More 0.98 not found.
Writing Makefile for Data::Dumper

接下来是

make
make install

大概就安装完了

 

重新调用  mysqlhotcopy

[root@localhost bin]# ./mysqlhotcopy 
Can't locate DBI.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at ./mysqlhotcopy line 25.
BEGIN failed--compilation aborted at ./mysqlhotcopy line 25.

再次google一下,需要安装两个软件

perl-DBD-mysql

perl-DBI

如果要使用Yum的方式安装这两个包的话,就需要配置一个“拥有这两个软件”的软件仓库,详细参考:Yum install perl-DBD-mysql, perl-DBI to use "mysqlreport" under CentOS 5.2 + DirectAdmin

vi /etc/yum.repos.d/dag.repo

[dag]
name=Dag RPM Repository for Red Hat Enterprise Linux
baseurl=http://apt.sw.be/redhat/el$releasever/en/$basearch/dag
gpgcheck=1
gpgkey=http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
enabled=1

配置完以后就可以yum了

yum install perl-DBD-mysql perl-DBI

安装完以后,mysqlhotcopy可以使用了

[root@localhost bin]# ./mysqlhotcopy
Database name to hotcopy not specified
./mysqlhotcopy Ver 1.23

Usage: ./mysqlhotcopy db_name[./table_regex/] [new_db_name | directory]

  -?, --help           display this help-screen and exit
  -u, --user=#         user for database login if not current user
  -p, --password=#     password to use when connecting to server (if not set
                       in my.cnf, which is recommended)
  -h, --host=#         hostname for local server when connecting over TCP/IP
  -P, --port=#         port to use when connecting to local server with TCP/IP
  -S, --socket=#       socket to use when connecting to local server
      --old_server     connect to old MySQL-server (before v5.5) which
                       doesn't have FLUSH TABLES WITH READ LOCK fully implemented.

  --allowold           don't abort if target dir already exists (rename it _old)
  --addtodest          don't rename target dir if it exists, just add files to it
  --keepold            don't delete previous (now renamed) target when done
  --noindices          don't include full index files in copy
  --method=#           method for copy (only "cp" currently supported)

看起来是可以使用了,但当真正要备份数据库时,还是出现一个错误

[root@localhost bin]# ./mysqlhotcopy mysql /windows10/000000000000000/
install_driver(mysql) failed: Can't load '/usr/lib64/perl5/vendor_perl/auto/DBD/mysql/mysql.so' for module DBD::mysql: libmysqlclient.so.18: cannot open shared object file: No such file or directory at /usr/lib64/perl5/DynaLoader.pm line 190.
 at (eval 11) line 3.
Compilation failed in require at (eval 11) line 3.
Perhaps a required shared library or dll isn't installed where expected
 at ./mysqlhotcopy line 197.

 

这里有安装手册:http://cpansearch.perl.org/src/JWIED/DBD-mysql-2.1017/INSTALL.html#name

未完待续。。。。。

 

posted @ 2016-01-07 17:39  lawrence.li  阅读(6016)  评论(0编辑  收藏  举报