percona-toolkit执行时遇到install_driver(mysql) failed: Attempt to reload DBD/mysql.pm aborted错误



执行pt-table-checksum报错如下:
[root@db ~]# pt-table-checksum S=/data/mysql/mysqldata3306/sock/mysql.sock,h=localhost
11-01T17:07:02 install_driver(mysql) failed: Attempt to reload DBD/mysql.pm aborted.
Compilation failed in require at (eval 14) line 3.

 at /usr/local/bin/pt-table-checksum line 1623


而主机上已经安装了相应的软件包:
[root@db ~]# rpm -qa | grep -i mysql
perl-DBD-MySQL-4.013-3.el6.x86_64
mysql-libs-5.1.73-8.el6_8.x86_64

[root@db ~]# rpm -qa | grep -i perl
perl-Pod-Escapes-1.04-144.el6.x86_64
perl-version-0.77-144.el6.x86_64
perl-ExtUtils-ParseXS-2.2003.0-144.el6.x86_64
perl-Time-HiRes-1.9721-144.el6.x86_64
perl-libs-5.10.1-144.el6.x86_64
perl-Pod-Simple-3.13-144.el6.x86_64
perl-5.10.1-144.el6.x86_64
perl-ExtUtils-MakeMaker-6.55-144.el6.x86_64
perl-devel-5.10.1-144.el6.x86_64
perl-DBI-1.609-4.el6.x86_64
perl-DBD-MySQL-4.013-3.el6.x86_64
perl-Module-Pluggable-3.90-144.el6.x86_64
perl-Test-Harness-3.17-144.el6.x86_64


发现系统没有加载mysql的动态链接库:
[root@db ~]# ldconfig -p | grep mysql

那就添加一下:
[root@db ~]# echo '/usr/local/mysql/lib' > /etc/ld.so.conf.d/mysql.conf
[root@db ~]# ldconfig
[root@db ~]# ldconfig -p | grep mysql
    libmysqlclient.so.20 (libc6,x86-64) => /usr/local/mysql/lib/libmysqlclient.so.20


再次执行pt-table-checksum仍然报错:
[root@db ~]# pt-table-checksum S=/data/mysql/mysqldata3306/sock/mysql.sock,h=localhost
11-01T17:07:02 install_driver(mysql) failed: Attempt to reload DBD/mysql.pm aborted.
Compilation failed in require at (eval 14) line 3.

 at /usr/local/bin/pt-table-checksum line 1623


参考 https://zhjxue.wordpress.com/2016/10/08/perl-install_drivermysql-failed-failed-attempt-to-reload-dbdmysql-pm-aborted-issue-and-how-to-fix/  这里的说明后,我也试着找了下 mysql.so ,果然找到了。
[root@db ~]# locate mysql.so
/data/mysql/mysqldata3306/sock/mysql.sock
/data/mysql/mysqldata3306/sock/mysql.sock.lock
/usr/lib64/perl5/auto/DBD/mysql/mysql.so


也确实没有找到 mysql的动态链接库:
[root@db ~]# ldd /usr/lib64/perl5/auto/DBD/mysql/mysql.so
    linux-vdso.so.1 =>  (0x00007ffecb770000)
    libmysqlclient.so.16 => not found
    libz.so.1 => /lib64/libz.so.1 (0x00007f3be2321000)
    libcrypt.so.1 => /lib64/libcrypt.so.1 (0x00007f3be20ea000)
    libnsl.so.1 => /lib64/libnsl.so.1 (0x00007f3be1ed1000)
    libm.so.6 => /lib64/libm.so.6 (0x00007f3be1c4c000)
    libssl.so.10 => /usr/lib64/libssl.so.10 (0x00007f3be19e0000)
    libcrypto.so.10 => /usr/lib64/libcrypto.so.10 (0x00007f3be15fb000)
    libc.so.6 => /lib64/libc.so.6 (0x00007f3be1266000)
    libfreebl3.so => /lib64/libfreebl3.so (0x00007f3be1063000)
    libgssapi_krb5.so.2 => /lib64/libgssapi_krb5.so.2 (0x00007f3be0e1f000)
    libkrb5.so.3 => /lib64/libkrb5.so.3 (0x00007f3be0b37000)
    libcom_err.so.2 => /lib64/libcom_err.so.2 (0x00007f3be0933000)
    libk5crypto.so.3 => /lib64/libk5crypto.so.3 (0x00007f3be0707000)
    libdl.so.2 => /lib64/libdl.so.2 (0x00007f3be0502000)
    /lib64/ld-linux-x86-64.so.2 (0x000055b6337e9000)
    libkrb5support.so.0 => /lib64/libkrb5support.so.0 (0x00007f3be02f7000)
    libkeyutils.so.1 => /lib64/libkeyutils.so.1 (0x00007f3be00f4000)
    libresolv.so.2 => /lib64/libresolv.so.2 (0x00007f3bdfed9000)
    libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f3bdfcbc000)
    libselinux.so.1 => /lib64/libselinux.so.1 (0x00007f3bdfa9c000)


那就重新安装一下这个软件包,先找一下这个文件是属于哪个软件包的:
[root@db ~]# rpm -qf /usr/lib64/perl5/auto/DBD/mysql/mysql.so
perl-DBD-MySQL-4.013-3.el6.x86_64
[root@db lib]# yum install perl-DBD-MySQL
Loaded plugins: fastestmirror
Setting up Install Process
Loading mirror speeds from cached hostfile
Package perl-DBD-MySQL-4.013-3.el6.x86_64 already installed and latest version
Nothing to do
[root@db lib]# yum reinstall perl-DBD-MySQL


安装之后再次检查 mysql.so
[root@db ~]# ldd /usr/lib64/perl5/auto/DBD/mysql/mysql.so
    linux-vdso.so.1 =>  (0x00007ffe08d85000)
    libmysqlclient.so.16 => /usr/lib64/mysql/libmysqlclient.so.16 (0x00007ffbd1cb5000)
    libz.so.1 => /lib64/libz.so.1 (0x00007ffbd1a9e000)
    libcrypt.so.1 => /lib64/libcrypt.so.1 (0x00007ffbd1867000)
    libnsl.so.1 => /lib64/libnsl.so.1 (0x00007ffbd164e000)
    libm.so.6 => /lib64/libm.so.6 (0x00007ffbd13c9000)
    libssl.so.10 => /usr/lib64/libssl.so.10 (0x00007ffbd115d000)
    libcrypto.so.10 => /usr/lib64/libcrypto.so.10 (0x00007ffbd0d78000)
    libc.so.6 => /lib64/libc.so.6 (0x00007ffbd09e3000)
    libfreebl3.so => /lib64/libfreebl3.so (0x00007ffbd07e0000)
    libgssapi_krb5.so.2 => /lib64/libgssapi_krb5.so.2 (0x00007ffbd059c000)
    libkrb5.so.3 => /lib64/libkrb5.so.3 (0x00007ffbd02b4000)
    libcom_err.so.2 => /lib64/libcom_err.so.2 (0x00007ffbd00b0000)
    libk5crypto.so.3 => /lib64/libk5crypto.so.3 (0x00007ffbcfe84000)
    libdl.so.2 => /lib64/libdl.so.2 (0x00007ffbcfc7f000)
    /lib64/ld-linux-x86-64.so.2 (0x000055abf0353000)
    libkrb5support.so.0 => /lib64/libkrb5support.so.0 (0x00007ffbcfa74000)
    libkeyutils.so.1 => /lib64/libkeyutils.so.1 (0x00007ffbcf871000)
    libresolv.so.2 => /lib64/libresolv.so.2 (0x00007ffbcf656000)
    libpthread.so.0 => /lib64/libpthread.so.0 (0x00007ffbcf439000)
    libselinux.so.1 => /lib64/libselinux.so.1 (0x00007ffbcf219000)


再次执行 pt-table-checksum 就正常了。
[root@db lib]# pt-table-checksum S=/data/mysql/mysqldata3306/sock/mysql.sock,h=localhost
Checking if all tables can be checksummed ...
Starting checksum ...
Diffs cannot be detected because no slaves were found.  Please read the --recursion-method documentation for information.
            TS ERRORS  DIFFS     ROWS  DIFF_ROWS  CHUNKS SKIPPED    TIME TABLE
11-01T17:30:13      0      0        0          0       1       0   0.003 mysql.columns_priv
11-01T17:30:13      0      0        2          0       1       0   0.007 mysql.db
11-01T17:30:13      0      0        2          0       1       0   0.005 mysql.engine_cost
11-01T17:30:13      0      0        0          0       1       0   0.003 mysql.event
11-01T17:30:13      0      0        0          0       1       0   0.002 mysql.func
11-01T17:30:13      0      0       40          0       1       0   0.003 mysql.help_category
11-01T17:30:13      0      0      693          0       1       0   0.010 mysql.help_keyword
11-01T17:30:13      0      0     1406          0       1       0   0.003 mysql.help_relation
11-01T17:30:13      0      0      637          0       1       0   0.022 mysql.help_topic
11-01T17:30:13      0      0        0          0       1       0   0.003 mysql.ndb_binlog_index
11-01T17:30:13      0      0        0          0       1       0   0.007 mysql.plugin
11-01T17:30:13      0      0       48          0       1       0   0.004 mysql.proc
11-01T17:30:13      0      0        0          0       1       0   0.004 mysql.procs_priv
11-01T17:30:13      0      0        1          0       1       0   0.003 mysql.proxies_priv
11-01T17:30:13      0      0        6          0       1       0   0.003 mysql.server_cost
11-01T17:30:13      0      0        0          0       1       0   0.003 mysql.servers
11-01T17:30:13      0      0        2          0       1       0   0.002 mysql.tables_priv
11-01T17:30:13      0      0        0          0       1       0   0.002 mysql.time_zone
11-01T17:30:13      0      0        0          0       1       0   0.006 mysql.time_zone_leap_second
11-01T17:30:13      0      0        0          0       1       0   0.006 mysql.time_zone_name
11-01T17:30:13      0      0        0          0       1       0   0.002 mysql.time_zone_transition
11-01T17:30:13      0      0        0          0       1       0   0.004 mysql.time_zone_transition_type
11-01T17:30:13      0      0        3          0       1       0   0.004 mysql.user
11-01T17:30:13      0      0        6          0       1       0   0.002 sys.sys_config

02-12 09:34