1.Restart a Secondary in Standalone Mode on a Different Port
db.shutdownServer()
mongod --port 37017 --dbpath /data/standby
2.Create a Backup of the Oplog (Optional)
mongodump --db local --collection 'oplog.rs' --port 37017
3.Recreate the Oplog with a New Size and a Seed Entry
use local
db = db.getSiblingDB('local')
db.temp.drop()
db.temp.save( db.oplog.rs.find( { }, { ts: 1, h: 1 } ).sort( {$natural : -1} ).limit(1).next() )
db.temp.find()
4.Remove the Existing Oplog Collection
db = db.getSiblingDB('local')
db.oplog.rs.drop()
5.Create a New Oplog
db.runCommand( { create: "oplog.rs", capped: true, size: (2 * 1024 * 1024) } ) //2MB
6.Insert the Last Entry of the Old Oplog into the New Oplog
db.oplog.rs.save( db.temp.findOne() )
db.oplog.rs.find()
7.Restart the Member
db.shutdownServer()
mongod --replSet "rs0" --dbpath /data/standby
8.查看日志文件大小
rs0:SECONDARY> use local
switched to db local
rs0:SECONDARY> db.oplog.rs.totalSize()
2097152 //2MB
8.Change the Size of the Oplog on the Primary
To finish the rolling maintenance operation, step down the primary with the rs.stepDown() method and repeat the oplog resizing procedure above.
修改(Secondary,Primary set)Oplog文件大小
最新推荐文章于 2023-01-13 09:40:00 发布