From 49911b1a39f4b82ca9e227007f81ed2aff627885 Mon Sep 17 00:00:00 2001 From: hhyo Date: Fri, 28 Sep 2018 20:34:10 +0800 Subject: [PATCH] v1.3.3 --- .gitignore | 4 +- .travis.yml | 2 +- README.md | 63 ++++++++++++------------------- {archer => archery}/__init__.py | 0 {archer => archery}/settings.py | 35 ++++------------- {archer => archery}/urls.py | 0 {archer => archery}/wsgi.py | 4 +- common/templates/login.html | 2 +- common/utils/chart_dao.py | 2 +- common/utils/sendmsg.py | 2 +- manage.py | 2 +- sql/utils/data_masking.py | 2 +- sql/utils/execute_sql.py | 2 +- src/docker/Dockerfile | 18 ++++----- src/docker/nginx.conf | 4 +- src/docker/startup.sh | 8 ++-- src/docs/mysql_db_design_guide.md | 2 +- src/script/analysis_slow_query.sh | 6 +-- startup.sh | 4 +- 19 files changed, 64 insertions(+), 98 deletions(-) rename {archer => archery}/__init__.py (100%) rename {archer => archery}/settings.py (84%) rename {archer => archery}/urls.py (100%) rename {archer => archery}/wsgi.py (74%) diff --git a/.gitignore b/.gitignore index 5fc7e8fe04..66c9055bf6 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/.travis.yml b/.travis.yml index 3160f863c7..41dd6bbbac 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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: diff --git a/README.md b/README.md index 266a675f95..ad09e89592 100644 --- a/README.md +++ b/README.md @@ -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/) 快速开始 =============== @@ -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 @@ -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) 依赖或引用项目 =============== diff --git a/archer/__init__.py b/archery/__init__.py similarity index 100% rename from archer/__init__.py rename to archery/__init__.py diff --git a/archer/settings.py b/archery/settings.py similarity index 84% rename from archer/settings.py rename to archery/settings.py index fbd044d592..72572a8a0c 100644 --- a/archer/settings.py +++ b/archery/settings.py @@ -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' @@ -59,7 +45,7 @@ 'common.middleware.exception_logging_middleware.ExceptionLoggingMiddleware', ) -ROOT_URLCONF = 'archer.urls' +ROOT_URLCONF = 'archery.urls' TEMPLATES = [ { @@ -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' @@ -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'), ] @@ -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', @@ -125,7 +104,7 @@ 'charset': 'utf8mb4' }, 'TEST': { - 'NAME': 'test_archer', + 'NAME': 'test_archery', 'CHARSET': 'utf8', }, } @@ -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"), } } @@ -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" @@ -203,7 +182,7 @@ 'handlers': ['default'], 'level': 'DEBUG', }, - 'django_apscheduler': { # django_auth_ldap模块相关日志 + 'django_apscheduler': { # django_apscheduler模块相关日志 'handlers': ['default'], 'level': 'DEBUG', }, diff --git a/archer/urls.py b/archery/urls.py similarity index 100% rename from archer/urls.py rename to archery/urls.py diff --git a/archer/wsgi.py b/archery/wsgi.py similarity index 74% rename from archer/wsgi.py rename to archery/wsgi.py index 19ef50079e..1b6a357e5c 100644 --- a/archer/wsgi.py +++ b/archery/wsgi.py @@ -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``. @@ -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() diff --git a/common/templates/login.html b/common/templates/login.html index 65c0535e9f..2c163ff483 100644 --- a/common/templates/login.html +++ b/common/templates/login.html @@ -104,7 +104,7 @@