inception安装步骤

1. 下载:
https://github.com/mysql-inception/inception  选择下载:

Downloda ZIP

注意安装包:
yum -y install cmake  libncurses5-dev libssl-dev g++ bison openssl-devel.x86_64 
mkdir  /usr/local/inception
mkdir  -p  /data/inception
mkdir  /data/socket
mkdir  /data/temp

2. 下载后解压编译:
# unzip inception-master.zip
# cd inception-master
# cmake .
# cmake -DWITH_DEBUG=OFF -DCMAKE_INSTALL_PREFIX=/usr/local/inception  -DMYSQL_DATADIR=/data/inception -DWITH_SSL=yes -DCMAKE_BUILD_TYPE=RELEASE-DWITH_ZLIB=bundled-DMY_MAINTAINER_CXX_WARNINGS="-Wall -Wextra -Wunused -Wwrite-strings -Wno-strict-aliasing  -Wno-unused-parameter -Woverloaded-virtual" -DMY_MAINTAINER_C_WARNINGS="-Wall -Wextra -Wunused -Wwrite-strings -Wno-strict-aliasing -Wdeclaration-after-statement"
# make && make install
# sh -x  inception_build.sh debug
报错如下:
-- Build files have been written to: /root/inception-master
+ '[' x '!=' Xcode ']'
+ make install
make: *** 没有规则可以创建目标“install”。 停止。

# sh inception_build.sh debug [linux]
make: *** 没有规则可以创建目标“install”。 停止。

解决办法:# make -j6 && make install

inception错误处理make[2]: *** [sql/CMakeFiles/sql.dir/sql_yacc.cc.o] Error 1

问题

make[2]: * [sql/CMakeFiles/sql.dir/sql_yacc.cc.o] Error 1
make[1]: * [sql/CMakeFiles/sql.dir/all] Error 2
make: * [all] Error 2

按照文档的提示
http://mysql-inception.github.io/inception-document/install/
仔细检查,发现bison的版本较高,使用apt-get install bison安装的版本为3.0.2,而手册建议的版本为2.6之前的

解决方案

下载、安装bison2.5.1后再重新安装inception

http://ftp.gnu.org/gnu/bison/bison-2.5.1.tar.gz

./configure

  make && make install

另外,请注意建议通过sh执行inception_build.sh,如
sh inception_build.sh debug

3、完成后添加配置文件

[inception]
  general_log=1      #这个参数就是原生的MySQL的参数,用来记录在Inception服务上执行过哪些语句,用来定位一些问题等
  general_log_file= /data/inception/inception .log                #设置general log写入的文件路径
  port=6669                      #Inception的服务端口
  socket= /data/socket/inc .socket                         #Inception的套接字文件存放位置
  character- set -client-handshake=0                       
  character- set -server=utf8                            #mysql原生参数
  #备份服务器信息
  inception_remote_system_password=root
  inception_remote_system_user=123456@
  inception_remote_backup_port=3306
  inception_remote_backup_host=127.0.0.1
  inception_support_charset=utf8mb4       #表示在建表或者建库时支持的字符集,如果需要多个,则用逗号分隔,影响的范围是建表、设置会话字符集、修改表字符集属性等
  inception_enable_nullable=0                     #创建或者新增列时如果列为NULL,不报错
  inception_check_primary_key=1                     #建表时,如果没有主键,则报错
  inception_check_column_comment=1                     #建表时,列没有注释时报错
  inception_check_table_comment=1                        #建表时,表没有注释时报错
  inception_osc_min_table_size=1   # 这个参数实际上是一个OSC的开关,如果设置为0,则全部ALTER语句都走OSC,如果设置为非0,则当这个表占用空间大小大于这个值时才使用OSC方式
  inception_osc_bin_dir= /data/temp                 #用于指定pt-online-schema-change脚本的位置,不可修改,在配置文件中设置
  inception_osc_chunk_time=0.1                         #对应OSC参数--chunk-time
  inception_enable_blob_type=1                              #检查是不是支持BLOB字段,包括建表、修改列、新增列操作 默认开启
  inception_check_column_default_value=1               #检查在建表、修改列、新增列时,新的列属性是不是要有默认值

注:inc.cnf 配置上的参数意义可以参考

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

         http://blog.itpub.net/27808137/viewspace-1816388/

 

注:启动Inception. 现在就到启动时间了,那么启动有两种方式,和MySQL是一样的
1. Inception –defaults-file=inc.cnf
2. Inception –port=6669

4、启动inception服务
/usr/local/inception/bin/Inception --defaults-file=/etc/inc.cnf     //启动inception 有2种方式,在这采用配置文件启动方式。
/use/local/inception/bin/Inception--port =6669  注:记得在防火墙开启6669 端口

 
5、测试inception。
测试之前创建一个可以连接mysql的用户:用户名wwn  密码:123456  IP:127.0.0.1 保证能正常登陆mysql即可。
# mysql -uroot -h127.0.0.1 -P6669       //登陆inception
登录上去之后,再执行一个命令:
inception get variables;
输出了所有的变量,恭喜你,已经启动成功了,都说了非常简单。

root@wiki:[/home/inception-master]mysql -uroot -h127.0.0.1 -P6669  
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: Inception2.1.50 1

Copyright (c) 2009-2018 Percona LLC and/or its affiliates
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> inception get variables;

+------------------------------------------+-------------------------------------------+
| Variable_name                            | Value                                     |
+------------------------------------------+-------------------------------------------+
| autocommit                               | OFF                                       |
| bind_address                             | *                                         |
| character_set_system                     | utf8                                      |
| character_sets_dir                       | /home/inception-master/share/charsets/    |
| connect_timeout                          | 10                                        |
| date_format                              | %Y-%m-%d                                  |
| datetime_format                          | %Y-%m-%d %H:%i:%s                         |
| general_log                              | ON                                        |
| general_log_file                         | inc.log                                   |
| inception_check_autoincrement_datatype   | ON                                        |
| inception_check_autoincrement_init_value | ON                                        |
| inception_check_autoincrement_name       | ON                                        |
| inception_check_column_comment           | ON                                        |
| inception_check_column_default_value     | ON                                        |
| inception_check_dml_limit                | ON                                        |
| inception_check_dml_orderby              | ON                                        |
| inception_check_dml_where                | ON                                        |
| inception_check_identifier               | ON                                        |
| inception_check_index_prefix             | ON                                        |
| inception_check_insert_field             | ON                                        |
| inception_check_primary_key              | ON                                        |
| inception_check_table_comment            | ON                                        |
| inception_check_timestamp_default        | ON                                        |
| inception_ddl_support                    | ON                                        |
| inception_enable_autoincrement_unsigned  | ON                                        |
| inception_enable_blob_type               | ON                                        |
| inception_enable_column_charset          | OFF                                       |
| inception_enable_enum_set_bit            | OFF                                       |
| inception_enable_foreign_key             | OFF                                       |
| inception_enable_identifer_keyword       | OFF                                       |
| inception_enable_not_innodb              | OFF                                       |
| inception_enable_nullable                | OFF                                       |
| inception_enable_orderby_rand            | OFF                                       |
| inception_enable_partition_table         | OFF                                       |
| inception_enable_pk_columns_only_int     | OFF                                       |
| inception_enable_select_star             | OFF                                       |
| inception_enable_sql_statistic           | ON                                        |
| inception_max_char_length                | 16                                        |
| inception_max_key_parts                  | 5                                         |
| inception_max_keys                       | 16                                        |
| inception_max_primary_key_parts          | 5                                         |
| inception_max_update_rows                | 10000                                     |
| inception_merge_alter_table              | ON                                        |
| inception_osc_alter_foreign_keys_method  | none                                      |
| inception_osc_bin_dir                    | /usr/bin                                  |
| inception_osc_check_alter                | ON                                        |
| inception_osc_check_interval             | 5.000000                                  |
| inception_osc_check_replication_filters  | ON                                        |
| inception_osc_chunk_size                 | 1000                                      |
| inception_osc_chunk_size_limit           | 4.000000                                  |
| inception_osc_chunk_time                 | 0.100000                                  |
| inception_osc_critical_thread_connected  | 1000                                      |
| inception_osc_critical_thread_running    | 80                                        |
| inception_osc_drop_new_table             | ON                                        |
| inception_osc_drop_old_table             | ON                                        |
| inception_osc_max_lag                    | 3.000000                                  |
| inception_osc_max_thread_connected       | 1000                                      |
| inception_osc_max_thread_running         | 80                                        |
| inception_osc_min_table_size             | 1                                         |
| inception_osc_on                         | ON                                        |
| inception_osc_print_none                 | ON                                        |
| inception_osc_print_sql                  | ON                                        |
| inception_osc_recursion_method           | processlist                               |
| inception_password                       |                                           |
| inception_read_only                      | OFF                                       |
| inception_remote_backup_host             | 127.0.0.1                                 |
| inception_remote_backup_port             | 3306                                      |
| inception_remote_system_password         | *CFF486455239DB377A8E258CD199C8F12DE10AB8 |
| inception_remote_system_user             | thunder                                   |
| inception_support_charset                | utf8                                      |
| inception_user                           |                                           |
| interactive_timeout                      | 28800                                     |
| max_allowed_packet                       | 1073741824                                |
| max_connect_errors                       | 100                                       |
| max_connections                          | 151                                       |
| net_buffer_length                        | 16384                                     |
| net_read_timeout                         | 30                                        |
| net_write_timeout                        | 60                                        |
| port                                     | 6669                                      |
| query_alloc_block_size                   | 8192                                      |
| query_prealloc_size                      | 8192                                      |
| socket                                   | /tmp/inc.socket                           |
| thread_handling                          | one-thread-per-connection                 |
| thread_stack                             | 262144                                    |
| time_format                              | %H:%i:%s                                  |
| version                                  | Inception2.1.50                           |
| version_comment                          | Source distribution                       |
| version_compile_machine                  | x86_64                                    |
| version_compile_os                       | Linux                                     |
| wait_timeout                             | 28800                                     |
+------------------------------------------+-------------------------------------------+
90 rows in set (0.00 sec)

mysql>



下面用脚本测试相关的审核语句:
1.  审核表创建语句测试:
[root@localhost ~]# cat aa.py 
#!/usr/bin/python
#-\*-coding: utf-8-\*-
import MySQLdb
sql='/*--user=wwn;--password=123456;--host=127.0.0.1;--execute=1;--port=3306;*/\
    inception_magic_start;\
    use test;\
    CREATE TABLE `alifeba_user` (\
                    `ID` int(11) unsigned NOT NULL auto_increment comment"aaa",\
                    `username` varchar(50) NOT NULL Default "" comment"aaa",\
                    `realName` varchar(50) NOT NULL Default "" comment"aaa",\
                    `age` int(11) NOT NULL Default 0 comment"aaa",\
                    PRIMARY KEY (`ID`)\
                    ) ENGINE=INNODB DEFAULT CHARSET=utf8mb4 COMMENT="AAAA";\
    inception_magic_commit;'
try:
        conn=MySQLdb.connect(host='127.0.0.1',user='wwn',passwd='123456',db='wwn',port=6669)
        cur=conn.cursor()
        ret=cur.execute(sql)
        result=cur.fetchall()
        num_fields = len(cur.description)
        field_names = [i[0] for i in cur.description]
        print field_names
        for row in result:
                print row[0], "¦",row[1],"¦",row[2],"¦",row[3],"¦",row[4],"¦",
                row[5],"¦",row[6],"¦",row[7],"¦",row[8],"¦",row[9],"¦",row[10]
        cur.close()
        conn.close()
except MySQLdb.Error,e:
        print "Mysql Error %d: %s" % (e.args[0], e.args[1])

2. 审核增删改语句
[root@localhost ~]# cat bb.py 
#!/usr/bin/python
#-\*-coding: utf-8-\*-
import MySQLdb
sql='/*--user=wwn;--password=123456;--host=127.0.0.1;--execute=1;--enable-remote-backup;--port=3306;*/\
    inception_magic_start;\
    use wwn;\
    INSERT INTO v9_wap(siteid,sitename,logo,domain,setting) VALUES ("12","aa","bb","cc","dd");\
    delete from   v9_wap where siteid=11;\
    update  v9_wap set sitename="haha" where siteid=10;\
    inception_magic_commit;'
     
try:
        conn=MySQLdb.connect(host='127.0.0.1',user='wwn',passwd='123456',db='wwn',port=6669)
        cur=conn.cursor()
        ret=cur.execute(sql)
        result=cur.fetchall()
        num_fields = len(cur.description)
        field_names = [i[0] for i in cur.description]
        print field_names
        for row in result:
                print row[0], "¦",row[1],"¦",row[2],"¦",row[3],"¦",row[4],"¦",
                row[5],"¦",row[6],"¦",row[7],"¦",row[8],"¦",row[9],"¦",row[10]
        cur.close()
        conn.close()
except MySQLdb.Error,e:
        print "Mysql Error %d: %s" % (e.args[0], e.args[1])


安装 web封装的界面

     下载:https://github.com/dbalihui/inception_web

      上传inception_web-master.zip包到服务器


环境配置

python2.7 + flask

先安装依赖模块

pip install flask_wtf 

pip install flask-script 

pip install flask-debugtoolbar

pip install MySQL-python

使用方法

先将app目录中的inception.py文件里的账号密码改成自己的

记得use sql_check这里要改成自己的数据库名字

在inception_web目录下运行./run.py runserver --host 0.0.0.0

使用浏览器访问你的IP  http://192.168.xx.xxx:5000/

运行报错的话是因为没有安装flask组件,请使用pip install xx安装相关组件

所以先升级Python2.7

wget https://www.python.org/ftp/python/2.7.10/Python-2.7.10.tgz --no-check-certificate

tar -xvf Python-2.7.10.tar

cd Python-2.7.10

./configure && make && make install

/usr/local/bin/python -V

mv /usr/bin/python /usr/bin/python2.6.6

ln -s /usr/local/bin/python /usr/bin/python

python -V //验证版本

vim /usr/bin/yum   //修改#!/usr/bin/python 为#!/usr/bin/python2.6.6,因为yum安装依赖的是2.6版本的python

下面安装模块:

首先安装一个pip

# yum -y install python-pip   //这种安装处理是2.6版本的

# wget  https://bootstrap.pypa.io/ez_setup.py  --no-check-certificate  //下载一个ez_setup 安装pip2.7版本的

# python2.7   ez_setup.py

# easy_install-2.7   pip

# pip2.7 install   MySQL-python

# yum install mysql-devel  //如果报错看看是不是缺失mysql-devel包。

# pip2.7 install flask_wtf

# pip2.7  install flask-script

# pip2.7 install flask-debugtoolbar

安装步骤:

# unzip inception_web-master.zip
# cd inception_web-master
# vim inception.py //修改配置文件

inception_web-master目录下运行

# ./run.py runserver --host 0.0.0.0  //启动服务

在浏览器输入http://192.168.**:5000




解决:

查看自身系统的Python 版本 python -V

先升级到Python 2.7 版本,下载 https://www.python.org/downloads/release/python-2711/

 并上传到服务器、解压

1
2
tar  -zxvf Python-2.7.11.tgz 
cd  Python-2.7.11/

编译安装

1
2
. /configure
make  &&  make  install

查看版本信息

1
/usr/local/bin/python  -V


 建立软连接,使系统默认的 python指向python2.7

1
2
mv  /usr/bin/python  /usr/bin/python2 .6.6
ln  -s  /usr/local/bin/python  /usr/bin/python


验证版本

1
python -V


 注:

1
vim  /usr/bin/yum

   修改#!/usr/bin/python #!/usr/bin/python2.6.6,因为yum安装依赖的是2.6版本的python,否则yum 安装用不了


下载一个ez_setup 安装pip2.7版本的                   

1
wget https: //bootstrap .pypa.io /ez_setup .py  --no-check-certificate
1
2
3
python2.7 ez_setup.py
easy_install-2.7 pip
pip2.7  install  MySQL-python


  * 出现报错的话 是缺少相关的 mysql-devel  

1
yum  install  -y mysql-devel

 pip 安装flask

1
pip2.7  install  flask_wtf



1
pip2.7  install  flask_script[object Object]


1
pip2.7  install  flask-debugtoolbar[object Object]


进入inception web的目录下运行 run.py

1
. /run .py runserver --host 0.0.0.0[object Object]

 注:记得在防火墙上面开启5000端口

 


*参考文档:http://blog.csdn.net/wulantian/article/details/48547711

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





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值