试用 MySQL Inception

Inception是集审核、执行、回滚于一体的一个自动化运维系统,它是根据MySQL代码修改过来的,用它可以很明确的,详细的,准确的审核MySQL的SQL语句,它的工作模式和MySQL完全相同,可以直接使用MySQL客户端来连接,Inception是一款自动化运维的利器,有别与现在各个公司使用的方式,使用Inception,将会给DBA带来最大的便利性,将DBA从繁冗的工作中解放出来,做一些更多的自动化工作,或者从架构方面研究如何更大程度的保证数据库的高可用等等。

安装依赖条件

1
yum install -y cmake ncurses-devel openssl-devel bison-devel gcc-c++

编译 inception

1
2
3
git clone https://github.com/mysql-inception/inception.git
cd inception
./inception_build.sh debug

每次如果出错之后,需要把编译目录删除掉rm -rf debug,重新执行,不然会执行出错。

配置 inception

新建 inc.cnf 文件,粘贴下面的内容

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
[inception]
general_log=1
general_log_file=inception.log
port=6669
socket=/自己目录,请自行修改/inc.socket
character-set-client-handshake=0
character-set-server=utf8
inception_remote_system_password=root
inception_remote_system_user=wzf1
inception_remote_backup_port=3306
inception_remote_backup_host=127.0.0.1
inception_support_charset=utf8mb4
inception_enable_nullable=0
inception_check_primary_key=1
inception_check_column_comment=1
inception_check_table_comment=1
inception_osc_min_table_size=1
inception_osc_bin_dir=/data/temp
inception_osc_chunk_time=0.1
inception_enable_blob_type=1
inception_check_column_default_value=1
inception_check_autoincrement_name=0
inception_enable_identifer_keyword=1
inception_enable_sql_statistic=1

点击下面的链接查看更多的参数和选项

http://mysql-inception.github.io/inception-document/option/

启动 inception

和MySQL是一样的,Inception可执行文件可以在编译目录下面通过find命令找到,编译目录就是在执行inception_build.sh脚本时指定的目录。

1
./debug/mysql/bin/Inception --defaults-file=inc.cnf

注意: 因为Inception支持OSC执行的功能,是通过调用 pt-online-schema-change 工具来做的,但如果Inception后台启动(&)的话,可能会导致 pt-online-schema-change 在执行完成之后,长时间不返回,进而导致Inception卡死的问题,这个问题后面会解决,但现阶段请尽量不要使用后台启动的方式,或者可以使用 nohup Inception 启动命令 & 的方式来启动。

安装 inception_web 端

1
2
3
4
5
6
7
git clone https://github.com/dbalihui/inception_web.git
pip install flask_wtf
pip install flask-script
pip install flask-debugtoolbar
pip install MySQL-python
#在inception_web目录下运行
./run.py runserver --host 0.0.0.0

因为这个 web 界面的工具只是一个测试的 Demo 程序,很多深入的功能还需要自己开发。