MongoDB oplog 设置

运行时设置:
rs0:PRIMARY> use local
switched to db local
rs0:PRIMARY> 
rs0:PRIMARY> db.oplog.rs.stats().maxSize
1048576000

rs0:PRIMARY> db.adminCommand({replSetResizeOplog:1, size: 16384})
{
"ok" : 1,
"operationTime" : Timestamp(1536311345, 1),
"$clusterTime" : {
"clusterTime" : Timestamp(1536311345, 1),
"signature" : {
"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
"keyId" : NumberLong(0)
}
}
}
rs0:PRIMARY> db.oplog.rs.stats().maxSize
NumberLong("17179869184")

--查询:
rs0:PRIMARY> rs.printReplicationInfo()
configured oplog size:   16384MB
log length start to end: 804951secs (223.6hrs)
oplog first event time:  Wed Aug 29 2018 09:36:14 GMT+0800 (CST)
oplog last event time:   Fri Sep 07 2018 17:12:05 GMT+0800 (CST)
now:                     Fri Sep 07 2018 17:12:11 GMT+0800 (CST)
rs0:PRIMARY> db.getReplicationInfo()
{
"logSizeMB" : 16384,
"usedMB" : 8.45,
"timeDiff" : 804961,
"timeDiffHours" : 223.6,
"tFirst" : "Wed Aug 29 2018 09:36:14 GMT+0800 (CST)",
"tLast" : "Fri Sep 07 2018 17:12:15 GMT+0800 (CST)",
"now" : "Fri Sep 07 2018 17:12:15 GMT+0800 (CST)"
}


--配置文件设置:mongod.conf
oplogSize=1000
表示操作日志大小为1000MB。

参考:
https://docs.mongodb.com/manual/core/replica-set-oplog/
https://docs.mongodb.com/manual/reference/command/replSetResizeOplog/#dbcmd.replSetResizeOplog
https://docs.mongodb.com/manual/reference/configuration-file-settings-command-line-options-mapping/index.html

 

相关推荐
©️2020 CSDN 皮肤主题: 技术工厂 设计师:CSDN官方博客 返回首页