SQLAdvisor(美團)部署實錄
[root@king01 ~]# rpm -ivh percona-release-0.1-4.noarch.rpm
[root@king01 ~]# yum install -y cmake libaio-devel libffi-devel glib2 glib2-devel
[root@king01 ~]# yum install -y Percona-Server-shared-55
[root@king01 ~]# git clone https://github.com/Meituan-Dianping/SQLAdvisor.git
Initialized empty Git repository in /root/SQLAdvisor/.git/
remote: Counting objects: 1460, done.
remote: Total 1460 (delta 0), reused 0 (delta 0), pack-reused 1460
Receiving objects: 100% (1460/1460), 19.92 MiB | 109 KiB/s, done.
Resolving deltas: 100% (368/368), done.
[root@king01 ~]# cd SQLAdvisor
[root@king01 SQLAdvisor]# cmake -DBUILD_CONFIG=mysql_release -DCMAKE_BUILD_TYPE=debug -DCMAKE_INSTALL_PREFIX=/usr/local/sqlparser ./
[root@king01 SQLAdvisor]# make && make install
[root@king01 SQLAdvisor]# cd sqladvisor
[root@king01 sqladvisor]# cmake -DCMAKE_BUILD_TYPE=debug ./
[root@king01 sqladvisor]# make
[root@king01 sqladvisor]# cp sqladvisor /usr/bin
[root@king01 ~]# 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
[root@king01 ~]# vi sql.cnf
[sqladvisor]
username=tpcc
password=tpcc
host=192.168.1.200
port=3306
dbname=tpcc1000
sqls=select * from warehouse;
[root@king01 ~]# sqladvisor -f sql.cnf -v 1
2018-02-13 09:04:31 20618 [Note] 第1步: 對SQL解析優化之後得到的SQL:select `*` AS `*` from `tpcc1000`.`warehouse`
2018-02-13 09:04:31 20618 [Note] 第2步:表warehouse 的SQL太逆天,沒有優化建議
2018-02-13 09:04:31 20618 [Note] 第3步: SQLAdvisor結束!
SQLAdvisor(美團)部署實錄