Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Percona Toolkit installation

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Percona Toolkit (pt tools) is a group of command-line tools for database maintenance, most of which are Perl scripts, which connect to the database and need the support of DBI and DBD::mysql.

Install these two packages directly using yum.

# yum install perl-DBI perl-DBD-MySQL

After installing the dependencies of the pt tool, you install pt itself (percona-toolkit-3.0.3_x86_64.tar.gz), which specifies the directory in which it is installed.

# perl Makefile.PLPREFIX=/usr/local/percona-toolkit

# make

# make install

Set the environment variable PATH and execute the command line. If you can get the authorization information of the database user, the installation is normal.

$pt-show-grants-host=localhost--password=123456-port=3316-user=root

On the command line above, the process of accessing the database is as follows:

Pt-show-grants-> DBI-> DBD::MySQL- > MySQL client library-> MySQL Database

What exactly does the MySQL client library used in the above process look like? it has not been manually set.

$ldconfig-- print-cache | grep'libmysqlclient.so'

Libmysqlclient.so.16 (libc6,x86-64) = > / usr/lib64/mysql/libmysqlclient.so.16

The software package by which the library file libmysqlclient.so is installed, look as follows:

$rpm-qf/usr/lib64/mysql/libmysqlclient.so.16

Mysql-libs-5.1.73-8.el6_8.x86_64

Which files are mainly installed in mysql-libs? there are two parts: one is the client library file used to connect to the MySQL database, and the other is the file mysql-x86_64.conf, which specifies the path / usr/lib64/mysql of the library file. When ldconfig is executed, the operating system loads the files under this path.

$rpm-ql mysql-libs-5.1.73-8.el6_8.x86_64

/ etc/ld.so.conf.d/mysql-x86_64.conf

/ etc/my.cnf

/ usr/lib64/mysql

/ usr/lib64/mysql/libmysqlclient.so.16

/ usr/lib64/mysql/libmysqlclient.so.16.0.0

/ usr/lib64/mysql/libmysqlclient_r.so.16

/ usr/lib64/mysql/libmysqlclient_r.so.16.0.0

If you are careful, you will find that when you install perl-DBD-MySQL, it depends on mysql-libs, and yum will install mysql-libs.

So far, we have a general understanding of how the pt tool accesses the database, what kind of MySQL client library it uses, and which software package it comes from.

If you want the pt tool to use the client library file that comes with the current MySQL software, that is, the library file under the directory / opt/mysql/lib (the MySQL installation path is / opt/mysql), instead of using the one provided by mysql-libs, what should you do?

1. Uninstall the package mysql-libs

# rpm-e mysql-libs-5.1.73-8.el6_8.x86_64--nodeps

two。 Edit the file / etc/ld.so.conf.d/mysql.conf, write the new path / opt/mysql/lib, and then ldconfig to see if the new library file is valid.

# ldconfig

# ldconfig-- print-cache | grep 'libmysqlclient.so'

Libmysqlclient.so.18 (libc6,x86-64) = > / opt/mysql/lib/libmysqlclient.so.18

Using the command line pt-show-grants test, the error is as follows:

$pt-show-grants--host=localhost-password=123456-port=3316-user=root

Install_driver (mysql) failed: Attempt toreload DBD/mysql.pm aborted.

Compilation failed in require at (eval 5) line 3.

At/usr/local/percona-toolkit/bin/pt-show-grants line 1367

3. Why, perl-DBD-MySQL and MySQL clientlibrary may not match, try this, uninstall DBI and DBD::mysql, source code install the latest version of both.

3.1 Uninstall perl-DBI and perl-DBD-MySQL.

# yum remove perl-DBI perl-DBD-MySQL

Download the latest DBI and DBD::mysql source packages and compile and install them.

Download link, https://dev.mysql.com/downloads/dbi.html

Install DBI first, follow the steps perl Makefile.PL, make make, install, and then DBD::mysql.

There is a problem in installing DBD::mysql, first download the corresponding dependent package of DBD::mysql and install it.

# perl Makefile.PL

Can't locate Devel/CheckLib.pm in @ INC...

# rpm-ivh ftp://fr2.rpmfind.net/linux/epel/6/x86_64/perl-Devel-CheckLib-0.98-1.el6.noarch.rpm

Retrieving ftp://fr2.rpmfind.net/linux/epel/6/x86_64/perl-Devel-CheckLib-0.98-1.el6.noarch.rpm

Warning: / var/tmp/rpm-tmp.uqBd6F: Header V3RSA/SHA256 Signature, key ID 0608b895: NOKEY

Preparing... # [100%]

1:perl-Devel-CheckLib # # [100%]

4. It is normal to use pt-show-grants test again at this time.

If you are interested, please follow Subscription account's Database Best practices (DBBestPractice).

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report