ubuntu14.04 Sentry安裝教程

一、安裝環境

python2.7
python-setuptools, python-pip, python-dev, libxslt1-dev, libxml2-dev, libz-dev, libffi-dev, libssl-dev, libpq-dev, libyaml-dev
redis >= 2.8.9
nginx
mysql

二、Sentry安裝

mkvirtualenv sentry    # 安裝sentry虛擬環境
(sentry)pip install sentry
(sentry)pip install sentry[mysql]
(sentry)pip install MYSQL-python
(sentry)pip install redis==2.10.5

三、Sentry配置

sudo mkdir /etc/sentry
sentry init
sudo cp .sentry/* /etc/sentry/
  • 修改/etc/sentry/sentry.conf.py數據庫配置
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'sentry',
        'USER': 'sentry',
        'PASSWORD': '',
        'HOST': '',
        'PORT': '3306',
    }
}
  • sentry啓動,upgrade過程可以創建超級用戶
sentry --config=/etc/sentry/ upgrade
sentry --config=/etc/sentry/ start
  • sentry三個主要模塊:web,worker,cron,用supervisor啓動的
[program:sentry-web]
directory=/home/jtserver
environment=SENTRY_CONF="/etc/sentry"
command=/home/jtserver/.virtualenvs/sentry/bin/sentry start
autostart=true
autorestart=true
redirect_stderr=true
stdout_logfile=/home/jtserver/log/sentry/sentry-cron.log
  
[program:sentry-worker]
directory=/home/jtserver
environment=SENTRY_CONF="/etc/sentry"
command=/home/jtserver/.virtualenvs/sentry/bin/sentry run worker
autostart=true
autorestart=true
redirect_stderr=true
stdout_logfile=/home/jtserver/log/sentry/sentry-cron.log
user=jtserver
  
[program:sentry-cron]
directory=/home/jtserver
environment=SENTRY_CONF="/etc/sentry"
command=/home/jtserver/.virtualenvs/sentry/bin/sentry run cron
autostart=true
autorestart=true
redirect_stderr=true
  • nginx配置
server {
    # the port your site will be served on
    listen 80;
    # the domain name it will serve for
    server_name sentry.tlwlmy.com; # substitute your machine's IP address or FQDN
    gzip on;
    charset                 utf8;
    proxy_set_header   Host                 $http_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;
    proxy_redirect     off;
    keepalive_timeout 0;
    #auth_basic "Sentry Log!";
    #auth_basic_user_file /home/tlwlmy/auth/sentry-user;
    location / {
        proxy_pass http://127.0.0.1:9000;
    }
}

四、Sentry測試

  • python安裝raven庫就可以直接調用了
pip install raven --upgrade
  • 例子
from raven import Client
client = Client('https://<key>:<secret>@app.getsentry.com/<project>')
try:
    1 / 0
except ZeroDivisionError:
    client.captureException()

五、參考

  • https://docs.getsentry.com/on-premise/server/installation/
  • https://docs.getsentry.com/hosted/clients/python/
  • http://blog.gaoyuan.xyz/2013/12/18/deploy-sentry-in-product/
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章