oplogsizeを修正すると、mongodbが起動できなくなります。


1.故障現象
mongodbデータベースはmater-slavieを有効にしています。プロファイルを変更した後、mongodbは起動できません。
2.故障分析
mongod.logログログを見ると、次のようなキーワードがあります。
2016-06-06 T 23:03:16.752+0800 I REPL    [initand listen]cmdline oplogsize(2048)ディfferent than existing(990)see:http://dochub.mongodb.org/core/increase-oplog
私たちがoplogsizeを修正する方法が間違っているようです。直接に設定ファイルを修正してからmongodbを再開します。ログには具体的な操作方法が貼ってあります。
3.故障解決
ログで提供されたリンクによって、どのように正確にoplogsizeのサイズを変更するかを確認します。
  http://dochub.mongodb.org/core/increase-oplog
Change the Size of the Oplog/
On this page
Overview Proccedure The OPロゴ exists internally as a capped collection,so you cannot modify its size in the course of normal operations.In most cases the default oplog size is an acceptable size;however,in some situations you may need a larger or smaaller oplogs.For example,you might need to change the oplogs size if your appication s perform large numbers of multi-udates or deletes.
This tutorial describes how to resize the oplogs.For a detailed explanion of oplog sizing,see Oplog Size.For details how oplogs size affects delayed members and affects replication lag,see Delayed Replica Set Members.
Overview
To change the size of the oplog,you must perform mantence on each member of the replica set in turn.The procedure requires:stopping the mongod instance and starting as a standunlone instance、modifying the oplog size、and retating the member.
IMPORTANT
Always start rolling replica set mantence with the secondaries、and finish with the mantence on primere.
Proccedure
Restart the member in standowne mode.
TIP
Always use rs.step Down() to force the price to become a secondary,before stopping the server.This facility a more efficient election process.
Recreate the oplogs with the new size and with an old oplogntry as.Restart the mongod instance as a member of the replica set.Restart a Secondary in Standarlone Mode on a Different Port
Shut down the mongod instance for one of the non-primers of your replica set.For example,to shut down,use the db.shutdown Server() method:
db.shutdownServer()
Restart this mongod as a standowne instance running on a different port and without the --replSet parameter.Use a command simiar to the followwing:
mongod --port 37017 --dbpath /srv/mongodb
Create a Backup of the Oplog(Optional)
Optionally、backup the existing oplogn the standowne instance、as in the follwing example:
mongodump --db local --collection 'oplog.rs' --port 37017
Recreate the Oplog with a New Size and a Seed Entry
Save the last entry from the oplogs.For example,connect to the instance using the モンゴ shell、and enter the follwing command to switch to the local database:
use local
In モンゴ shell scripts you can use the follwing operation to set the db object:
db = db.getSiblingDB('local')
Ense that the temp temporary collection is empty by dropping the collection:
db.temp.drop()
Use the db.co llection.save() method and a sort on reverse natual order to find the last entry and save it to a temporary collection:
db.temp.save( db.oplog.rs.find( { }, { ts: 1, h: 1 } ).sort( {$natural : -1} ).limit(1).next() )
To see this oplogntry,use the follwing operation:
db.temp.find()
Remove the Existing Oplog Collection
Drop the old oplog.rs コレクションin the local database.Use the follwing command:
db = db.getSiblingDB('local')db.oplog.rs.drop()
This returns true in the shell.
Create a New Oplog
Use the create command to create a new oplogs of a different size.Specify the size argment in bytes.A value of 2 * 1024 * 1024 * 1024 will create a new oplog that’s 2 gigabytes:
db.runCommand( { create: "oplog.rs", capped: true, size: (2 * 1024 * 1024 * 1024) } )
Upon success、this command returns the following status:
{ "ok" : 1 }
Insert the Last Entry of the Old Oplog into the New Oplog
Insert the previously saved last entry from the old oplog into the new oplogs.For example:
db.oplog.rs.save( db.temp.findOne() )
To confirm the entry is in the new oplogs,use the follwing operation:
db.oplog.rs.find()
Restart theメンバー
Restart the mongod as a member of the replica set on its usual port.For example:
db.shutdownServer()mongod --replSet rs0 --dbpath /srv/mongodb
The replica set member will recover and「catch up」before it is eligible for election to prmary.
Repeat Process for all Members that may become Primary
Repeat this procedure for all members you want to change the size of the oplogs.Repeat the procedure for the prive as parts of the follwing step.
Change the Size of the Oplog on the Primary
To finish the rolling mantnance operation,step down the primary with the rs.step Down() method and repeat the oplogs resizing procedure above.