mongodb logrotation 正在创建,但没有写入日志

问题描述 投票:0回答:1

我已经在我的 ubuntu 服务器上安装了 mongodb,并且还在我的服务器中安装了 logrotation 以轮换日志并使用数据创建一个新日志

我正在添加我的

/etc/mongod.conf

#  wiredTiger:

# where to write logging data.
systemLog:
  destination: file
  logAppend: true
  logRotate: reopen
  path: /var/mongodb/log/*.log

# network interfaces
net:
  port: 27017
  bindIp: 0.0.0.0


# how the process runs
processManagement:
  timeZoneInfo: /usr/share/zoneinfo

security:
    authorization: enabled

#operationProfiling:

#replication:

#sharding:

## Enterprise-Only Options:

#auditLog:

我也添加我的

/etc/logrotate.d/mongodb

 /var/log/mongodb/mongod.log {
#    state /var/lib/logrotate/status-mongodb
    hourly
    rotate 96
    size 100M
    missingok
    create 0600 mongodb mongodb
    notifempty
    compress
    delaycompress
    sharedscripts
    postrotate
         if /usr/sbin/pidof -s mongod > /dev/null ; then kill -USR1 $( /usr/sbin/pidof mongod ) ; fi
         /bin/kill -SIGUSR1 `cat /var/run/mongodb/mongod.pid 2>/dev/null` 2> /dev/null || true
#        /bin/kill -SIGUSR1 `cat /var/lib/mongo/mongod.lock 2> /dev/null` 2> /dev/null || true
#        /bin/kill -SIGUSR1 $(cat /var/run/mongodb.pid)
#        systemctl restart mongod >/dev/null 2>&1 || true
    endscript
}

同时添加我的

logrotate.conf
文件

# see "man logrotate" for details

# global options do not affect preceding include directives

# rotate log files weekly
*/15

# use the adm group by default, since this is the owning group
# of /var/log/syslog.
su root adm

# keep 4 weeks worth of backlogs
rotate 4

# create new (empty) log files after rotating old ones
create

# use date as a suffix of the rotated file
#dateext

# uncomment this if you want your log files compressed
#compress

# packages drop log rotation information into this directory
include /etc/logrotate.d

# system-specific logs may also be configured here.

我已经提到了这一切,但仍然没有成功旋转日志,并且日志没有被写入。

我尝试更改配置强制启动 logrotation ,甚至尝试使用 cron 来为其创建日志,但仍然没有成功。 请帮我解决这个问题

linux mongodb ubuntu
1个回答
0
投票

路径错误,必须使用

systemLog:
  destination: file
  logAppend: true
  logRotate: reopen
  path: /var/log/mongodb/mongod.log
© www.soinside.com 2019 - 2024. All rights reserved.