Ubuntu16.04部署Sentry(Python环境)

2019-07-08  本文已影响0人  TFFTF

官方安装教程

Sentry安装 Python环境

依赖

创建环境

环境搭建请使用root用户, 避免出现文件读写问题

安装Sentry

pip install -U sentry

配置Sentry

# This file is just Python, with a touch of Django which means
# you can inherit and tweak settings to your hearts content.
from sentry.conf.server import *

import os.path

CONF_ROOT = os.path.dirname(__file__)

DATABASES = {
  'default': {
      'ENGINE': 'sentry.db.postgres',
      #数据库名称,默认sentry
      'NAME': 'sentry',
      #数据库登录用户
      'USER': 'postgres',
      #数据库连接密码
      'PASSWORD': 'password',
      #数据库ip
      'HOST': '192.168.50.71',
      #数据库端口, postgres默认5432
      'PORT': '5432',
      'AUTOCOMMIT': True,
      'ATOMIC_REQUESTS': False,
  }
}
#sentry.conf.py文件中
#########
# Queue #
#########

# See https://docs.sentry.io/on-premise/server/queue/ for more
# information on configuring your queue broker and workers. Sentry relies
# on a Python framework called Celery to manage queues.

BROKER_URL = 'redis://{IP}:6379'
#config.yml文件中
# The ``redis.clusters`` setting is used, unsurprisingly, to configure Redis
# clusters. These clusters can be then referred to by name when configuring
# backends such as the cache, digests, or TSDB backend.
#
# Two types of clusters are currently supported:
#
#   rb.Cluster
#   A redis blaster cluster is the traditional cluster used by most services
#   within sentry. This is the default type cluster type.
#
#   rediscluster.StrictRedisCluster
#   An official Redis Cluster can be configured by marking the named group with
#   the ``is_redis_cluster: True`` flag. In future versions of Sentry more
#   services will require this type of cluster.
#
redis.clusters:
  default:
    hosts:
      0:
        host: {IP}
        port: 6379

运行数据库迁移

创建超级管理员

开启web页面服务

 SENTRY_CONF=/home/sentry/init_s sentry run worker

开启后台workers服务

SENTRY_CONF=/home/sentry/init_s sentry run worker

开启定时任务服务

SENTRY_CONF=/home/sentry/init_s sentry run worker

将Sentry当做服务启动

[Unit]
Description=Sentry Main Service
After=network.target
Requires=sentry-worker.service
Requires=sentry-cron.service

[Service]
Type=simple
User=执行用户名
Group=执行用户所在分组
WorkingDirectory=/home/sentry/env
Environment=SENTRY_CONF=/home/sentry/init_s
ExecStart=/home/sentry/env/bin/sentry run web

[Install]
WantedBy=multi-user.target

sentry-worker.service

[Unit]
Description=Sentry Background Worker
After=network.target

[Service]
Type=simple
User=执行用户名
Group=执行用户所在分组
WorkingDirectory=/home/sentry/env
Environment=SENTRY_CONF=/home/sentry/init_s
ExecStart=/home/sentry/env/bin/sentry run worker

[Install]
WantedBy=multi-user.target

sentry-cron.service

[Unit]
Description=Sentry Beat Service
After=network.target

[Service]
Type=simple
User=执行用户
Group=执行用户所在分组
WorkingDirectory=/home/sentry/env
Environment=SENTRY_CONF=/home/sentry/init_s
ExecStart=/home/sentry/env/bin/sentry run cron

[Install]
WantedBy=multi-user.target

PS

若使用root运行worker会出现提示:
If you really want to continue then you have to set the C_FORCE_ROOT environment variable (but please think about this before you do).
此时需要加入环境变量C_FORCE_ROOT
SENTRY_CONF=/home/sentry/init_s C_FORCE_ROOT=a sentry run worker

上一篇 下一篇

猜你喜欢

热点阅读