Ставим Sentry 9.0.0 на Debian Stretch
1. Установим нужные пакеты
# apt install python python-setuptools python-pip python-dev libxslt1-dev libjpeg-dev libxml2-dev libpq-dev libffi-dev gcc libxslt-dev libyaml-dev
2. Nginx
# apt install nginx
Правим конфиг /etc/nginx/sites-available/sentry.conf
server {
listen 80;
server_name sentry.megapuper.ru;
location / {
proxy_pass http://localhost:9000;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
3. Postgresql
# apt install postgresql
Создаём БД
# cd /tmp/
/tmp # su postgres
postgres@sentry01:/tmp$ psql
CREATE DATABASE sentry encoding utf8;
CREATE USER sentry WITH password 'PASS_FOR_USER_sentry';
GRANT ALL privileges ON DATABASE sentry TO sentry;
\q
4. Redis
# apt install redis-server
5. Устанавливаем Sentry
# pip install -U virtualenv
# virtualenv /srv/www/sentry/
# source /srv/www/sentry/bin/activate
(sentry)# pip install -U sentry
(sentry)# sentry init /etc/sentry
Правим конфиги
/etc/sentry/config.yml
Spoiler
# While a lot of configuration in Sentry can be changed via the UI, for all
# new-style config (as of 8.0) you can also declare values here in this file
# to enforce defaults or to ensure they cannot be changed via the UI. For more
# information see the Sentry documentation.
###############
# Mail Server #
###############
mail.backend: 'smtp' # Use dummy if you want to disable email entirely
# mail.host: 'localhost'
# mail.port: 25
# mail.username:
# mail.password:
# mail.use-tls: false
# The email address to send on behalf of
mail.from: 'sentry@encry.ru'
# If you'd like to configure email replies, enable this.
# mail.enable-replies: false
# When email-replies are enabled, this value is used in the Reply-To header
# mail.reply-hostname:
# If you're using mailgun for inbound mail, set your API key and configure a
# route to forward to /api/hooks/mailgun/inbound/
# mail.mailgun-api-key:
###################
# System Settings #
###################
# If this file ever becomes compromised, it's important to regenerate your a new key
# Changing this value will result in all current sessions being invalidated.
# A new key can be generated with `$ sentry config generate-secret-key`
system.secret-key: 'e)_e)t+^t3x3(q!ljx@^d2f(_%bgyc^ck-jjf#)o8(t!_@t+%3'
# 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: 127.0.0.1
port: 6379
################
# File storage #
################
# Uploaded media uses these `filestore` settings. The available
# backends are: `filesystem`, `gcs`, and `s3`.
filestore.backend: 'filesystem'
filestore.options:
location: '/tmp/sentry-files'
# NOTE: See docs/filestore for instructions on configuring the shell environment
# with authentication credentials for Google Cloud.
# filestore.backend: 'gcs'
# filestore.options:
# bucket_name: 's3-bucket-name'
# filestore.backend: 's3'
# filestore.options:
# access_key: 'AKIXXXXXX'
# secret_key: 'XXXXXXX'
# bucket_name: 's3-bucket-name'
system.url-prefix: 'http://sentry.megapuper.ru'
/etc/sentry/sentry.conf.py
Spoiler
Заводим пользователя
# useradd -u 20005 -s /bin/bash -m -d /home/sentry sentry
# chown -R sentry:sentry /srv/www/sentry/
6. Supervisor
# apt install supervisor
Создаём конфиг /etc/supervisor/conf.d/sentry.conf
Spoiler
[program:sentry-web]
environment=SENTRY_CONF="/etc/sentry/"
directory=/srv/www/sentry/
command=/srv/www/sentry/bin/sentry run web
autostart=true
autorestart=true
redirect_stderr=true
user=sentry
[program:sentry-worker]
environment=SENTRY_CONF="/etc/sentry/"
directory=/srv/www/sentry/
command=/srv/www/sentry/bin/sentry run worker
autostart=true
autorestart=true
redirect_stderr=true
user=sentry
[program:sentry-cron]
environment=SENTRY_CONF="/etc/sentry/"
directory=/srv/www/sentry/
command=/srv/www/sentry/bin/sentry run cron
autostart=true
autorestart=true
redirect_stderr=true
killasgroup=true
Рестартим supervisor и заходим в sentry, должно работать)
Если во время sentry upgrade будет падать с ошибкой
django.db.utils.ProgrammingError: ProgrammingError('permission denied to create extension "citext"\nHINT: Must be superuser to create this extension.\n',)
перед запуском sentry update, дадим sentry права суперюзера, потом заберём:
alter role sentry superuser;
alter role sentry nosuperuser;
Почитать по установке можно здесь
https://docs.sentry.io/server/installation/python/
https://docs.sentry.io/server/nginx/
https://docs.sentry.io/server/warnings/
7. Подключение Telegram-бота для оповещений (https://github.com/butorov/sentry-telegram)
# pip install sentry-telegram
Добавляем в конфиг /etc/sentry/sentry.conf.py
INSTALLED_APPS += ('sentry_telegram',)
Рестартим Sentry
Затем заходим в настройки проекта и в меню INTEGRATIONS настраиваем плагин Telegram Notifications
8. Подключение плагина redmine (https://github.com/getsentry/sentry-redmine)
# pip install sentry-redmine
Далее в настройках проекта, в меню INTEGRATIONS появляется пункт Redmine, конфигурим его с параметрами, которые берём из нашего redmine.
Если плагин не подтягивается из-за конфликта версий
Failed to load plugin 'redmine':
ContextualVersionConflict: (redis 2.10.5 (/srv/www/sentry/lib/python2.7/site-packages), Requirement.parse('redis==2.10.6'), set(['redis-py-cluster']))
Грохаем redis-py-cluster и ставим версию 1.3.4
# pip uninstall redis-py-cluster
# pip install redis-py-cluster==1.3.4
# pip install sentry-redmine
Рестартим supervisor-web