关于sentry:Sentry-10-升级到-Sentry-20

10次阅读

共计 6302 个字符,预计需要花费 16 分钟才能阅读完成。

Sentry 简介

Sentry [‘sentri]
  • n. 哨兵
  • v. 站岗;在…设岗哨

Sentry 是一个用于监控前后端出错和统计上报剖析一体的一个开源软件系统。

Sentry 适宜中等规模以上的网站的开发及生产线上出错治理。Sentry 能够适应多租户多我的项目的治理。性能很欠缺。

官网地址:https://sentry.io/features/re…

因为软件架构比较复杂。倡议采纳官网的 docker-compose 脚本即 onpremise 来装置。

Sentry 零碎占用内存较多,最好有 8G 以上内存。因资源受限,我用的是 4G 内存 +4G Swap 分区的形式在 CentOS 7 上装置的。在收集几千万个谬误上报后,零碎依然很晦涩,可见其性能低劣。

最新的 Sentry 零碎由 28 个容器组成:

# docker ps --format 'table {{.Ports}}\t{{.Names}}'
PORTS                          NAMES
0.0.0.0:9000->80/tcp           sentry_onpremise_nginx_1
9000/tcp                       sentry_onpremise_subscription-consumer-events_1
9000/tcp                       sentry_onpremise_ingest-consumer_1
9000/tcp                       sentry_onpremise_cron_1
9000/tcp                       sentry_onpremise_subscription-consumer-transactions_1
9000/tcp                       sentry_onpremise_post-process-forwarder_1
9000/tcp                       sentry_onpremise_sentry-cleanup_1
9000/tcp                       sentry_onpremise_web_1
9000/tcp                       sentry_onpremise_worker_1
1218/tcp                       sentry_onpremise_snuba-subscription-consumer-transactions_1
1218/tcp                       sentry_onpremise_snuba-transactions-consumer_1
1218/tcp                       sentry_onpremise_snuba-sessions-consumer_1
1218/tcp                       sentry_onpremise_snuba-api_1
1218/tcp                       sentry_onpremise_snuba-outcomes-consumer_1
1218/tcp                       sentry_onpremise_snuba-consumer_1
1218/tcp                       sentry_onpremise_snuba-replacer_1
1218/tcp                       sentry_onpremise_snuba-subscription-consumer-events_1
3000/tcp                       sentry_onpremise_relay_1
1218/tcp                       sentry_onpremise_snuba-cleanup_1
9092/tcp                       sentry_onpremise_kafka_1
6379/tcp                       sentry_onpremise_redis_1
5432/tcp                       sentry_onpremise_postgres_1
3021/tcp                       sentry_onpremise_symbolicator_1
2181/tcp, 2888/tcp, 3888/tcp   sentry_onpremise_zookeeper_1
25/tcp                         sentry_onpremise_smtp_1
8123/tcp, 9000/tcp, 9009/tcp   sentry_onpremise_clickhouse_1
11211/tcp                      sentry_onpremise_memcached_1
3021/tcp                       sentry_onpremise_symbolicator-cleanup_1

注: docker ps 后加 format 参数,能够管制输入字段和格局,很不便写文档用。详见 Docker 官网。

以上的 28 个容器大略造成了以下的构造:

最下面是两个前端:一个是通过反对各种编程语言 SDK 上报事件的 API 入口,一个是通过 React 的单页面利用 SPA 实现的治理后盾前端。

Sentry 通过提供 SDK 的形式,反对简直所有支流的编程语言及各类框架接入,目前达 88 种之多。

存储方面,Sentry 采纳了两种数据库 PostgreSQL 和 ClickHouse. 前者次要用于存储事件以外的,用户,团队组织等元数据和治理数据。后者则是以高性能、宽表、海量数据反对能力而闻名的 ClickHouse 数据库。

ClickHouse 通过 ZooKeeper 反对分布式架构,轻松实现对 PB 级数据量的反对。表列数仅受限于内存大小,因为每一列多应多个磁盘文件独自存储。高性能的实现很大程序上在于行只增,不做物理删除,通过程序读写实现逻辑上的增删改查。因而 IO 方面大大优化传统的关系型数据库。同时 ClickHouse 反对 MySQL 的形式拜访,因而对于移植方面也很敌对。

两头局部通过 Kafka 和 Snuba 这两个消息中间件,来实现简单的事件处理过程。

Kafka 置信大家都很相熟,Snuba 则实现了 Kafka 所短少的一些个性:在任意字段上提供疾速事件搜寻,筛选和聚合的服务。

软件系统报错,特地是互联网上,通常出的问题都是一样的。通过 Snuba 中间件,Sentry 实现了对同类事件的合并解决,而再是重复解决同样的信息。同时在每一个 SDK 客户端能够通过设置采样率,管制事件上报的频率。缩小同样问题的反复上报。从而缩小 Sentry 服务器的压力。

Sentry 零碎就介绍到这里。上面咱们看一下降级中遇到的问题和相应的解决方法。

Sentry 10 降级到 Sentry 20

Sentry 20 减少了 Peformance 性能,能够通过上报数据来测量利用在各个环节上的性能。这个性能对测试客户端的性能特地有用。因为你本人无奈实现用户端在大网环境下的客户所面对的各种各样的状况。

从官网下载安装脚本:

wget https://github.com/getsentry/onpremise/archive/20.12.1.tar.gz

解压:

tar xvf 20.12.1.tar.gz
cd onpremise-20.12.1

如果你想批改 Docker 的默认存储地位(比方默认分区空间不够等),能够参考这个链接。

首先要先启动 Docker 服务,否则间接运行装置脚本有显示如下信息:

onpremise-20.12.1$ ./install.sh
tee: sentry_install_log-2020-12-24_16-39-16.txt: Permission denied
Checking minimum requirements...
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

启动 Docker 服务:

systemctl start docker

再运行装置脚本:

onpremise-20.12.1# ./install.sh
Checking minimum requirements...
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
An error occurred, caught SIGERR on line 97
Cleaning up...
[centos onpremise-20.12.1]# systemctl start docker
[centos onpremise-20.12.1]#
You have new mail in /var/spool/mail/root
[centos onpremise-20.12.1]#
[centos onpremise-20.12.1]#
[centos onpremise-20.12.1]#
[centos onpremise-20.12.1]# ./install.sh
Checking minimum requirements...
FAIL: Expected minimum Docker version to be 19.03.6 but found 18.09.6

出错,要求 Docker 版本最小为 19.03.6, 装置新版本 Docker:

yum install docker-ce docker-ce-cli containerd.io

--> Finished Dependency Resolution
Error: Package: 3:docker-ce-20.10.1-3.el7.x86_64 (docker-ce-stable)
           Requires: container-selinux >= 2:2.74
           Installed: 2:container-selinux-2.33-1.git86f33cd.el7.noarch (@extras)
               container-selinux = 2:2.33-1.git86f33cd.el7
           Available: 2:container-selinux-2.21-1.el7.noarch (extras)
               container-selinux = 2:2.21-1.el7
           Available: 2:container-selinux-2.21-2.gitba103ac.el7.noarch (extras)
               container-selinux = 2:2.21-2.gitba103ac.el7
           Available: 2:container-selinux-2.28-1.git85ce147.el7.noarch (extras)
               container-selinux = 2:2.28-1.git85ce147.el7
Error: Package: containerd.io-1.4.3-3.1.el7.x86_64 (docker-ce-stable)
           Requires: container-selinux >= 2:2.74
           Installed: 2:container-selinux-2.33-1.git86f33cd.el7.noarch (@extras)
               container-selinux = 2:2.33-1.git86f33cd.el7
           Available: 2:container-selinux-2.21-1.el7.noarch (extras)
               container-selinux = 2:2.21-1.el7
           Available: 2:container-selinux-2.21-2.gitba103ac.el7.noarch (extras)
               container-selinux = 2:2.21-2.gitba103ac.el7
           Available: 2:container-selinux-2.28-1.git85ce147.el7.noarch (extras)
               container-selinux = 2:2.28-1.git85ce147.el7
Error: Package: docker-ce-rootless-extras-20.10.1-3.el7.x86_64 (docker-ce-stable)
           Requires: slirp4netns >= 0.4
Error: Package: docker-ce-rootless-extras-20.10.1-3.el7.x86_64 (docker-ce-stable)
           Requires: fuse-overlayfs >= 0.7
 You could try using --skip-broken to work around the problem
** Found 4 pre-existing rpmdb problem(s), 'yum check' output follows:
puppet-3.8.7-1.el7.noarch has missing requires of hiera >= ('0', '1.0.0', None)
puppet-3.8.7-1.el7.noarch has missing requires of ruby(selinux)
puppet-3.8.7-1.el7.noarch has missing requires of ruby-augeas
puppet-3.8.7-1.el7.noarch has missing requires of ruby-shadow

因为 Docker 是配置的 Docker 官网的镜像,装置还要依赖多个新版的软件库。参考以下链接解决:

https://www.cnblogs.com/gaowe…

即,从如下地址,下载 container-selinux 安装包 container-selinux-2.107-3.el7.noarch.rpm

http://mirror.centos.org/cent…

下载后装置:

# rpm -ivh container-selinux-2.107-3.el7.noarch.rpm 

从新执行 Docker 装置命令,

# yum install docker-ce docker-ce-cli containerd.io

还有依赖,再装:

wget http://mirror.centos.org/centos/7/extras/x86_64/Packages/slirp4netns-0.4.3-4.el7_8.x86_64.rpm
rpm -i slirp4netns-0.4.3-4.el7_8.x86_64.rpm
wget http://mirror.centos.org/centos/7/extras/x86_64/Packages/fuse-overlayfs-0.7.2-6.el7_8.x86_64.rpm
rpm -i fuse-overlayfs-0.7.2-6.el7_8.x86_64.rpm

直到实现全副的依赖项。

应该说装置脚本还是很欠缺的,逐个按提醒装置就好了。我是在原有版本上降级的,原有数据尽管做了数据库导出备份,但最好也都没有用上,期中的数据也都平滑降级。

降级后一个邮件发送配置的正告:

是因为零碎的一个 bug 导致的。按 forum 上 提醒,批改 sentry/config.yml 文件

mail.host: 'smtp'
mail.use-ssl: false  #去除 warning, 一个零碎 bug

#mail.backend: 'django.core.mail.backends.smtp.EmailBackend'  # Use dummy if you want to disable email entirely
#mail.host: 'localhost'
mail.port: 25
mail.username: ''mail.password:''
mail.use-tls: false

新版的 sentry 自带 smtp 服务器,这几项都留空就好了

另外能够通过批改配置文件的 SENTRY_SINGLE_ORGANIZATION 参数,使得治理多个组织变得更不便。

零碎应用快一年了,从没有删数据的状况下,磁盘空间占用了近 70G,上报的出错有几千万,零碎很稳固,排错好帮手。能够在其余局部反馈问题之前第一工夫收到报警邮件。

再也不必问客户你用的是什么操作系统、什么浏览器的、怎么操作的等等这些令人讨厌的问题。你要问的,都在 Sentry 上了。分给你的组员,让他疾速解决就好了。

总之,强烈推荐!

正文完
 0