Sentry 高可用部署
时间:2022-10-24 01:00:00
Sentry 基于高可用性部署的部署分析Sentry 10.1.0.dev 05e720a7
对应dockerhub镜像版分别为:
getsentry/snuba:31c967e774759c0548652d986645fdff844e0a39
getsentry/sentry:8549f2a492c803bab77af26e7417272975b9369a
getsentry/symbolicator:94cdbb7b543ebe53744144305db21a56b6a0d5a8
Sentry自托管推荐的官方部署方式是Docker Compose,但这种方法有以下缺点:
- 所有服务都部署在机器上
- 所有组件都不是高可用性的
对生产环境而言,组件高可用性是必要条件,因此有以下高可用性部署,高可用性部署分为两部分:
- Sentry依靠中间件的高可用性
- Sentry本身组件的高可用性
Sentry 服务
Sentry具体的服务关系和依赖性下图:
[外链图片存储失败,源站可能有防盗链机制,建议保存图片直接上传(img-bRwycccO-1647422427770)(/images/sentry-high-availability-deploy/Sentry.png)]
注意以下几点:
- symbolicator、symbolicator-cleanup 依赖挂载卷sentry-symbolicator:/data
- web、cron、worker、post-process-forwarder、sentry-cleanup 还依赖挂载卷,具体可见:https://docs.sentry.io/server/filestore/
为什么要注意挂载卷?
由于挂载卷依赖于存储服务,如果没有高可用性的存储服务,Sentry所有高可用性的组件都很难实现。
部署
Sentry依赖中间件
- Sentry依靠中间件的高可用性,可以通过购买云服务提供商的服务来实现或自行构建。
- 通过修改sentry onpremise将Sentry依赖服务被相关服务取代ip或域名,具体代码可参考:jiankunking/onpremise。
Sentry自身服务
将Sentry拆分服务,部署到kubernetes集群中具体设置参考onpremise中docker-compose.yml设置启动命令、端口和环境变量。
其中有以下几点需要注意:
- Sentry与各种服务的启动命令相比,docker-compose.yml中command,不一致,简单列出:
- snuba api
- snuba consumer --auto-offset-reset=latest --max-batch-time-ms 750
- snuba replacer --auto-offset-reset=latest --max-batch-size 3
- symbolicator run
- sentry run web --loglevel DEBUG
- sentry run cron
- sentry run worker
- …
- snuba api127默认监听.0.0.1,修改为0.0.0.具体修改位置见:
https://github.com/jiankunking/snuba/commit/69fee6253c6a78e7c2668bf6c86692e4df8fe012 - sentry sentry/conf/server.py中KAFKA_CLUSTERS默认是localhost:修改方法见9092:
https://github.com/jiankunking/onpremise/blob/master/sentry/cover/server.py#L1640 - 构建sentry当启动命令为时,镜像post-process-forwarder当需要定制自定义时config.yml、sentry.conf.py复制到镜像//etc/sentry具体见目录:
https://github.com/jiankunking/onpremise/blob/master/sentry/Dockerfile#L10 - sentry 添加到环境变量中C_FORCE_ROOT=true,可以强制以root身份运行
- install.sh脚本
- 初始化clickhouse数据库结构
- 添加初始用户
- sentry worker依赖于sentry cron,所以不能只部署worker,否则会有以下错误提示:Background workers haven’t checked in recently. This is likely an issue with your configuration or the workers aren’t running.
小结
总的来说,会sentry部署到kubernetes中间还是有很多点需要注意,很多细节需要看代码来查。
2020-06-17 更新
Sentry 社区版不支持高可用的ClickHouse分布式表。
Distributed tables are not officially supported. DATASET_MODE would switch to distributed table names, but bootstrap won't work. You would have to manage your tables (create and all DDL operations) manually. This is not a support process, I can give you some hints, but you would be doing it at your own risk. On the other hand, we are working on this support though we cannot commit to a timeline at this time.
The environment variable DATASET_MODE does not work
二期
[外链图片存储失败,源站可能有防盗链机制,建议保存图片直接上传(img-6jsG6WLT-1647422427771)(/images/sentry-high-availability-deploy/Sentry重构.png)]
具体分析
[外链图片存储失败,源站可能有防盗链机制,建议保存图片直接上传(img-JEaZKADA-1647422427771)(/images/sentry-high-availability-deploy/Sentry重构技术分析.png)]
本文的一些交流
https://forum.sentry.io/t/sentry-high-availability-deploy/11838/4
https://github.com/getsentry/onpremise/issues/747#issuecomment-729850059