In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
# yum install cmake bison ncurses-devel gcc gcc-c++ openssl-devel
Download and extract wget https://github.com/mysql-inception/inception/archive/master.zip
# mkdir / usr/local/inception installation directory
# mkdir / inception
# mkdir {data,logs}
# 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
Edit the configuration file (create it yourself)
# vim / etc/inc.cnf
[inception]
General_log=1 # is the parameter of the native MySQL, which is used to record which statements have been executed on the Inception service, to locate some problems, and so on.
General_log_file=/usr/local/inception/data/inception.log # sets the file path written by general log
Service port of port=6669 # Inception
Socket file location of socket=/usr/local/inception/data/inc.socket # Inception
Character-set-server=utf8 # mysql native parameters
# Inception Audit rules
Inception_check_autoincrement_datatype=1 # when creating a table, the type of self-incrementing column is not int or bigint Times error
Inception_check_autoincrement_init_value=1 # an error is reported if the value of the self-incrementing column is not specified as 1 when the table is created
Inception_check_autoincrement_name=1 # when creating a table, if the name of the specified self-incrementing column is not ID, an error will be reported, which is meaningful. Give a hint.
When inception_check_column_comment=1 # created the table, there was no comment in the column.
Inception_check_column_default_value=0 # check whether the new column properties should have default values when creating tables, modifying columns, and adding new columns
Does inception_check_dml_limit=1 # report an error when it uses LIMIT in the DML statement
Does inception_check_dml_orderby=1 # report an error when it uses Order By in the DML statement
Does inception_check_dml_where=1 # report an error when there is no WHERE condition in the DML statement?
Inception_check_identifier=1 # turns on and off Inception's checking of various names in SQL statements. If set to ON, if characters other than numbers, letters, or underscores are found in the name, it will report Identifier "invalidname" is invalid, valid options: [Identifier ZMague 0-9 invalidname _].
Does inception_check_index_prefix=1 # check that the index name is prefixed with "idx_" and that the unique index prefix is "uniq_"
Does inception_check_insert_field=1 # check the existence of column linked lists in insert statements?
Inception_check_primary_key=1 # when creating a table, if there is no primary key, an error will be reported
When inception_check_table_comment=1 # created the table, there was no comment on the table.
Inception_check_timestamp_default=0 # error is reported if no default value is specified for the timestamp type when creating the table
Does inception_enable_autoincrement_unsigned=1 # self-increment column want to be unsigned?
Inception_enable_blob_type=0 # checks whether BLOB fields are supported, including creating tables, modifying columns, and adding columns. Default is enabled.
Inception_enable_column_charset=0 # allows columns to set their own character sets
Does inception_enable_enum_set_bit=0 # support enum,set,bit data types?
Does inception_enable_foreign_key=0 # support foreign keys?
Inception_enable_identifer_keyword=0 # checks to see if there is an identifier written as a MySQL keyword in the SQL statement. The default value is alarm.
The storage engine specified in inception_enable_not_innodb=0 # table creation is not Innodb and does not report errors.
Inception_enable_nullable=0 # does not report an error if it is listed as NULL when creating or adding a column
Is there an error in inception_enable_orderby_rand=0 # orderby rand?
Does inception_enable_partition_table=0 # support partitioned tables?
Do you have to report an error when inception_enable_select_star=0 # Select*
Whether the inception_enable_sql_statistic=1 # setting supports statistics on the proportion of various statements executed by Inception. If this parameter is enabled, the statistics of this operation will be stored in the statistic table of the inception library in the backup database instance. Each operation corresponds to a record. The information contained in this record is the number of statements executed of various types.
Inception_max_char_length=16 # when the length of the char type is greater than this value, you are prompted to convert it to VARCHAR
Inception_max_key_parts=5 # the maximum number of columns in an index. If you exceed this number, an error will be reported.
Inception_max_keys=16 # the maximum number of indexes in a table. If you exceed this number, an error will be reported
Inception_max_update_rows=10000 # in a modification statement, the maximum number of rows expected to be affected is greater than this number, an error is reported
Inception_merge_alter_table=1 # appears in multiple statements that change the same table, reporting an error and prompting to synthesize one
# inception supports OSC parameters
Inception_osc_bin_dir=/user/bin # is used to specify the location of the pt-online-schema-change script, which cannot be modified, and is set in the configuration file
Inception_osc_check_interval=5 # corresponds to the OSC parameter-check-interval, which means Sleep time between checks for-- max-lag.
Inception_osc_chunk_size=1000 # corresponds to OSC parameter-chunk-size
Inception_osc_chunk_size_limit=4 # corresponds to OSC parameter-chunk-size-limit
Inception_osc_chunk_time=0.1 # corresponds to OSC parameter-chunk-time
Inception_osc_critical_thread_connected=1000 # corresponding parameter-- thread_connected part of critical-load
Inception_osc_critical_thread_running=80 # corresponding parameter-- thread_running part of critical-load
Inception_osc_drop_new_table=1 # corresponding parameter-- [no] drop-new-table
Inception_osc_drop_old_table=1 # corresponding parameter-- [no] drop-old-table
Inception_osc_max_lag=3 # corresponding parameter-max-lag
Inception_osc_max_thread_connected=1000 # corresponding parameter-- thread_connected part of max-load
Inception_osc_max_thread_running=80 # corresponding parameter-- thread_running part of max-load
The parameter inception_osc_min_table_size=0 # is actually a switch for OSC. If set to 0, all ALTER statements go OSC. If set to non-0, the OSC mode is used when the space occupied by the table is greater than this value. In M, the size of this table is calculated by the statement "select (DATA_LENGTH + INDEX_LENGTH) / 1024 INDEX_LENGTH 1024 from information_schema.tables where table_schema = 'dbname' and table_name =' tablename'"
Inception_osc_on=1 # A global OSC switch, which is on by default and set to OFF if you want to turn it off, so it can be modified directly.
Inception_osc_print_none=1 # is used to set the returned result set in Inception. If the standard output information of the original OSC is printed to the corresponding error information column of the result set, if it is set to 1, it will not be printed. If set to 0, it will be printed. If there is an error, it will be printed.
Inception_osc_print_sql=1 # corresponding parameter-print
# back up the server information and change it to your machine
Inception_remote_system_password=123456
Inception_remote_system_user=root
Inception_remote_backup_port=3306
Inception_remote_backup_host=192.168.99.205
Inception_support_charset=utf8 # indicates the character set supported when building a table or database. If more than one is needed, it is separated by a comma. The scope of influence is to create a table, set a session character set, modify the attributes of a table character set, etc.
Start
# nohup / usr/local/inception/bin/Inception-- defaults-file=/etc/inc.cnf &
# netstat-tulpn | the default port of grep 6669 / / inception is 6669
# cd / usr/local/inception/bin/
#. / mysql-uroot-h227.0.0.1-P6669 / / Connect inception in the same way as mysql
# inception get variables; / / View all parameters of inception
Currently, inception supports python, c and C++ interfaces.
# vim aaa.py
#! / usr/bin/python
#-*-coding: utf-8-*-
Import MySQLdb
Sql='/*--user=user;--password=pass;--host=x.x.x.x;--port=3306;--execute=1;*/\ # here are the addresses and users of your mysql
Inception_magic_start;\
Use optest;\
CREATE TABLE xxx (id int unsigned not null auto_increment comment "aaaa", username varchar (10) not null default 0 comment "xxx", primary key (id)) engine = innodb charset=utf8 comment "dddd";
Inception_magic_commit;'
# insert into adaptive_office (username) values ("ASD"), ("ZXC"), ("EST")
Try:
Conn=MySQLdb.connect (host='127.0.0.1',user='admin',passwd='123456',db='',port=6669) # here is for backing up the database (my inception and mysql are installed on the same machine)
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 recordings), row_num,'.row',' * .ljust (27 recordings)
Row = map (lambda XQuery y: (XMague 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'.ljust (column_name_max_size+4)')
Cursor.close ()
Conn.close ()
Except MySQLdb.Error,e:
Print "Mysql Error% d:% s"% (e.args [0], e.args [1])
* * INCEPTION_WEB * *
Upgrade python to 2.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 / / verify version
# vim / usr/bin/yum
Modify #! / usr/bin/python to #! / usr/bin/python2.6.6, because the yum installation depends on version 2.6 of python
Installation module
# yum-y install python-pip / / this installation process is version 2.6
# wget https://bootstrap.pypa.io/ez_setup.py-- no-check-certificate / / download an ez_setup to install the pip2.7 version
# python2.7 ez_setup.py
# easy_install-2.7 pip
# pip2.7 install MySQL-python
# yum install mysql-devel / / if an error is reported, see if the mysql-devel package is missing. Reinstalling MySQL-python
# pip2.7 install flask_wtf
# pip2.7 install flask-script
# pip2.7 install flask-debugtoolbar
Installation
# unzip inception_web-master.zip
# cd inception_web-master/app
# vim inception.py / / modify the configuration file and pay attention to the configuration host and password below.
# coding=utf-8
Import MySQLdb
Def table_structure (mysql_structure):
Sql1='/*--user=root;--password=123456;--host=127.0.0.1;--execute=1;--port=3306;*/\ # actual database
Inception_magic_start;\
Use mysql;'
Sql2='inception_magic_commit;'
Sql = sql1 + mysql_structure + sql2
Try:
Conn=MySQLdb.connect (host='127.0.0.1',user='root',passwd='',db='',port=6669,use_unicode=True, charset= "utf8") # backup database
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")
Start
. / run.py runserver-- host 0.0.0.0 &
Enter ip:5000
This interface has not been updated for a long time, and can only do sql review, nothing else.
* * archer installation and deployment * *
Version
Python:3.4
Django:1.8
Mysql: 5.6 or above
Linux: 64-bit linux
# mkdir / op/archer_web/
# cd / opt/archer_web
# git clone https://github.com/jly8866/archer.git
Install python3
# cd / opt
# wget https://www.python.org/ftp/python/3.4.1/Python-3.4.1.tgz
# tar-zxvf Python-3.4.1.tgz
# cd Python-3.4.1
#. / configure-- prefix=/opt/python3 & & make & & make install
# vim / etc/profile
Add: export PATH= "/ opt/python3/bin:$PATH"
# source / etc/profile
# python3
Install setuptools
# wget-- no-check-certificate https://pypi.python.org/packages/source/s/setuptools/setuptools-19.6.tar.gz#md5=c607dd118eae682c44ed146367a17e26
# tar-zxvf setuptools-19.6.tar.gz
# cd setuptools-19.6
# python3 setup.py build
# python3 setup.py install
You can see that it is installed under python3.
Install pip
# wget-- no-check-certificate https://pypi.python.org/packages/source/p/pip/pip-8.0.2.tar.gz#md5=3a73c4188f8dbad6a1e6f6d44d117eeb
# tar-zxvf pip-8.0.2.tar.gz
# cd pip-8.0.2
# python3 setup.py build
# python3 setup.py install
Install Django
# wget https://pypi.python.org/packages/44/41/bf93934082e9897a56a591a67bacbd9fb74e71244f3f42253432a9e627e6/Django-1.8.17.tar.gz#md5=e76842cdfbcb31286bd44f51e087a04c
# tar-zxvf Django-1.8.17.tar.gz
# cd Django-1.8.17
# python3 setup.py install
# python3
Python 3.4.1 (default, Apr 15 2017, 14:11:11)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-18)] on linux
Type "help", "copyright", "credits" or "license" for more information.
> django.VERSION
(1,8,17, 'final', 0)
> > exit ()
Install Crypto and pymysql
# pip3 install Crypto
# pip3 install pycrypto
# pip3 install pymysql
An error has been encountered here.
# pip3 install Crypto
-bash:. / pip3: / usr/bin/python3: bad interpreter: No such file or directory
Solution:
Python3.4-m pip install Crypto
Or
Vim / opt/python3/bin/pip3
Change #! / usr/bin/python3 to #! / opt/python3/bin/python3.4
# vim / opt/python3/lib/python3.4/site-packages/pymysql/connections.py
Add the following sentence before if int (self.server_version.split ('.', 1) [0]) > = 5: this line and save it, remember not to use the tab key to indent with 4 spaces:
Self.server_version = '5.6.24-72.2 Mustang log'
Configure archer
1 、
# cd / opt/archef_web/archer
# ls
Archer debug.bat debug.sh docs LICENSE manage.py nohup.out README.md requirements.txt screenshots sql startup.sh stop.sh
# pip3 install-r requirements.txt
2. Create archer DB and inception DB
Enter the installed mysql5.6
Create database archer default character set utf8
Grant all on archer.* to archer_rw@'%' identified by 'xxx'
Create database inception_db default character set utf8
Grant all on inception_db.* to incep_rw@'%' identified by 'xxx'
Flush privileges
3. Modify / opt/archef_web/archer/archer/settings.py, as follows:
# the mysql database address of the project itself
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql'
'NAME': 'archer'
'USER': 'archer_rw'
'PASSWORD': 'xxx'
'HOST': '192.168.1.3'
'PORT': '3306'
}
}
# address where the inception component is located
INCEPTION_HOST = '192.168.1.123'
INCEPTION_PORT = '6669'
# it is used to view the rollback SQL. Here, you need to tell archer which mysql to read the rollback information and SQL of the inception backup.
# Note that this should be consistent with the inception_remote_XX part of the inception.conf of the inception component.
INCEPTION_REMOTE_BACKUP_HOST='192.168.1.3'
INCEPTION_REMOTE_BACKUP_PORT=3306
INCEPTION_REMOTE_BACKUP_USER='admin'
The user INCEPTION_REMOTE_BACKUP_PASSWORD='XXX' is the user who is deploying inception. (this user should be the same as the incep_rw created above, so you don't have to create an incep_rw.)
4. Create the database table of archer itself through model
# cd / opt/archef_web/archer
# python3 manage.py makemigrations or python3 manage.py makemigrations sql
Migrations for 'sql':
0001_initial.py:
-Create model users
-Create model master_config
-Create model workflow
# python3 manage.py migrate
Operations to perform:
Synchronize unmigrated apps: messages, staticfiles
Apply all migrations: sessions, auth, contenttypes, sql, admin
Synchronizing apps without migrations:
Creating tables...
Running deferred SQL...
Installing custom SQL...
Running migrations:
Rendering model states... DONE
Applying contenttypes.0001_initial... OK
Applying contenttypes.0002_remove_content_type_name... OK
Applying auth.0001_initial... OK
Applying auth.0002_alter_permission_name_max_length... OK
Applying auth.0003_alter_user_email_max_length... OK
Applying auth.0004_alter_user_username_opts... OK
Applying auth.0005_alter_user_last_login_null... OK
Applying auth.0006_require_contenttypes_0002... OK
Applying sql.0001_initial... OK
Applying admin.0001_initial... OK
Applying sessions.0001_initial... OK
Enter the database to check whether the table under the archer library exists.
5. Create a django admin administrator
# python3 manage.py createsuperuser
Username: admin fills in the user name herself
Email address: mailbox
Password: password
Password (again): confirm password
Superuser created successfully.
The user can log in to django admin to manage model.
6. Start acher
# vi debug.sh
#! / bin/bash
Python3 manage.py runserver 0.0.0.0 Port 9123 is 9123
# sh debug.sh or nohup sh debug.sh 2 & > 1 &
Performing system checks...
System check identified no issues (0 silenced).
April 15, 2017-16:39:11
Django version 1.8.17, using settings' archer.settings'
Starting development server at http://0.0.0.0:9123/
Quit the server with CONTROL-C.
Create an archer system login user
Access the ip:9123/admin/sql/users/ of the http://archer deployment machine through a browser
You can see the django login interface:
Log in with the username and password (admin/ and password) created in step 5 above:
Click on the right Add user configuration, user name password customization, create at least one engineer and one auditor (login with admin users) follow-up new engineers and auditors users please use LDAP to import sql_ users table or django admin add
Configure the main library address
Access http://192.168.1.123:9123/admin/sql/master_config through a browser
Click Add master_config on the right. This step is to tell archer which mysql main library you want to use inception to execute SQL, user name, password, port, etc.
Official visit to the home page
Http://192.168.1.123:9123/login/
After the successful landing
If you encounter the problem of rollback, it is the problem of giving permissions. The permissions of the users who connect to the database configured by inception, in the
Grant select,create,insert on *. * to incep_rw@'%' identified by 'XXX'
That is, the user of the admin I configured.
Inception source code address: https://github.com/mysql-inception/inception
Archer source code address: https://github.com/jly8866/archer
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.