Sentry-Bug追踪系统安装.

Sentry安装

本文主要介绍在centos7 下经过docker安装sentrypython

一. 安装docker

1.确保yum packages 是最新的

sudo yum update

2.添加yum repo

sudo tee /etc/yum.repos.d/docker.repo <<-'EOF'
[dockerrepo]
name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/centos/7/
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg

3.安装docker

sudo yum install docker-engine

4.启动docker

sudo service docker start

5.验证docker已经启动

sudo docker run hello-world

Unable to find image 'hello-world:latest' locally
latest: Pulling from hello-world
a8219747be10: Pull complete
91c95931e552: Already exists
hello-world:latest: The image you are pulling has been verified.      Important: image verification is a tech preview feature and should not be relied on to provide security.
Digest: sha256:aa03e5d0d5553b4c3473e89c8619cf79df368babd1.7.1cf5daeb82aab55838d
Status: Downloaded newer image for hello-world:latest
Hello from Docker.
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
        (Assuming it was not already locally available.)
 3. The Docker daemon created a new container from that image which runs the
        executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
        to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

For more examples and ideas, visit:
 http://docs.docker.com/userguide/

6.安装--Docker Compose

# 注意pip版本必定要python2.x
sudo yum install epel-release
sudo yum install -y python-pip
sudo pip install docker-compose

测试安装。git

docker-compose --version
docker-compose version 1.22.0, build 1719ceb
docker-compose经常使用命令:
命令 说明
docker-compose build 构建容器
docker-compose restart 重启
docker-compose ps 查看当前服务
docker-compose up 以日志方式启动服务
docker-compose up -d 后台启动服务
docker-compose run --rm web upgrade 运行新的迁移

二. 安装sentry

sentry 依赖的组件比较多 包括 redis、 postgresql、 outbound email 在安装sentry前请确保 docker 版本大于1.10github

1.安装gitweb

sudo yum install git

2.下载docker镜像redis

git clone  https://github.com/getsentry/onpremise.git

三、按git上的readme开始安装(网上别的教程都不是最新的,直接看readme便可) onpremise/README.md at master · getsentry/onpremise · GitHubsql

名称 描述
sentry_cron 定时任务,使用的是 celery-beat
sentry_memcached memcached
sentry_postgres pgsql数据库
sentry_redis 运行celery须要的服务
sentry_smtp 发邮件
sentry_web 使用 django+drf写的一套 SentryWeb界面
sentry_worker celery的worker服务,用来跑异步任务的

三.集成钉钉机器人提醒

因为邮箱通知的时效性太差,不可以即便传递,因此使用钉钉机器人的群通知。docker

1.修改requirements.txt

cd onpremise
vi requirements.txt # 增长下面模块和版本号
redis-py-cluster==1.3.4

2.修改Dockerfile

vi Dockerfile
添加 RUN pip install git+https://github.com/L3T/sentry-dingding.git

FROM sentry:9.0-onbuild
RUN pip install git+https://github.com/L3T/sentry-dingding.git

3.从新执行 build

docker-compose build
docker-compose restart

4.sentry出现钉钉插件

在项目集成中找到钉钉,并填写自定义机器人的webhook便可.数据库

注意:

# 在执行build时会报错,查找 redis_py_cluster-1.3.5版本的文件所有删除

find / -name "redis_py_cluster-1.3.5-py2.7.egg-info"  #查找redis_py_cluster-1.3.5文件

# redis版本是2.10.5时会致使build时安装dingding插件失败,将redis删除,从新安装2.10.6版本
pip install redis==2.10.6 # 安装2.10.6版本

# 若是钉钉插件尚未,执行docker-compose up查看报错日志

docker-compose up

四.配置email通知

sentry自己自带了邮件通知,但若是你但愿有本身的邮箱发邮件的话.配置如下文件便可django

  • 修改docker-compose.yml文件
# vim docker-compose.yml 
x-defaults: &defaults
  restart: unless-stopped
  build: .
  depends_on:
    - redis
    - postgres
    - memcached
    - smtp
  env_file: .env
  environment:
    SENTRY_MEMCACHED_HOST: memcached
    SENTRY_REDIS_HOST: redis
    SENTRY_POSTGRES_HOST: postgres
    SENTRY_EMAIL_HOST: 'smtp.qq.com'
    SENTRY_EMAIL_USER: '48470673@qq.com'
    SENTRY_SERVER_EMAIL: '48470673@qq.com'
    SENTRY_EMAIL_PASSWORD: '这里是受权码'
    SENTRY_EMAIL_USE_TLS: 'true'
    SENTRY_EMAIL_PORT: 587
  volumes:
    - sentry-data:/var/lib/sentry/files
  • 重启服务
docker-compose down
docker-compose up -d

重启以后能够在 Admin==> 邮件下面找到邮箱的配置.ubuntu

相关文章
相关标签/搜索