docker-compose安装Sentry

作者: admin 分类: 运维那些事 发布时间: 2018-07-17 13:45

安装准备

Docker安装参考:

Centos安装最新版Docker CE、Docker-Compose

获取安装脚本

$ git clone https://github.com/getsentry/onpremise.git 
$ cd onpremise
$ mkdir -p data/sentry
$ mkdir -p data/postgres

邮件配置

邮件配置,邮件提醒需要

# vim sentry.conf.py
# if email:
#     SENTRY_OPTIONS['mail.backend'] = 'smtp'
#     SENTRY_OPTIONS['mail.host'] = email
#     SENTRY_OPTIONS['mail.password'] = env('SENTRY_EMAIL_PASSWORD') or ''
#     SENTRY_OPTIONS['mail.username'] = env('SENTRY_EMAIL_USER') or ''
#     SENTRY_OPTIONS['mail.port'] = int(env('SENTRY_EMAIL_PORT') or 25)
#     SENTRY_OPTIONS['mail.use-tls'] = env('SENTRY_EMAIL_USE_TLS', False)
# else:
#     SENTRY_OPTIONS['mail.backend'] = 'dummy'

# The email address to send on behalf of
# SENTRY_OPTIONS['mail.from'] = env('SENTRY_SERVER_EMAIL') or 'root@localhost'

SENTRY_OPTIONS['mail.backend'] = 'smtp'
SENTRY_OPTIONS['mail.host'] = 'smtp.exmail.qq.com'
SENTRY_OPTIONS['mail.password'] = '密码'
SENTRY_OPTIONS['mail.username'] = '账号'
SENTRY_OPTIONS['mail.port'] = 587
SENTRY_OPTIONS['mail.use-tls'] = True

# The email address to send on behalf of
SENTRY_OPTIONS['mail.from'] = '邮箱'

安装Sentry

继续安装,

$ docker-compose build
$ docker-compose run --rm web config generate-secret-key # 生成secret key,添加到docker-compose.yml的SENTRY_SECRET_KEY
...
i4&4bexsine3c9=*yqzcxmmvpnshm*gd&)2=)yon9yv(6^9^zd
$ docker-compose run --rm web upgrade # 生成database,创建超级管理员账号
$ docker-compose up -d # 启动所有服务

查看启动服务,

$ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES
3997c9730ffb        onpremise_web       "/entrypoint.sh run …"   2 hours ago         Up 2 hours          0.0.0.0:9000->9000/tcp   onpremise_web_1
29ae61ff101c        onpremise_cron      "/entrypoint.sh run …"   2 hours ago         Up 2 hours          9000/tcp                 onpremise_cron_1
820b5a570488        onpremise_worker    "/entrypoint.sh run …"   2 hours ago         Up 2 hours          9000/tcp                 onpremise_worker_1
1ca2e6568146        tianon/exim4        "docker-entrypoint.s…"   2 hours ago         Up 2 hours          25/tcp                   onpremise_smtp_1
94f7ad4fff07        redis:3.2-alpine    "docker-entrypoint.s…"   2 hours ago         Up 2 hours          6379/tcp                 onpremise_redis_1
ce762fc3a4e4        postgres:9.5        "docker-entrypoint.s…"   2 hours ago         Up 2 hours          5432/tcp                 onpremise_postgres_1
7e4448bf87c9        memcached:1.4       "docker-entrypoint.s…"   2 hours ago         Up 2 hours          11211/tcp                onpremise_memcached_1

Sentry Web UI

安装完成!访问:localhost:9000!

邮件测试

查看邮件配置
http://localhost/manage/status/mail/

点击测试,如果能正常收到测试邮件,安装就大功告成咯!

报警邮件测试

创建新项目,以Python项目为例

from raven import Client
client = Client('http://xxxxxxxx')
try:
     1 / 0
except ZeroDivisionError:
     client.captureException()

正常情况会有报警邮件!

问题

ERROR: Version in "./docker-compose.yml" is unsupported

docker版本限制:
查看docker-compose.yml文件版本3.4,

cd /root/onpremise
$ grep version docker-compose.yml
version: '3.4'

支持docker版本查看,https://github.com/docker/compose/releases

版本不匹配会报错!

Background workers haven't checked in recently. This is likely an issue with your configuration or the workers aren't running.

http://localhost/manage/queue/
队列支持,暂时先不设置

(完)

如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!

发表评论

电子邮件地址不会被公开。 必填项已用*标注