项目github地址:https://github.com/Meituan-Dianping/SQLAdvisor/blob/master/doc/QUICK_START.md
拉取代码:
git clone https://github.com/Meituan-Dianping/SQLAdvisor.git
1. yum install cmake libaio-devel libffi-devel glib2 glib2-devel
2. yum install Percona-Server-shared-56
安装yum源:yum install http://www.percona.com/downloads/percona-release/redhat/0.1-3/percona-release-0.1-3.noarch.rpm
执行第2步
编译:
1. cmake -DBUILD_CONFIG=mysql_release -DCMAKE_BUILD_TYPE=debug -DCMAKE_INSTALL_PREFIX=/usr/local/sqlparser ./
2. make && make install
安装源码:
1. cd SQLAdvisor/sqladvisor/
2. cmake -DCMAKE_BUILD_TYPE=debug ./
3. make
4. 在本路径下生成一个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
2.2 命令行传参调用
./sqladvisor -h xx -P xx -u xx -p 'xx' -d xx -q "sql" -v 1