Inception是集审核SQL、执行SQL、回滚于一体的一个自动化运维系统。
#ssh 192.168.163.128 //我的测试机
下载Inception
#mkdir -p /songlisha/inception
#cd /songlisha/inception
#wget https://github.com/mysql-inception/inception/archive/master.zip
安装Inception
# unzip master.zip
# mkdir inception data //建inception的安装目录和数据目录
#cd inception-master
# cmake -DWITH_DEBUG=OFF -DCMAKE_INSTALL_PREFIX=/songlisha/inception/inception -DMYSQL_DATADIR=/songlisha/inception/data -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”
编译时报错啦!如下图所示:
解决办法(安装inception所需要的模块):
#yum -y install cmake libncurses5-dev libssl-dev g++ bison openssl-devel.x86_64
#sh -x inception_build.sh debug
# sh inception_build.sh debug [linux]
报错如下:
解决办法:
# make -j6 && make install
安装完毕后添加配置文件:
#vim /songlisha/inception/inc.cnf
[inception]
general_log=1
general_log_file=/songlisha/inception/data/inception.log
port=6669
socket=/songlisha/inception/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=/songlisha/inception/data/temp
inception_osc_chunk_time=0.1
inception_ddl_support=1
inception_enable_blob_type=1
inception_check_column_default_value=1
# mkdir -p /songlisha/inception/data/temp //创建配置文件中没有的目录
启动Inception.
现在就到启动时间了,那么启动有两种方式,和MySQL是一样的
1.配置文件启动。
#/songlisha/inception/inception/bin/Inception –defaults-file=/songlisha/inception/inc.cnf
2. 端口启动。
#/songlisha/inception/inception/bin/Inception –port=6669
我使用第一种方式启动成功。
测试Inception
# mysql -uroot -h127.0.0.1 -P6669
mysql> inception get variables; //列出所有参数,启动成功!
安装pip //pip类似RedHat里面的yum,安装Python包非常方便。
# cd /songlisha/inception
# wget “https://pypi.python.org/packages/source/p/pip/pip-1.5.4.tar.gz#md5=834b2904f92d46aaa333267fb1c922bb” –no-check-certificate
#tar zxvf pip-1.5.4.tar.gz
#cd pip-1.5.4
#python setup.py install
先安装依赖模块
#pip install flask_wtf
#pip install flask-script
#pip install flask-debugtoolbar
#pip install MySQL-python
报错如下:
error: command ‘gcc’ failed with exit status 1
Cleaning up…
Command /usr/bin/python -c “import setuptools, tokenize;__file__=’/tmp/pip_build_root/MySQL-python/setup.py’;exec(compile(getattr(tokenize, ‘open’, open)(__file__).read().replace(‘\r\n’, ‘\n’), __file__, ‘exec’))” install –record /tmp/pip-lhP9WW-record/install-record.txt –single-version-externally-managed –compile failed with error code 1 in /tmp/pip_build_root/MySQL-python
Traceback (most recent call last):
File “/usr/bin/pip”, line 9, in <module>
load_entry_point(‘pip==1.5.4’, ‘console_scripts’, ‘pip’)()
File “/usr/lib/python2.6/site-packages/pip-1.5.4-py2.6.egg/pip/__init__.py”, line 185, in main
return command.main(cmd_args)
File “/usr/lib/python2.6/site-packages/pip-1.5.4-py2.6.egg/pip/basecommand.py”, line 161, in main
text = ‘\n’.join(complete_log)
UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xe2 in position 33: ordinal not in range(128)
解决办法:
# yum install gcc libffi-devel python-devel openssl-devel -y
#pip install MySQL-python //再次执行安装成功!
安装git
# yum -y install git
安装inception_web
# git clone https://github.com/dbalihui/inception_web.git
#cd /songlisha/inception/inception_web/app
# cat inception.py //修改配置文件中的用户名密码
#coding=utf-8
import MySQLdb
def table_structure(mysql_structure):
sql1=’/*–user=root;–password=root;–host=127.0.0.1;–execute=1;–port=3306;*/\
inception_magic_start;\
use songlisha;’ //这里改成自己的数据库名字
sql2=’inception_magic_commit;’
sql = sql1 + mysql_structure + sql2
try:
conn=MySQLdb.connect(host=’127.0.0.1′,user=’root’,passwd=’root’,db=’songlisha’,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”)
#cd /songlisha/inception/inception_web/
# ./run.py runserver –host 127.0.0.1
报错如下:
/songlisha/inception/inception_web/app/__init__.py:7: ExtDeprecationWarning: Importing flask.ext.script is deprecated, use flask_script instead.
from flask.ext.script import Manager
Traceback (most recent call last):
File “./run.py”, line 7, in <module>
from app import app,manager
File “/songlisha/inception/inception_web/app/__init__.py”, line 7, in <module>
from flask.ext.script import Manager
File “/usr/lib/python2.6/site-packages/flask/exthook.py”, line 96, in load_module
reraise(exc_type, exc_value, tb.tb_next)
File “/usr/lib/python2.6/site-packages/flask_script/__init__.py”, line 11, in <module>
import argparse
ImportError: No module named argparse //缺少argparse 模块
解决办法:
# easy_install argparse //安装该模块
再次
# ./run.py runserver –host 127.0.0.1
再次报错:
ImportError: libmysqlclient.so.18: cannot open shared object file: No such file or directory
解决办法:
# ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64/libmysqlclient.so.18
# ./run.py runserver –host 127.0.0.1 //执行成功!但是无法从浏览器访问到哦。
# ./run.py runserver –host 192.168.163.128 //必须得使用本机IP才能用浏览器访问
在浏览器中访问我的页面
http://192.168.163.128:5000/
但是:# ./run.py runserver –host 192.168.163.128
此命令一退出,我的浏览器就不能访问啦!404
screen -S server_ name 创建一个窗口管理器
ctrl + a + c 创建一个窗口
ctrl + a + n 切换到下一个窗口
ctrl + a + d 最小化窗口管理器
screen -dr server_name 重新打开窗口管理器
screen -ls 列出窗口管理器列表
本文永久更新链接地址:http://www.linuxidc.com/Linux/2018-01/150623.htm