背景:
关于MySQL的审核的重要性就不说明了,本文的自动化审核是通过Inception和SQLAdvisor实现的,具体的使用可以看它们各自的说明文档。这里大致介绍下如何部署和使用它们,其实该文章也可以说成是如何在ubuntu下安装Inception和SQLAdivsor。本文的web平台是通过python的tornado来实现的,详细信息可以看下面的介绍说明。
环境:
系统:Ubuntu 14.04.5
安装部署:
① 下载inception
git clone https://github.com/mysql-inception/inception.git
② 安装依赖包
1,cmake:sudo apt-get installcmake:2,libncurses5-dev:sudo apt-get install libncurses5-dev3,libssl-dev:sudo apt-get install libssl-dev4,g++
sudo apt-get install g++
5,m4sudo apt-get installm46,bison:版本最好是2.6之前的,最新的可能会有问题wget http://ftp.gnu.org/gnu/bison/bison-2.5.1.tar.gz
./configuremake
make install
做个软连接:
ln -s /usr/local/inception-master_2.1.50/sql/Inception /usr/bin/Inception
③ 安装inception
1安装,进入clone的目录执行:sh inception_build.shdebug
上面执行完毕之后再执行,可执行文件在debug下面的sql目录中,执行:mv debug/ /usr/local/inception-master_2.1.50
2查看版本:
cd/usr/local/inception-master_2.1.50/sql
./Inception -V
./Inception Ver Inception2.1.50 for Linux on x86_64 (Source distribution)
wget https://www.percona.com/downloads/percona-toolkit/2.2.20/tarball/percona-toolkit-2.2.20.tar.gz
tar zxvf percona-toolkit-2.2.20.tar.gz
cd percona-toolkit-2.2.20/
perlMakefile.PLmake install
⑤ 测试Inception:
命令行启动:
Inception --port=6669
2017-03-27 00:45:31 0 [Note] Welcome to use Inception2.1.50
2017-03-27 00:45:31 26811 [Note] Server hostname (bind-address): '*'; port: 6669
2017-03-27 00:45:31 26811[Note] IPv6 is available.2017-03-27 00:45:31 26811 [Note] - '::' resolves to '::';2017-03-27 00:45:31 26811 [Note] Server socket created on IP: '::'.
参数启动:可以根据需要来调整参数
Inception --defaults-file=/etc/inception/inc.cnf
[inception]
general_log=1general_log_file=/var/log/inception.log
port=6669socket=/tmp/inc.socket
character-set-client-handshake=0character-set-server=utf8
#备份相关
#需要开启binlog
inception_remote_system_password=cVQ9FLoiTbED2R3ycvnJ
inception_remote_system_user=audit_user
inception_remote_backup_port=3306inception_remote_backup_host=192.168.200.49#在DML语句中没有WHERE条件时,是不是要报错
inception_check_dml_where=1#在DML语句中使用了LIMIT时,是不是要报错
inception_check_dml_limit=1#在DML语句中使用了Order By时,是不是要报错
inception_check_dml_orderby
#Select*时是不是要报错
inception_enable_select_star=1#order by rand时是不是报错
inception_enable_orderby_rand=1#创建或者新增列时如果列为NULL,是不是报错
inception_enable_nullable=1#是不是支持外键
inception_enable_foreign_key=1#一个索引中,列的最大个数,超过这个数目则报错(1-64)
inception_max_key_parts=5#在一个修改语句中,预计影响的最大行数,超过这个数就报错(1-max)
inception_max_update_rows=10000#一个表中,最大的索引数目,超过这个数则报错(1-1024)
inception_max_keys=16#建表指定的存储引擎不为Innodb,不报错
inception_enable_not_innodb