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://:@app.getsentry.com/')
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/

你可能感兴趣的:(运维,服务器)