Sentry 是一个开源的实时错误报告工具,支持 web 前后端、移动应用以及游戏,支持 Python、OC、Java、Go、Node、Django、RoR 等主流编程语言和框架 ,还提供了 GitHub、Slack、Trello 等常见开发工具的集成。
github地址
一、环境准备
环境说明Ubuntu16.04 ip: 10.211.55.14
二、安装必备组件
1. 安装PostgreSQL
1. apt 安装
sudo apt-get -y install postgresql postgresql-contrib
2. 修改Postgres角色的密码
> sudo su
> su - postgres
> psql
输入:
postgres =# \password #修改当前用户密码
Enter new password:
Enter it again:
postgres =# \q # 退出
运行exit离开postgres用户
2. 安装redis
1. 安装
> sudo wget
> sudo tar -zxvf redis-3.2.6.tar.gz
> sudo cp -rf redis-3.2.6 /usr/local/redis
> cd /usr/local/redis
> sudo apt install gcc
> sudo make
> sudo make install
如果提示make test, 则输入make test
2. 启动
运行redis-server 启动redis
3. 安装python, pip, 以及其他环境
1. 安装系统组件
sudo apt install python-setuptools python-dev libxslt1-dev gcc libffi-dev libjpeg-dev libxml2-dev libxslt-dev libyaml-dev libpq-dev
2. 安装pip
下载get-pip.py
> wget "https://bootstrap.pypa.io/get-pip.py"
> sudo python get-pip.py
3. 安装python库
> pip install -U virtualenv
三、安装sentry
1. 创建虚拟环境
> sudo mkdir /var/www
> sudo chmod -R 777 /var/www
> cd /var/www/
> mkdir sentry
> cd sentry
> virtualenv venv
2. 安装sentry
> source venv/bin/activate
> pip install -U sentry
> sentry
Usage: sentry [OPTIONS] COMMAND [ARGS]...
Sentry is cross-platform crash reporting built with love.
The configuration file is looked up in the `~/.sentry` config directory but this can
be overridden with the `SENTRY_CONF` environment variable or be explicitly provided
through the `--config` parameter.
Options:
--config PATH Path to configuration files.
--version Show the version and exit.
--help Show this message and exit.
Commands:
celery DEPRECATED see `sentry run` instead.
cleanup Delete a portion of trailing data based on...
config Manage runtime config options.
createuser Create a new user.
devserver Starts a lightweight web server for...
django Execute Django subcommands.
dsym Manage system symbols in Sentry.
export Exports core metadata for the Sentry...
files Manage files from filestore.
help Show this message and exit.
import Imports data from a Sentry export.
init Initialize new configuration directory.
plugins Manage Sentry plugins.
queues Manage Sentry queues.
repair Attempt to repair any invalid data.
run Run a service.
shell Run a Python interactive interpreter.
start DEPRECATED see `sentry run` instead.
tsdb Tools for interacting with the time series...
upgrade Perform any pending database migrations and...
四、配置sentry
1. 初始化
sentry init 配置文件路径
> sentry init /var/www/sentry/conf
2. 修改postgreSQL的连接账号密码
打开/var/www/sentry/conf/sentry.conf.py
修改下面这段
DATABASES = {
'default': {
'ENGINE': 'sentry.db.postgres',
'NAME': 'sentry',
'USER': 'postgres',
'PASSWORD': '123123', # 刚才安装完postgreSQL 后你设置的密码
'HOST': '',
'PORT': '',
'AUTOCOMMIT': True,
'ATOMIC_REQUESTS': False,
}
}
3. 初始化数据并且创建用户
> createdb -E utf-8 sentry
如果提示createdb: could not connect to database template1: FATAL: role "lin" does not exist
则切换到postgre用户执行
执行
SENTRY_CONF=/var/www/sentry/conf/ sentry upgrade
如果提示OperationalError: FATAL: Peer authentication failed for user "postgres"
解决方案:
1.sudo vim /etc/postgresql/9.5/main/pg_hba.conf
2.修改
local all postgres peer
TYPE DATABASE USER ADDRESS METHOD
"local" is for Unix domain socket connections only
local all all peer
IPv4 local connections:
host all all 127.0.0.1/32 md5
IPv6 local connections:
host all all ::1/128 md5
为
local all postgres md5
TYPE DATABASE USER ADDRESS METHOD
"local" is for Unix domain socket connections only
local all all peer
IPv4 local connections:
host all all 127.0.0.1/32 md5
IPv6 local connections:
host all all ::1/128 md5
3. 重启postgresql
sudo service postgresql restart
再次执行
SENTRY_CONF=/var/www/sentry/conf/ sentry upgrade