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

相關文章
相關標籤/搜索