Sentry私有化部署的内存和存储优化
创始人
2024-11-15 03:33:38
0

在官方的介绍与文档里面对sentry进行了详细的介绍,以及教大家如何进行私有化部署。但是在部署后会出现什么问题,在安装之前与安装之后我们可以通过什么方式进行优化?

通过项目的实际使用所遇到的问题:

1.磁盘空间占用大

2.内存出现爆满

通过在安装之前与安装之后进行优化配置,避免服务出现以上两点问题

一、安装之前

1.配置日志存储时长

官方默认配置为90天,我们可以根据自己服务器资源(硬盘大小),以及项目需要调整配置。调整“.env”文件下的配置即可。此配置可有效控制日志存储,防止日志过多,导致硬盘容量不足。

# 将此90调整为所需要的值即可  SENTRY_EVENT_RETENTION_DAYS=90

2.开放项目集成的postgresql、clickhouse的端口

开放所用数据的端口,便于使用客户端连接。若数据量过大可以通过数据脚本进行数据清理操作。开放端口主要调整“docker-compose.yml”文件内容。具体调整内容如下:

postgres:     <<: *restart_policy     # Using the same postgres version as Sentry dev for consistency purposes     image: "postgres:14.5"     healthcheck:       <<: *healthcheck_defaults       # Using default user "postgres" from sentry/sentry.conf.example.py or value of POSTGRES_USER if provided       test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-postgres}"]     command:       [         "postgres",         "-c",         "wal_level=logical",         "-c",         "max_replication_slots=1",         "-c",         "max_wal_senders=1",       ]     environment:       POSTGRES_HOST_AUTH_METHOD: "trust"     entrypoint: /opt/sentry/postgres-entrypoint.sh     volumes:       - "sentry-postgres:/var/lib/postgresql/data"       - type: bind         read_only: true         source: ./postgres/         target: /opt/sentry/     ports:       - "5432:5432"  #增加的端口映射 clickhouse:     <<: *restart_policy     image: clickhouse-self-hosted-local     build:       context: ./clickhouse       args:         BASE_IMAGE: "${CLICKHOUSE_IMAGE:-}"     ulimits:       nofile:         soft: 262144         hard: 262144     volumes:       - "sentry-clickhouse:/var/lib/clickhouse"       - "sentry-clickhouse-log:/var/log/clickhouse-server"       - type: bind         read_only: true         source: ./clickhouse/config.xml         target: /etc/clickhouse-server/config.d/sentry.xml     ports:       - "8123:8123"  #增加的端口映射       - "9001:9000"  #增加的端口映射     environment:       # This limits Clickhouse's memory to 30% of the host memory       # If you have high volume and your search return incomplete results       # You might want to change this to a higher value (and ensure your host has enough memory)       MAX_MEMORY_USAGE_RATIO: 0.3     healthcheck:       test: [           "CMD-SHELL",           # Manually override any http_proxy envvar that might be set, because           # this wget does not support no_proxy. See:           # https://github.com/getsentry/self-hosted/issues/1537           "http_proxy='' wget -nv -t1 --spider 'http://localhost:8123/' || exit 1",         ]       interval: 10s       timeout: 10s       retries: 30

3.设置服务内存限制

内存大小限制,能有效的控制服务运行时存储爆满,将服务器拖垮导致服务宕机。此处建议对clickhouse、postgres、redis服务进行内存限制

# 在对应服务的docker-compose文件下增加如下内容即可 deploy:     resources:     limits:     memory: 8G  #根据需要设置内存大小,此处8GB

二、安装之后

根据上述配置进行调整之后,第一次服务运行起来了,我们还需要对一些服务内部的配置进行优化调整,以保持服务长时间稳定运行。

1.kafka日志数据保留时长设置调整

kafka队列日志保存时长设置,能有效的控制kafka所需使用的磁盘空间大小。在刚使用的sentry时,我就因为使用默认的配置,为调节导致kafka服务占用磁盘达到了500G左右,导致服务器空间不足。因此我就此问题找到了调整kafka队列日志保存时间,有效控制磁盘使用,kafka服务所需磁盘空间在20G左右.

以下内容为调整的方式

# 进入kafka容器 docker exec -it sentry-self-hosted-kafka-1 /bin/bash  #查看topics kafka-topics --list --zookeeper zookeeper:2181  # 安装vim apt-get update apt-get install vim  # 安装vim 时可能因为资源问题不能正常安装 # 可以将资源增加阿里云资源  cat >> /etc/apt/sources.list # 按enter键输入如下内容 deb https://mirrors.aliyun.com/debian-archive/debian/ jessie main non-free contrib deb-src https://mirrors.aliyun.com/debian-archive/debian/ jessie main non-free contrib deb http://mirrors.aliyun.com/debian-security/ squeeze/updates main non-free contrib deb-src http://mirrors.aliyun.com/debian-security/ squeeze/updates main non-free contrib # 按ctrl+d 保存内容   #修改kafka配置文件 vi /etc/kafka/server.properties  #修改为7小时 默认168 log.retention.hours=7 log.cleaner.enable=true log.cleanup.policy=delete log.cleanup.interval.mins=1

2.调整完成后停掉服务,重新启动

# 停止服务 docker-compose down  # 启动服务 docker-compose up -d

相关内容

热门资讯

7分钟设置抽水!aapoker... 7分钟设置抽水!aapoker免费透视脚本,aapoker能控制牌吗,详细教程(有挂技巧);1、构建...
3分钟手机版!wepoker怎... 3分钟手机版!wepoker怎么看底牌(透视底牌)详细辅助外挂(确实是有挂)1)辅助挂:进一步探索辅...
两分钟控制牌!aapoker脚... 两分钟控制牌!aapoker脚本怎么用,aapoker插件,详细教程(有挂秘籍)1)aapoker脚...
6分钟破解版内购!wejoke... 6分钟破解版内购!wejoker内置辅助,wepoker看底牌,详细教程(有挂辅助);1、wejok...
7分钟能控制牌!aapoker... 7分钟能控制牌!aapoker插件下载,aa poker辅助,详细教程(有挂脚本)aapoker插件...
两分钟提高运气!wepoker... 两分钟提高运气!wepoker辅助器下载,wepoker国外版透视,详细教程(有挂外 挂)1、wep...
两分钟设置胜率!aapoker... 两分钟设置胜率!aapoker公共底牌(透视脚本)详细辅助程序(一直真的有挂);1、很好的工具软件,...
3分钟开辅助!wejoker内... 3分钟开辅助!wejoker内置辅助(透视底牌)详细辅助软件(真是存在有挂);1、实时wejoker...
4分钟开辅助器!aapoker... 4分钟开辅助器!aapoker透视脚本下载(透视脚本)详细辅助挂(真是真的有挂)1、aapoker透...
7分钟安装教程!wepoker... 7分钟安装教程!wepoker软件辅助程序,wepoker私人局怎么玩,详细教程(有挂修改器)1、每...