进入到mongo的命令行交互程序,输入:

use admin
db.auth('root', '密码')
db.runCommand({logRotate: 1})

输出

spy:PRIMARY> db.runCommand({logRotate: 1})
{
    "ok" : 1,    # 1表示成功
    "$clusterTime" : {
        "clusterTime" : Timestamp(1639454694, 22),
        "signature" : {
            "hash" : BinData(0,"cSlu4Fz/b6GilocR/VwfXOWdsxM="),
            "keyId" : NumberLong("7031832375268999172")
        }
    },
    "operationTime" : Timestamp(1639454694, 22)
}

进入日志目录查看日志:
cd /var/log/mongodb

[root@s187049 mongodb]# ll -h
total 1.6G
-rw------- 1 root   root    16K Dec 14 12:06 mongod.log
-rw-r----- 1 mongod mongod 1.1G Dec 14 12:04 mongod.log.2021-12-14T04-04-54

YYGP
25 声望11 粉丝

写BUG