解决podman crt.log日志过大的问题

问题描述

使用如下命令创建 gitlab 容器:

podman run -d -p 443:443 -p 80:80 -p 8022:22 --restart always --name gitlab0929 -v /etc/gitlab:/etc/gitlab -v /root/gitdata/log:/var/log/gitlab -v /root/gitdata/data:/var/opt/gitlab --privileged=true yrzr/gitlab-ce-arm64v8:latest

容器运行一段时间后,硬盘空间占满,导致容器启动失败。

分析过程

  1. 运行 podman logs 971f03023b80 命令,查看日志容器日志 (971f03023b80为容器ID)
2022-10-08_01:57:43.04350 level=info ts=2022-10-08T01:57:43.042Z caller=head.go:740 component=tsdb msg="WAL segment loaded" segment=104772 maxSegment=142618
2022-10-08_01:57:43.04352 level=info ts=2022-10-08T01:57:43.042Z caller=head.go:740 component=tsdb msg="WAL segment loaded" segment=104773 maxSegment=142618
2022-10-08_01:57:43.04352 level=info ts=2022-10-08T01:57:43.042Z caller=head.go:740 component=tsdb msg="WAL segment loaded" segment=104774 maxSegment=142618
2022-10-08_01:57:43.04353 level=info ts=2022-10-08T01:57:43.043Z caller=head.go:740 component=tsdb msg="WAL segment loaded" segment=104775 maxSegment=142618
2022-10-08_01:57:43.04353 level=info ts=2022-10-08T01:57:43.043Z caller=head.go:740 component=tsdb msg="WAL segment loaded" segment=104776 maxSegment=142618
2022-10-08_01:57:43.04353 level=info ts=2022-10-08T01:57:43.043Z caller=head.go:740 component=tsdb msg="WAL segment loaded" segment=104777 maxSegment=142618
2022-10-08_01:57:43.04688 level=info ts=2022-10-08T01:57:43.046Z caller=head.go:740 component=tsdb msg="WAL segment loaded" segment=104778 maxSegment=142618
2022-10-08_01:57:43.04730 level=info ts=2022-10-08T01:57:43.047Z caller=head.go:740 component=tsdb msg="WAL segment loaded" segment=104779 maxSegment=142618
2022-10-08_01:57:43.04757 level=info ts=2022-10-08T01:57:43.047Z caller=head.go:740 component=tsdb msg="WAL segment loaded" segment=104780 maxSegment=142618
2022-10-08_01:57:43.04851 level=info ts=2022-10-08T01:57:43.048Z caller=head.go:740 component=tsdb msg="WAL segment loaded" segment=104781 maxSegment=142618
2022-10-08_01:57:43.04956 level=info ts=2022-10-08T01:57:43.048Z caller=head.go:740 component=tsdb msg="WAL segment loaded" segment=104782 maxSegment=142618
2022-10-08_01:57:43.04958 level=info ts=2022-10-08T01:57:43.048Z caller=head.go:740 component=tsdb msg="WAL segment loaded" segment=104783 maxSegment=142618
2022-10-08_01:57:43.04959 level=info ts=2022-10-08T01:57:43.049Z caller=head.go:740 component=tsdb msg="WAL segment loaded" segment=104784 maxSegment=142618
2022-10-08_01:57:43.04959 level=info ts=2022-10-08T01:57:43.049Z caller=head.go:740 component=tsdb msg="WAL segment loaded" segment=104785 maxSegment=142618
2022-10-08_01:57:43.04959 level=info ts=2022-10-08T01:57:43.049Z caller=head.go:740 component=tsdb msg="WAL segment loaded" segment=104786 maxSegment=142618
2022-10-08_01:57:43.05003 level=info ts=2022-10-08T01:57:43.049Z caller=head.go:740 component=tsdb msg="WAL segment loaded" segment=104787 maxSegment=142618
2022-10-08_01:57:43.05043 level=info ts=2022-10-08T01:57:43.050Z caller=head.go:740 component=tsdb msg="WAL segment loaded" segment=104788 maxSegment=142618
  1. 查找日志文件超大
    /var/lib/containers/storage/overlay-containers/[container id]/userdata/crt.log

解决方法

  1. 新建或者编辑配置文件: /etc/containers/containers.conf(root 用户)
[containers]
log_size_max=10485760
  1. 重启所有容器,使配置生效。

你可能感兴趣的:(解决podman crt.log日志过大的问题)