错误日志收集平台 - Sentry(Redis+MySQL)
Sentry 是一个实时的事件日志和聚合平台,基于 Django 构建。
Sentry 可以帮助你将 Python 程序的所有 exception 自动记录下来,然后在一个好用的 UI 上呈现和搜索。处理 exception 是每个程序的必要部分,所以 Sentry 也几乎可以说是所有项目的必备组件。
# 1. 数据库依赖
MySQL & Redis
# 2. 数据库环境搭建
# 2.1 MySQL
mysql -uroot -p
# 访问权限
ALTER USER 'root'@'localhost' IDENTIFIED BY 'passwd';
ALTER USER 'root'@'%' IDENTIFIED BY 'passwd';
# 刷新权限
flush privileges;
# 创建 sentry 数据库
create database sentry;
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
# 2.2 redis
# redis安装
yum install epel-release # 安装epel源
yum install redis
# 配置redis
vim /etc/redis.conf
requirement Iccc2016
service redis.service restart
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
# 3. 系统环境包安装
# 3.1 yum离线安装包方法
yum -C install
1
# 3.2 yum install depend package
yum install -y python-devel libffi-devel openssl-devel
yum install -y libxslt-devel libxml2-devel postgresql-devel libjpeg-devel
yum install -y mysql-devel
1
2
3
2
3
# 4. python环境搭建
# 4.1 pip离线安装方法
pip --no-index --find-links=./
1
# 4.2 创建virtualenv
pip install pip --upgrade
pip install virtualenv --upgrade
virtualenv /app/app/sentry
source /app/app/sentry/bin/activate
1
2
3
4
2
3
4
# 4.3 安装sentry依赖python库
pip install Cython
pip install sentry[mysql] sentry
pip install sentry[mysql] --upgrade
pip install redis hiredis nydus
pip install redis hiredis nydus --upgrade
pip install gevent eventlet MySQL-python
1
2
3
4
5
6
2
3
4
5
6
# 4.4 Sentry 配置
mkdir -p /app/app/sentry/etc
sentry init /app/app/sentry/etc
vim /app/app/sentry/etc/sentry.conf.py # 修改 mysql,redis url配置
vim /app/app/sentry/etc/sentry.conf.py #修改redis配置
export SENTRY_CONF="/app/app/sentry/etc/"
sentry upgrade
nohup sentry --config=/app/app/sentry/etc/sentry.conf.py run web &
nohup sentry --config=/app/app/sentry/etc/sentry.conf.py run cron &
nohup sentry --config=/app/app/sentry/etc/sentry.conf.py run worker -c 2 &
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
# 4.5 supervisor
- 后续配合supervisord启动
上次更新: 2024/08/11, 01:59:03