percona-toolkit pt安装以及 Can’t load ‘/usr/lib64/perl5/vendor_perl/auto/DBD/mysql/mysql.so’ for module DBD::mysql: /lib64/libmysqlclient.so.18: version `libmysqlclient_18’ not found (required by /usr/lib64/perl5/vendor_perl/auto/DBD/mysql/mysql.so) at /usr/lib64/perl5/DynaLoader.pm line 190
下载pt rpm包 这个官方直接下载就行 ,没啥说的
#解压安装包
tar -zxvf percona-toolkit-3.0.12_x86_64.tar.gz
# 移动文件
mv percona-toolkit-3.0.12 /usr/local/perconatoolkit
#建立链接
ln -sf /usr/local/perconatoolkit/bin/* /usr/bin/
pt-heartbeat --help
可能遇到的问题 缺依赖包 因为pt-heartbeat 要连接mysql 常见的缺的就是DBI,DBD等,可以直接通过yum或者rpm包安装
yum install perl-DBI
yum install perl-DBD-MySQL
yum install perl-Time-HiRes
yum install perl-IO-Socket-SSL
执行ptb报错:
[root@localhost ~]# perl -e'use DBD::mysql'
Can't load '/usr/lib64/perl5/vendor_perl/auto/DBD/mysql/mysql.so' for module DBD::mysql: /lib64/libmysqlclient.so.18: version `libmysqlclient_18' not found (required by /usr/lib64/perl5/vendor_perl/auto/DBD/mysql/mysql.so) at /usr/lib64/perl5/DynaLoader.pm line 190.
at -e line 1.
Compilation failed in require at -e line 1.
BEGIN failed--compilation aborted at -e line 1.
[root@localhost ~]# ldd /usr/lib64/perl5/vendor_perl/auto/DBD/mysql/mysql.so
/usr/lib64/perl5/vendor_perl/auto/DBD/mysql/mysql.so: /lib64/libmysqlclient.so.18: version `libmysqlclient_18' not found (required by /usr/lib64/perl5/vendor_perl/auto/DBD/mysql/mysql.so)
linux-vdso.so.1 => (0x00007ffdb5a7d000)
libmysqlclient.so.18 => /lib64/libmysqlclient.so.18 (0x00007f7af32d3000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f7af30b7000)
libz.so.1 => /lib64/libz.so.1 (0x00007f7af2ea1000)
libm.so.6 => /lib64/libm.so.6 (0x00007f7af2b9f000)
libssl.so.10 => /lib64/libssl.so.10 (0x00007f7af292d000)
libcrypto.so.10 => /lib64/libcrypto.so.10 (0x00007f7af24cc000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007f7af22c8000)
libc.so.6 => /lib64/libc.so.6 (0x00007f7af1efb000)
librt.so.1 => /lib64/librt.so.1 (0x00007f7af1cf3000)
libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007f7af19eb000)
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f7af17d5000)
/lib64/ld-linux-x86-64.so.2 (0x00007f7af3a61000)
libgssapi_krb5.so.2 => /lib64/libgssapi_krb5.so.2 (0x00007f7af1588000)
libkrb5.so.3 => /lib64/libkrb5.so.3 (0x00007f7af12a0000)
libcom_err.so.2 => /lib64/libcom_err.so.2 (0x00007f7af109c000)
libk5crypto.so.3 => /lib64/libk5crypto.so.3 (0x00007f7af0e69000)
libkrb5support.so.0 => /lib64/libkrb5support.so.0 (0x00007f7af0c5b000)
libkeyutils.so.1 => /lib64/libkeyutils.so.1 (0x00007f7af0a57000)
libresolv.so.2 => /lib64/libresolv.so.2 (0x00007f7af083e000)
libselinux.so.1 => /lib64/libselinux.so.1 (0x00007f7af0617000)
libpcre.so.1 => /lib64/libpcre.so.1 (0x00007f7af03b5000)
[root@localhost ~]# ll /lib64/libmysqlclient*
lrwxrwxrwx 1 root root 27 11月 23 09:59 /lib64/libmysqlclient_18 -> /lib64/libmysqlclient.so.18
lrwxrwxrwx. 1 root root 28 11月 21 17:51 /lib64/libmysqlclient_r.so -> libperconaserverclient.so.18
lrwxrwxrwx. 1 root root 28 11月 21 17:51 /lib64/libmysqlclient_r.so.18 -> libperconaserverclient.so.18
lrwxrwxrwx. 1 root root 28 11月 21 17:51 /lib64/libmysqlclient_r.so.18.0.0 -> libperconaserverclient.so.18
lrwxrwxrwx. 1 root root 32 11月 21 17:51 /lib64/libmysqlclient_r.so.18.1.0 -> libperconaserverclient.so.18.1.0
lrwxrwxrwx. 1 root root 28 11月 21 17:51 /lib64/libmysqlclient.so -> libperconaserverclient.so.18
lrwxrwxrwx. 1 root root 28 11月 21 17:51 /lib64/libmysqlclient.so.18 -> libperconaserverclient.so.18
lrwxrwxrwx. 1 root root 28 11月 21 17:51 /lib64/libmysqlclient.so.18.0.0 -> libperconaserverclient.so.18
lrwxrwxrwx. 1 root root 32 11月 21 17:51 /lib64/libmysqlclient.so.18.1.0 -> libperconaserverclient.so.18.1.0
我们看到/lib64/libmysqlclient.so.18 -> libperconaserverclient.so.18 我们数据装的是percona 5.6.25 所以动态库都是perconaserverclient 与本地比较了一下在结合报错信息作出如下处理:
从pt好用的机器上拷贝一个libmysqlclient.so.18.0.0文件上传到有问题的机器的/lib64/下并重命名为libmysqlclient.so.18.0.0.0.0
#授权
[root@localhost ~]# chmod 777 /lib64/libmysqlclient.so.18.0.0.0.0
[root@localhost ~]# ll /lib64/libmysqlclient*
lrwxrwxrwx 1 root root 27 11月 23 09:59 /lib64/libmysqlclient_18 -> /lib64/libmysqlclient.so.18
lrwxrwxrwx. 1 root root 28 11月 21 17:51 /lib64/libmysqlclient_r.so -> libperconaserverclient.so.18
lrwxrwxrwx. 1 root root 28 11月 21 17:51 /lib64/libmysqlclient_r.so.18 -> libperconaserverclient.so.18
lrwxrwxrwx. 1 root root 28 11月 21 17:51 /lib64/libmysqlclient_r.so.18.0.0 -> libperconaserverclient.so.18
lrwxrwxrwx. 1 root root 32 11月 21 17:51 /lib64/libmysqlclient_r.so.18.1.0 -> libperconaserverclient.so.18.1.0
lrwxrwxrwx. 1 root root 28 11月 21 17:51 /lib64/libmysqlclient.so -> libperconaserverclient.so.18
lrwxrwxrwx. 1 root root 28 11月 21 17:51 /lib64/libmysqlclient.so.18 -> libperconaserverclient.so.18
lrwxrwxrwx. 1 root root 28 11月 21 17:51 /lib64/libmysqlclient.so.18.0.0 -> libperconaserverclient.so.18
#权限已经改变
-rwxrwxrwx 1 root root 3133544 11月 23 10:35 /lib64/libmysqlclient.so.18.0.0.0.0
lrwxrwxrwx. 1 root root 32 11月 21 17:51 /lib64/libmysqlclient.so.18.1.0 -> libperconaserverclient.so.18.1.0
[root@localhost ~]# cd /lib64/
#将 libmysqlclient.so.18做一个bak 然后移除
[root@localhost lib64]# cp libmysqlclient.so.18 libmysqlclient.so.18.bak
[root@localhost lib64]# rm libmysqlclient.so.18
rm:是否删除符号链接 "libmysqlclient.so.18"?y
#将新的libmysqlclient.so.18连接到libmysqlclient.so.18.0.0.0.0
[root@localhost lib64]# ln -s libmysqlclient.so.18.0.0.0.0 libmysqlclient.so.18
#在验证就可以了
[root@localhost lib64]# perl -e'use DBD::mysql'
[root@localhost lib64]# pt-heartbeat --user=backup --password=123456 --create-table --host=192.168.1.1 -D cum1 --interval=1 --update --replace --daemonize
[root@localhost lib64]#
由于对pt工具原理不清楚 具体也不是十分清晰为什么会这样 而且同样都是安装perocns server在开发机器和线上机器 结果却不同 大概理解可能就是通过libmysqlclient.so.18找到的是libperconaserverclient.so.18,而要求找到的是/lib64/libmysqlclient.so.18.0.0,也就是说libperconaserverclient.so.18和/lib64/libmysqlclient.so.18还是不同的 以后研究的明白再来补充 这里就做个记录吧