Inception初体验--安装

Inception初体验--安装

时间:2017-04-14 03:04:33      作者:beebol      标签: mysql inception 审核 上线平台      分类: mysql

1. Inception依赖安装

环境依赖都是少什么就安装什么就好了,这里只少了如下的包

yum install ncurses-devel  ncurses  cmake

2. 执行安装

  • 安装包

Inception开源GitHub地址: https://github.com/mysql-inception/inception.git

  • 安装

在安装目录执行:

sh inception_build.sh  debug linux

自动安装好后:

mv debug/mysql ~/inception
cd ~/inception && mkdir log etc tmp
  • 配置文件

    [inception]
    general_log=1
    general_log_file=/home/mysql/inception/log/inception.log
    port=6669
    bind_address=0.0.0.0  
    socket=/home/mysql/inception/tmp/inc.socket
    character-set-client-handshake=0
    character-set-server=utf8
    inception_remote_system_password=root
    inception_remote_system_user=root
    inception_remote_backup_port=3307
    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_ddl_support=on  #加上ddl支持,不然审核时会提示不支持DDL

    参数的含义可以见文档:http://mysql-inception.github.io/inception-document/variables/

  • 启动Inception

    nohup ./bin/Inception --defaults-file=/home/mysql/inception/etc/inc.cnf &

    没有报错,表示就没有问题,可以登录测试。

  • 开始使用 通过mysql客户端可以访问

    mysql -h127.0.0.1 -P6669  

    编写一个python脚本,就可以使用审核,上线了。

    #!/usr/bin/python
    #-\*-coding: utf-8-\*-
    import MySQLdb
    sql='/*--user=root;--password=root;--host=127.0.0.1;--check=1;--port=3307;*/\
    inception_magic_start;\
    create database inception_test;\
    use inception_test;\
    CREATE TABLE adaptive_office(id int);\
    inception_magic_commit;'
    try:
    conn=MySQLdb.connect(host='127.0.0.1',user='',passwd='',db='',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])

    执行结果:

    python test.py
    ['ID', 'stage', 'errlevel', 'stagestatus', 'errormessage', 'SQL', 'Affected_rows', 'sequence', 'backup_dbname', 'execute_time', 'sqlsha1']
    1 | CHECKED | 1 | Audit completed | Set charset to one of 'utf8mb4' for table 'inception_test'. | 2 | CHECKED | 0 | Audit completed | None | 3 | CHECKED | 1 | Audit completed | Set engine to innodb for table 'adaptive_office'.
    Set charset to one of 'utf8mb4' for table 'adaptive_office'.
    Set comments for table 'adaptive_office'.
    Column 'id' in table 'adaptive_office' have no comments.
    Column 'id' in table 'adaptive_office' is not allowed to been nullable.
    Set Default value for column 'id' in table 'adaptive_office'
    Set a primary key for table 'adaptive_office'. |
  • 后记 通过后面的审核结果来看,这是一个非常不错的mysql审核工具,很清晰地将审核结果显示出来。后面再继续测试下审核、上线执行、备份、回滚。

时间:2017-04-14 03:04:33      作者:beebol      标签: mysql inception 审核 上线平台      分类: mysql
  • 分享到:
  • 微博
  • QQ空间
  • 腾讯微博
  • 微信

Copyright © 2015 Gitblog | Proudly powered by Gitblog.