Centos7.4 安裝 Inception

Cetos7.4系統  環境設置

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


cd /usr/local/src/
wget http://ftp.gnu.org/gnu/m4/m4-1.4.18.tar.gz
tar -zxvf m4-1.4.18.tar.gz
cd m4-1.4.18
./configure && make && make install



wget  http://ftp.gnu.org/gnu/bison/bison-2.4.tar.gz
tar -zxvf bison-2.4.tar.gz
cd bison-2.4/
./configure





cd /usr/local/
wget https://github.com/mysql-inception/inception/archive/master.zip
unzip master.zip
mv inception-master/  inception
mv master.zip inception.zip
mv inception.zip   /usr/local/src/
sh inception_build.sh builddir  linux



配置文件

vim   inc.cnf
[inception]
general_log=1
general_log_file=inception.log
port=6669
socket=/tmp/mysql.sock
character-set-client-handshake=0
character-set-server=utf8
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
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


啓動測試

nohup    /usr/local/inception/builddir/mysql/bin/Inception  --defaults-file=inc.cnf   >/dev/null  2>&1   &


mysql -uroot -h127.0.0.1 -P6669

inception get variables;


安裝測試完成。


python3  

由於python3使用的pymysql模塊裏並未兼容inception返回的server信息,因此需要編輯/path/to/python3/lib/python3.4/site-packages/pymysql/connections.py:

在if int(self.server_version.split('.', 1)[0]) >= 5: 這一行之前加上以下這一句並保存,記得別用tab鍵用4個空格縮進:

self.server_version = '5.6.24-72.2-log'

#/usr/bin/python
#_*_ coding:utf-8  _*_
import pymysql.cursors
sql='/*--user=root;--password=123456;--host=192.168.10.81;--execute=1;--port=3306;*/\
inception_magic_start;\
use hequan;\
CREATE TABLE adaptive_office(id int);\
inception_magic_commit;'
try:
    conn=pymysql.connect(host='127.0.0.1',user='',passwd='',db='',port=6669)
    cursor=conn.cursor()
    cursor.execute(sql)
    results = cursor.fetchall()
    column_name_max_size=max(len(i[0]) for i in cursor.description)
    row_num=0
    for result in results:
        row_num=row_num+1
        print('*'.ljust(27,'*'),row_num,'.row', '*'.ljust(27,'*'))
        row = map(lambda x, y: (x,y), (i[0] for i in cursor.description), result)
        for each_column in row:
            if each_column[0] != 'errormessage':
                print(each_column[0].rjust(column_name_max_size),":",each_column[1])
            else:   
                print(each_column[0].rjust(column_name_max_size),':',each_column[1].replace('\n','\n'.ljust(column_name_max_size+4)))
    cursor.close()
    conn.close()
except pymysql.Error as e:
     print("Mysql Error %d: %s" % (e.args[0], e.args[1]))


*************************** 1 .row ***************************

           ID : 1

        stage : CHECKED

     errlevel : 0

  stagestatus : Audit completed

errormessage : None

          SQL : use hequan

Affected_rows : 0

     sequence : '0_0_0'

backup_dbname : None

execute_time : 0

      sqlsha1 :

*************************** 2 .row ***************************

           ID : 2

        stage : CHECKED

     errlevel : 2

  stagestatus : Audit completed

errormessage : Table 'adaptive_office' already exists.

                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'.

          SQL : CREATE TABLE adaptive_office(id int)

Affected_rows : 0

     sequence : '0_0_1'

backup_dbname : 192_168_10_81_3306_hequan

execute_time : 0

      sqlsha1 :


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章