#下载二进制包(根据需求下载对应版本)
#解压包
tar -xvf goInception-linux-v1.3.0-1-g140054c.tar.gz
#启动
./goInception -config=config/config.toml
[root@hadoop02 goInception]# netstat -tunlp|grep 4000
tcp6 2 0 :::4000 :::* LISTEN 2137/./goInception
[root@hadoop02 goInception]# kill -9 2137
[root@hadoop02 goInception]# ./goInception -config=config/config.toml &
mysql -h127.0.0.1 -P4000
inception show variables;
审核规则修改
审核规则有很多,大家可以参考官方文档。此处说明如何修改审核规则:
1、登录goinception审核server
mysql -h127.0.0.1 -P400
2、查看参数
inception show levels;# 筛选指定审核名称inception show levels like '%blob%';# 筛选指定级别inception show levels where value=2;# 筛选指定关键字inception show levels where `desc` like '%index%';
3、设置审核级别
inception set level er_no_where_condition = 2;
4、修改参数
inception set check_dml_where = 1;
调用示例
goInception延用inception的使用方式,在审核的sql开始前添加注释来指定远端服务器,并在sql的前后添加特殊标识以区分待审核语句,示例如下:
/*--user=root;--password=root;--host=127.0.0.1;--check=1;--port=3306;*/inception_magic_start;use test;create table t1(id int primary key);inception_magic_commit;
测试案例
1、python测试脚本
#!/usr/bin/env python3# -*- coding:utf-8 -*-import pymysqlimport prettytable as pttb = pt.PrettyTable()#修改为自己线上服务器连接信息sql = '''/*--user=root;--password=xxx;--host=xxx;--check=0;--port=3306;--execute=1;--backup=1;*/inception_magic_start;use testdb; create table t1(id int primary key,c1 int);insert into t1(id,c1)values(1,1);inception_magic_commit;'''conn = pymysql.connect(host='127.0.0.1', user='', passwd='', db='', port=4000, charset="utf8mb4")cur = conn.cursor()ret = cur.execute(sql)result = cur.fetchall()cur.close()conn.close()tb.field_names = [i[0] for i in cur.description]for row in result: tb.add_row(row)print(tb)
2、执行结果
3、线上库结果
4、备份库结果