ideawu / ssdb

SSDB - A fast NoSQL database, an alternative to Redis
http://ssdb.io/
BSD 3-Clause "New" or "Revised" License
8.19k stars 1.4k forks source link

请问下var/data目录中 000***.log 的日志文件是如何产生的?如何禁止 #1400

Closed emenwin closed 3 years ago

emenwin commented 3 years ago

请问下var/data目录中 000xxx.log 的日志文件是如何产生的?如何禁止

该log文件非常巨大,000.ldb 文件合计700M, 而单个 000.log 文件大小就达到近30G。

系统环境:

VPS:2C8G 、50G硬盘。 个人使用,所以对于空间利用比较敏感,请问如何操作。

已经操作:

ssdb.conf logger : level -> error replication: binlog -> no

同时:

已经写了定时任务

/1 rm -rf /usr/local/ssdb/var/data/.log , 虽然文件可以删除,但ssdb 仍然持有该文件,所有导致 df -h 查看磁盘大小时,磁盘使用率始终100%,只有重启ssdb后磁盘才被释放。

配置文件如下:

# absolute path, or relative to path of this file, directory must exists
work_dir = ./var
pidfile = ./var/ssdb.pid

server:
        # specify an ipv6 address to enable ipv6 support
        # ip: ::1
        #ip: 127.0.0.1
        port: 8888
        # bind to public ip
        ip: 0.0.0.0
        # format: allow|deny: all|ip_prefix
        # multiple allows or denys is supported
        #deny: all
        #allow: 127.0.0.1
        #allow: 192.168
        # auth password must be at least 32 characters
        auth:
        #readonly: yes
        # in ms, to log slowlog with WARN level
        #slowlog_timeout: 5

replication:
        binlog: no
        # Limit sync speed to *MB/s, -1: no limit
        sync_speed: -1
        slaveof:
                # to identify a master even if it moved(ip, port changed)
                # if set to empty or not defined, ip:port will be used.
                #id: svc_2
                # sync|mirror, default is sync
                #type: sync
                #host: localhost
                #port: 8889

logger:
        level: error
        output: log.txt
        rotate:
                size: 1000000000

leveldb:
        # in MB
        cache_size: 500
        # in MB
        write_buffer_size: 64
        # in MB/s
        compaction_speed: 1000
        # yes|no
        compression: yes
ideawu commented 3 years ago

.log 文件不是日志文件, 不要删除!

*.log 文件是 leveldb 的数据文件, 正常不会有 30GB 大小, 你的使用场景是什么?

emenwin commented 3 years ago

我做了一个未读文章的推服务,每个订阅用户维持一个 zset有序列表,新的文章按照发布时间 将文章唯一id 添加到zset内。 如果用户标记已读,则从表内删除

现在的处理:

在vps上重新附加了一块200G硬盘,将var/data 转移到这块硬盘上。 通过观察,log文件增加到30多G以后,log 大小会重新变为0 ,然后再继续增长。 继续观察使用情况

emenwin commented 3 years ago

使用的空间继续增长了:

-rw-r--r-- 1 root root 133G May 3 08:22 001889.log

如何限制大小?或者调整业务逻辑?

Screen Shot 2021-05-03 at 8 22 40 AM
ideawu commented 3 years ago

如果你没有改源码, 或者做特殊的配置的话, .log 文件应该不会超过 4GB. 因为你的情况是出现了 133GB 的大小, 所以, 你需要检查一下运维工具, 把定期删除文件或者其它类似的运维脚本停掉. 你再仔细想想, 自己是否做了某些操作?

建议你找一个干净的环境, 使用默认的源码和默认的配置, 看看能否复现这个问题.

emenwin commented 3 years ago

猜测应该是开始误删除 log 文件导致的。 具体原因未知