Sentry上线将近两个月以后崩溃,崩溃的原因有两个:
1、运行postgresql容器的机器磁盘空间被耗尽,导致数据库停止服务
2、运行Nginx和sentry web的docker无法重启。
修复sentry的过程因此分为两个步骤:
1、对postgresql中30天以前的数据进行清理,恢复磁盘空间。
2、对运行sentry web和nginx的机器重装docker,由于nginx和sentry web server不保存状态,因此重新搭建web server不会造成数据丢失。
- postgresql磁盘空间清理:
这里对应的操作应该被称为database rotation,sentry本身有名为cleanup的工具,可以利用cleanup删除过期数据。
但是,cleanup要求数据库提供服务。在sentry 搭建时,postgresql为主备搭建,主库所在机器磁盘已被耗尽,数据库服务无法启动。幸好备库还有20G左右的剩余空间,可以考虑清理备库的磁盘空间,然后将备库升为主库,再将原主库磁盘清空,同步新主库的数据。这样做会损失一部分数据,好在sentry记录的数据不是特别重要。
- cleanup:
sentry的cleanup工具操作帮助为
root@9acfe6561812:/# sentry cleanup --help
Usage: sentry cleanup [OPTIONS]
Delete a portion of trailing data based on creation date.
All data that is older than `--days` will be deleted. The default for this is 30 days. In
the default setting all projects will be truncated but if you have a specific project you want
to limit this to this can be done with the `--project` flag which accepts a project ID or a
string with the form `org/project` where both are slugs.
Options:
--days INTEGER Numbers of days to truncate on. [default: 30]
--project TEXT