Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

解决dms/sqle日志过量的问题 #2253

Closed
taolx0 opened this issue Feb 5, 2024 · 3 comments
Closed

解决dms/sqle日志过量的问题 #2253

taolx0 opened this issue Feb 5, 2024 · 3 comments
Assignees
Labels
feature publish-pre2 verified the issue all pr is verified
Milestone

Comments

@taolx0
Copy link
Collaborator

taolx0 commented Feb 5, 2024

背景

std.log目前没有轮转机制,如果长期不轮转,可能会导致硬盘空间被占用过多.

预期

期望可以对std.log进行轮转

方案(1)

通过 linux 自带的 logrotate 工具实现,可以根据日志size和保留日志份数参数实现

优点

  • dms/sqle 启动代码不需要调整

缺点

  • 依赖了系统命令logrotate【可能命令不存在】
  • 业务日志和std.log轮转方式不同

方案(2)

sqle/dms业务日志轮转使用了rotate包, std.log日志也使用rotate包进行轮转

优点

  • 业务日志和std日志使用了同一种轮转方式
  • 不依赖外部工具

缺点

  • 在dms/sqle启动时增加一段日志重定向代码
  • 重定向所有标准输出和标准错误输出到std.log影响面大,控制台不输出标准输出,可能导致调试困难

方案 (3)

通过对std.log的输出进行整理,减少std.log中的输出解决日志过大的问题.
目前std.log会输出:

  1. sqle启动失败的日志
  2. 调用各种数据源审核插件的日志

除去少量sqle启动失败的日志,大部份日志都是调用各种数据源审核插件产生的,这部分日志属于sqle业务日志,应该打印在sqled.log中,而不是std.log.可以重定向go-plugin客户端日志输出到sqled.log,利用现有的sqled.log日志实现轮转.采用这种方式,即可以规范日志打印,也可以解决std.log日志量过大的问题.

优点

  • 规范化日志输出
  • 对sqle影响面小,不影响docker容器部署的日志输出,可以正常通过 docker logs 查看标准输出
  • 利用现有slqed.log的方式实现轮转

缺点

无缺点

总结

方案三无缺点,优势突出,采用方案三

测试验证

  1. 在 plugins 目录下执行 vi t0.jar 创建 t0.jar 文件,chmod +x ./t0.jar 加可执行权限
  2. 重启 sqle
@taolx0 taolx0 added the feature label Feb 5, 2024
@ColdWaterLW ColdWaterLW added this to the 3.2404.0 milestone Mar 29, 2024
@ColdWaterLW ColdWaterLW assigned rocky114 and unassigned taolx0 Apr 7, 2024
@rocky114 rocky114 changed the title 支持std.log日志轮转 dms/sqle支持std.log日志轮转 Apr 12, 2024
@ColdWaterLW ColdWaterLW modified the milestones: 3.2404.0, 3.2405.0 Apr 22, 2024
@ColdWaterLW
Copy link
Collaborator

ColdWaterLW commented Apr 22, 2024

目前看来,我们的日志量可能会很大。需要确认如下问题:

  1. 现有的日志是否有需要收敛的内容(减少不必要的日志内容)
  2. 旧的日志文件是否需要压缩处理
  3. 如果重定向标准输出,那容器方式部署的话,容器挂了,可能也无法查看std日志

@ColdWaterLW ColdWaterLW assigned taolx0 and unassigned rocky114 Apr 22, 2024
@ColdWaterLW ColdWaterLW changed the title dms/sqle支持std.log日志轮转 解决dms/sqle日志过量的问题 May 8, 2024
@taolx0

This comment was marked as outdated.

@hasa1K
Copy link
Collaborator

hasa1K commented May 27, 2024

sqle version: 4a5e6c84549f209380ba4cfaba41c364158b19b2
dms version:7ebf3da28e3f0558d120fd1fd04c24a071f174e3
验证点:
sqle/plugins文件夹下存放几个插件,启动sqle观察插件日志

  1. 是否会出现在控制台中
  2. 是否会出现在sqled.log日志文件中

验证:
控制台中没有插件日志内容
image
sqled.log文件出现插件日志
image

@hasa1K hasa1K added the verified the issue all pr is verified label May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature publish-pre2 verified the issue all pr is verified
Projects
None yet
Development

No branches or pull requests

4 participants