Skip to content

Commit

Permalink
v1.3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
hhyo committed Sep 29, 2018
1 parent 7ba1702 commit 49911b1
Show file tree
Hide file tree
Showing 19 changed files with 64 additions and 98 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*.log
.idea/
.DS_Store
archer/settings.py.github
archer/settings.py.dev
archery/settings.py.github
archery/settings.py.dev
sql/migrations/
venv
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ services:
install:
- pip install -r requirements.txt
before_script:
- mysql -e "CREATE DATABASE archer_master CHARSET UTF8;"
- mysql -e "CREATE DATABASE archery CHARSET UTF8;"
- python manage.py makemigrations
- python manage.py makemigrations sql
script:
Expand Down
63 changes: 25 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[![Build Status](https://travis-ci.org/hhyo/archer.svg?branch=master)](https://travis-ci.org/hhyo/archer)
[![Build Status](https://travis-ci.org/hhyo/archery.svg?branch=master)](https://travis-ci.org/hhyo/archery)

介绍
============
项目基于archer,不定期更新,有问题请提交issues,[查看开发计划](https://github.com/hhyo/archer/projects/1)
- [文档](https://github.com/hhyo/archer/wiki)
- [release版本](https://github.com/hhyo/archer/releases/)
项目基于[archer](https://github.com/jly8866/archer),不定期更新,有问题请提交issues
- [文档](https://github.com/hhyo/archery/wiki)
- [release版本](https://github.com/hhyo/archery/releases/)

快速开始
===============
Expand All @@ -18,33 +18,8 @@
| DBA| dba | archer |

### Docker
archer镜像https://dev.aliyun.com/detail.html?spm=5176.1972343.2.14.58c75aaaaSPjnX&repoId=142147
archery镜像https://dev.aliyun.com/detail.html?spm=5176.1972343.2.2.58c75aaa3iK1Sb&repoId=244140
inception镜像: https://dev.aliyun.com/detail.html?spm=5176.1972343.2.12.7b475aaaLiCfMf&repoId=142093
#### 单个容器启动
```bash
#新建Docker网络(inception直接通过容器名连接)
docker network create -d bridge archer-net

#准备inc.cnf文件,启动inception
docker run --name inception --network archer-net -v /your_path/inc.cnf:/etc/inc.cnf -p 6669:6669 -dti registry.cn-hangzhou.aliyuncs.com/lihuanhuan/inception

#准备settings.py文件,启动archer,tag对应release版本,如1.3.2
docker run --name archer --network archer-net -v /your_path/:/opt/archer/downloads -v /your_path/settings.py:/opt/archer/archer/settings.py -e NGINX_PORT=9123 -p 9123:9123 -dti registry.cn-hangzhou.aliyuncs.com/lihuanhuan/archer:tag

#表结构初始化
docker exec -ti archer /bin/bash
cd /opt/archer
source /opt/venv4archer/bin/activate
python3 manage.py makemigrations sql
python3 manage.py migrate

#创建管理用户
python3 manage.py createsuperuser

#启动日志查看和问题排查
docker logs archer
cat /tmp/archer.log
```

#### docker-compose

Expand Down Expand Up @@ -85,26 +60,38 @@ services:
volumes:
- "./inception/inc.cnf:/etc/inc.cnf"

archer:
image: registry.cn-hangzhou.aliyuncs.com/lihuanhuan/archer:1.3.2
container_name: archer
archery:
image: registry.cn-hangzhou.aliyuncs.com/lihuanhuan/archery:1.3.3
container_name: archery
restart: always
ports:
- "9123:9123"
volumes:
- "./archer/settings.py:/opt/archer/archer/settings.py"
- "./archer/downloads:/opt/archer/downloads"
command: ["bash","/opt/archer/src/docker/startup.sh"]
- "./archery/settings.py:/opt/archery/archer/settings.py"
- "./archery/downloads:/opt/archery/downloads"
command: ["bash","/opt/archery/src/docker/startup.sh"]
environment:
NGINX_PORT: 9123

```
```bash
#表结构初始化
docker exec -ti archery /bin/bash
cd /opt/archery
source /opt/venv4archery/bin/activate
python3 manage.py makemigrations sql
python3 manage.py migrate

#创建管理用户
python3 manage.py createsuperuser

#启动日志查看和问题排查
docker logs archery
```

手动安装
===============
[部署说明](https://github.com/hhyo/archer/wiki/%E9%83%A8%E7%BD%B2)

[部署说明](https://github.com/hhyo/archery/wiki/%E9%83%A8%E7%BD%B2)

依赖或引用项目
===============
Expand Down
File renamed without changes.
35 changes: 7 additions & 28 deletions archer/settings.py → archery/settings.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,11 @@
# -*- coding: UTF-8 -*-

"""
Django settings for archer project.
Generated by 'django-admin startproject' using Django 1.8.17.
For more information on this file, see
https://docs.djangoproject.com/en/1.8/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.8/ref/settings/
"""

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'hfusaf2m4ot#7)fkw#di2bu6(cv0@opwmafx5n#6=3d%x^hpl6'

Expand Down Expand Up @@ -59,7 +45,7 @@
'common.middleware.exception_logging_middleware.ExceptionLoggingMiddleware',
)

ROOT_URLCONF = 'archer.urls'
ROOT_URLCONF = 'archery.urls'

TEMPLATES = [
{
Expand All @@ -78,11 +64,9 @@
},
]

WSGI_APPLICATION = 'archer.wsgi.application'
WSGI_APPLICATION = 'archery.wsgi.application'

# Internationalization
# https://docs.djangoproject.com/en/1.8/topics/i18n/

LANGUAGE_CODE = 'zh-hans'

TIME_ZONE = 'Asia/Shanghai'
Expand All @@ -97,8 +81,6 @@
DATE_FORMAT = 'Y-m-d'

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.8/howto/static-files/

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATICFILES_DIRS = [os.path.join(BASE_DIR, 'common/static'), ]
Expand All @@ -108,14 +90,11 @@

###############以下部分需要用户根据自己环境自行修改###################

# Database
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases

# 该项目本身的mysql数据库地址
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'archer_master',
'NAME': 'archery',
'USER': 'root',
'PASSWORD': '',
'HOST': '127.0.0.1',
Expand All @@ -125,7 +104,7 @@
'charset': 'utf8mb4'
},
'TEST': {
'NAME': 'test_archer',
'NAME': 'test_archery',
'CHARSET': 'utf8',
},
}
Expand All @@ -146,7 +125,7 @@
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
'LOCATION': os.path.join(BASE_DIR, "archer"),
'LOCATION': os.path.join(BASE_DIR, "archery"),
}
}

Expand All @@ -164,7 +143,7 @@
AUTH_LDAP_SERVER_URI = "ldap://xxx"
AUTH_LDAP_USER_DN_TEMPLATE = "cn=%(user)s,ou=xxx,dc=xxx,dc=xxx"
AUTH_LDAP_ALWAYS_UPDATE_USER = True # 每次登录从ldap同步用户信息
AUTH_LDAP_USER_ATTR_MAP = { # key为archer.sql_users字段名,value为ldap中字段名,用户同步信息
AUTH_LDAP_USER_ATTR_MAP = { # key为archery.sql_users字段名,value为ldap中字段名,用户同步信息
"username": "cn",
"display": "displayname",
"email": "mail"
Expand Down Expand Up @@ -203,7 +182,7 @@
'handlers': ['default'],
'level': 'DEBUG',
},
'django_apscheduler': { # django_auth_ldap模块相关日志
'django_apscheduler': { # django_apscheduler模块相关日志
'handlers': ['default'],
'level': 'DEBUG',
},
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions archer/wsgi.py → archery/wsgi.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
WSGI config for archer project.
WSGI config for archery project.
It exposes the WSGI callable as a module-level variable named ``application``.
Expand All @@ -11,6 +11,6 @@

from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "archer.settings")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "archery.settings")

application = get_wsgi_application()
2 changes: 1 addition & 1 deletion common/templates/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ <h4 class="modal-title" id="myModalLabel">

<!--底部部分 -->
<div class="row clearfix user-bottom-div">
<p><strong>SQL审核平台</strong>&nbsp;(v1.3.2)</p>
<p><strong>SQL审核平台</strong>&nbsp;(v1.3.3)</p>
</div>
<!-- jQuery (Bootstrap 的 JavaScript 插件需要引入 jQuery,务必先引入jquery js再引入bootstrap js) -->
<script src="{% static 'jquery/jquery.min.js' %}"></script>
Expand Down
2 changes: 1 addition & 1 deletion common/utils/chart_dao.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


class ChartDao(object):
# 直接在archer数据库查询数据,用于报表
# 直接在archery数据库查询数据,用于报表
def __query(self, sql):
cursor = connection.cursor()
effect_row = cursor.execute(sql)
Expand Down
2 changes: 1 addition & 1 deletion common/utils/sendmsg.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def send_email(self, strTitle, strContent, listToAddr, **kwargs):
main_msg.attach(file_msg)

# 收发件人地址和邮件标题:
main_msg['From'] = formataddr(["archer 通知", self.MAIL_REVIEW_FROM_ADDR])
main_msg['From'] = formataddr(["archery 通知", self.MAIL_REVIEW_FROM_ADDR])
main_msg['To'] = ','.join(listToAddr)
listCcAddr = kwargs.get('listCcAddr')
if listCcAddr:
Expand Down
2 changes: 1 addition & 1 deletion manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import sys

if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "archer.settings")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "archery.settings")

from django.core.management import execute_from_command_line

Expand Down
2 changes: 1 addition & 1 deletion sql/utils/data_masking.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def analy_query_tree(self, query_tree, instance_name):
for
select_item in select_list if select_item['type'] in ('FIELD_ITEM', 'aggregate')]

# 处理select_list,为统一的{'type': 'FIELD_ITEM', 'db': 'archer_master', 'table': 'sql_users', 'field': 'email'}格式
# 处理select_list,为统一的{'type': 'FIELD_ITEM', 'db': 'archery_master', 'table': 'sql_users', 'field': 'email'}格式
select_list = [select_item if select_item['type'] == 'FIELD_ITEM' else select_item['aggregate'] for
select_item in select_list if select_item['type'] in ('FIELD_ITEM', 'aggregate')]

Expand Down
2 changes: 1 addition & 1 deletion sql/utils/execute_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def send_msg(workflowDetail, url):

if send == 1:
# 消息内容通知
msg_title = '[Archer]有新的DDL语句执行完成#{}'.format(audit_id)
msg_title = '[archery]有新的DDL语句执行完成#{}'.format(audit_id)
msg_content = '''发起人:{}\n变更组:{}\n变更实例:{}\n变更数据库:{}\n工单名称:{}\n工单地址:{}\n工单预览:{}\n'''.format(
Users.objects.get(username=workflowDetail.engineer).display,
workflowDetail.group_name,
Expand Down
18 changes: 9 additions & 9 deletions src/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ RUN yum -y install wget gcc make zlib-devel openssl openssl-devel \
&& pip3 install virtualenv -i https://mirrors.ustc.edu.cn/pypi/web/simple/ \
&& cd /opt \
&& ln -fs /usr/local/python3/bin/virtualenv /usr/bin/virtualenv \
&& virtualenv venv4archer --python=python3 \
&& virtualenv venv4archery --python=python3 \
&& rm -rf Python-3.6.5 \
&& rm -rf Python-3.6.5.tar.xz \
#修改中文支持
Expand Down Expand Up @@ -46,20 +46,20 @@ RUN cd /opt \
&& cd /opt && rm -rf /opt/SchemaObject/ && rm -rf /opt/SchemaSync/ \
&& yum install -y python-devel \
&& pip install mysql-python
#archer
#archery
RUN cd /opt \
&& yum -y install openldap-devel nginx \
&& git clone https://github.com/hhyo/archer.git && cd archer && git checkout v1.3.2 \
&& source /opt/venv4archer/bin/activate \
&& pip3 install -r /opt/archer/src/docker/requirements.txt -i https://mirrors.ustc.edu.cn/pypi/web/simple/ \
&& cp /opt/archer/src/docker/connections.py /opt/venv4archer/lib/python3.6/site-packages/MySQLdb/connections.py \
&& cp /opt/archer/src/docker/nginx.conf /etc/nginx/
&& git clone https://github.com/hhyo/archery.git && cd archery && git checkout v1.3.3 \
&& source /opt/venv4archery/bin/activate \
&& pip3 install -r /opt/archery/src/docker/requirements.txt -i https://mirrors.ustc.edu.cn/pypi/web/simple/ \
&& cp /opt/archery/src/docker/connections.py /opt/venv4archery/lib/python3.6/site-packages/MySQLdb/connections.py \
&& cp /opt/archery/src/docker/nginx.conf /etc/nginx/

ENV LANG en_US.UTF-8
ENV LC_ALL zh_CN.utf8
ENV LC_ALL zh_CN.utf8

#port
EXPOSE 9123

#start service
ENTRYPOINT bash /opt/archer/src/docker/startup.sh && bash
ENTRYPOINT bash /opt/archery/src/docker/startup.sh && bash
4 changes: 2 additions & 2 deletions src/docker/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ http {

server{
listen 9123; #监听的端口
server_name archer;
server_name archery;
client_max_body_size 20M;
proxy_read_timeout 600s;

Expand All @@ -52,7 +52,7 @@ http {
}

location /static {
alias /opt/archer/static;
alias /opt/archery/static;
}

error_page 404 /404.html;
Expand Down
8 changes: 4 additions & 4 deletions src/docker/startup.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/bin/bash

cd /opt/archer
cd /opt/archery
#切换python运行环境
source /opt/venv4archer/bin/activate
source /opt/venv4archery/bin/activate
#修改重定向端口
if [ -z $NGINX_PORT ]; then
sed -i "s/:nginx_port//g" /etc/nginx/nginx.conf
Expand All @@ -15,8 +15,8 @@ fi
#收集所有的静态文件到STATIC_ROOT
python3 manage.py collectstatic -v0 --noinput

settings=${1:-"archer.settings"}
settings=${1:-"archery.settings"}
ip=${2:-"127.0.0.1"}
port=${3:-8888}

gunicorn -w 4 --env DJANGO_SETTINGS_MODULE=${settings} --error-logfile=/tmp/archer.err -b ${ip}:${port} --timeout 600 archer.wsgi:application
gunicorn -w 4 --env DJANGO_SETTINGS_MODULE=${settings} --error-logfile=/tmp/archery.err -b ${ip}:${port} --timeout 600 archery.wsgi:application
2 changes: 1 addition & 1 deletion src/docs/mysql_db_design_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ MySQL数据库与 Oracle、 SQL Server 等数据库相比,有其内核上的

详细存储大小参加下图:

![MySQL数据类型存储大小](https://github.com/kylexlau/archer/raw/master/sql/static/pics/mysql_datatype.png)
![MySQL数据类型存储大小](https://github.com/kylexlau/archery/raw/master/sql/static/pics/mysql_datatype.png)

### 2.1.4 索引设计

Expand Down
Loading

0 comments on commit 49911b1

Please sign in to comment.