修改(Secondary,Primary set)Oplog文件大小

来源:互联网 发布:淘宝秒杀在哪? 编辑:程序博客网 时间:2024/06/16 12:10
1.Restart a Secondary in Standalone Mode on a Different Port  db.shutdownServer()  mongod --port 37017 --dbpath /data/standby2.Create a Backup of the Oplog (Optional)   mongodump --db local --collection 'oplog.rs' --port 370173.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/standby8.查看日志文件大小  rs0:SECONDARY> use local  switched to db local  rs0:SECONDARY> db.oplog.rs.totalSize()  2097152  //2MB8.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.

0 0