inception安裝步驟---本身整理的安裝步驟
2015-09-18 15:51 6185人閱讀 評論(1) 收藏 舉報
分類: inception相關
版權聲明:本文爲博主原創文章,未經博主容許不得轉載。
目錄(?)[+]
1. 下載:
https://github.com/mysql-inception/inception 選擇下載:
Downloda ZIPpython
注意安裝包:
yum -y install cmake libncurses5-dev libssl-dev g++ bison openssl-devel.x86_64 mysql
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」。 中止。linux
# sh inception_build.sh debug [linux]
make: *** 沒有規則能夠建立目標「install」。 中止。git
解決辦法:# make -j6 && make installgithub
安裝完畢後添加配置文件:
#vim /etc/inc.cnf
[root@localhost ~]# cat /etc/inc.cnf
[inception]
general_log=1
general_log_file=/usr/local/inception/data/inception.log
port=6669
socket=/data/workspace/inception_data/inc.socket
character-set-client-handshake=0
character-set-server=utf8
inception_remote_system_password=123456
inception_remote_system_user=root
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_ddl_support=1
inception_enable_blob_type=1
inception_check_column_default_value=1web
//上面配置文件中用到的文件路徑,沒有的手動建立一下。
#mkdir -p /data/workspace/inception_data/
#mkdir -p /data/tempsql
6.啓動Inception. 如今就到啓動時間了,那麼啓動有兩種方式,和MySQL是同樣的
1. Inception –defaults-file=inc.cnf
2. Inception –port=6669數據庫
//啓動inception服務
#/usr/local/inception/bin/Inception --defaults-file=/etc/inc.cnf //啓動inception 有2種方式,在這採用配置文件啓動方式。flask
//測試inception。
測試以前建立一個能夠鏈接mysql的用戶:用戶名wwn 密碼:123456 IP:127.0.0.1 保證能正常登錄mysql便可。
# mysql -uroot -h127.0.0.1 -P6669 //登錄inception
登陸上去以後,再執行一個命令:
inception get variables;
輸出了全部的變量,恭喜你,已經啓動成功了,都說了很是簡單。bootstrap
[root@localhost app]# mysql -uroot -h127.0.0.1 -P6669
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 36
Server version: Inception2.0.18-beta 1
Copyright (c) 2000, 2013, 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>
下面用腳本測試相關的審覈語句:
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])
*************
3. 在網上下載一個web封裝的界面安裝過程以下:
下載地址:https://github.com/dbalihui/inception_web
環境配置
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 //修改配置文件
# ./run.py runserver --host 0.0.0.0 //啓動服務
配置文件信息以下:
[root@localhost inception_web-master]# cat /root/inception_web-master/app/inception.py
#coding=utf-8
import MySQLdb
def table_structure(mysql_structure): sql1='/*--user=wwn;--password=123456;--host=192.168.8.97;--execute=1;--port=3306;*/\ inception_magic_start;\ use wwn;' //此處數據庫是圖形界面框中選擇的數據,否則只寫create table會報錯提示要選擇數據庫。 sql2='inception_magic_commit;' sql = sql1 + mysql_structure + sql2 try: conn=MySQLdb.connect(host='127.0.0.1',user='wwn',passwd='123456',db='wwn',port=6669,use_unicode=True, charset="utf8") 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]) return result[1][4].split("\n")