github地址:
https://github.com/Meituan-Dianping/SQLAdvisor/blob/master/doc/QUICK_START.md
安装方法:
安装依赖包
yum -y install cmake libaio-devel libffi-devel glib2 glib2-devel
yum install http://www.percona.com/downloads/percona-release/redhat/0.1-3/percona-release-0.1-3.noarch.rpm
yum -y install Percona-Server-shared-56
cd /usr/lib64/
ln -s libperconaserverclient_r.so.18 libperconaserverclient_r.so编译依赖项sqlparser
#yum install git -y
#git clone https://github.com/Meituan-Dianping/SQLAdvisor.git
a.cd SQLAdvisor
b.cmake -DBUILD_CONFIG=mysql_release -DCMAKE_BUILD_TYPE=debug -DCMAKE_INSTALL_PREFIX=/usr/local/sqlparser ./
c.make && make install安装SQLAdvisor源码
a. cd SQLAdvisor/sqladvisor/
b. cmake -DCMAKE_BUILD_TYPE=debug ./
c. make
d. 在本路径下生成一个sqladvisor可执行文件,这即是我们想要的。SQLAdvisor使用
./sqladvisor --help
Usage:
sqladvisor [OPTION...] sqladvisor
SQL Advisor Summary
Help Options:
-?, --help Show help options
Application Options:
-f, --defaults-file sqls file
-u, --username username
-p, --password password
-P, --port port
-h, --host host
-d, --dbname database name
-q, --sqls sqls
-v, --verbose 1:output logs 0:output nothing命令行传参调用
./sqladvisor -h xx -P xx -u xx -p 'xx' -d xx -q "sql" -v 1
注意:命令行传参时,参数名与值需要用空格隔开配置文件传参调用
$> cat sql.cnf
[sqladvisor]
username=xx
password=xx
host=xx
port=xx
dbname=xx
sqls=sql1;sql2;sql3....
cmd: ./sqladvisor -f sql.cnf -v 1