MongoDB 3.4 이전에서는 oplog 컬렉션을 삭제 하고 다시 만들어 줘야 함.
3.4 이상에서는 replSetResizeOplog 명령을 이용하여 oplog의 크기를 변경.
use local rs.printReplicationInfo() -- OPlog Size 및 보관 기간 확인 db.oplog.rs.stats().maxSize --size 확인 후 secondary부터 oplog 사이즈 변경 하고 나중에 Primary 변경 해 준다 db.adminCommand({replSetResizeOplog: 1, size: 16000}) <--- 16GB로 변경 (16000MB) |
예) 3.4.24 버전 OPlog Size 변경 (1G --> 5G)
3.4.24 버전임
Primary : 27342
Secondary : 27341, 27343
repl34:PRIMARY> rs.status()
{
"set" : "repl34",
"date" : ISODate("2021-11-22T06:32:52.007Z"),
"myState" : 1,
"term" : NumberLong(2),
"syncingTo" : "",
"syncSourceHost" : "",
"syncSourceId" : -1,
"heartbeatIntervalMillis" : NumberLong(2000),
"optimes" : {
"lastCommittedOpTime" : {
"ts" : Timestamp(1637562764, 1),
"t" : NumberLong(2)
},
"appliedOpTime" : {
"ts" : Timestamp(1637562764, 1),
"t" : NumberLong(2)
},
"durableOpTime" : {
"ts" : Timestamp(1637562764, 1),
"t" : NumberLong(2)
}
},
"members" : [
{
"_id" : 0,
"name" : "mongoSvr:27341",
"health" : 1,
"state" : 2,
"stateStr" : "SECONDARY",
"uptime" : 949,
생략 ...
},
{
"_id" : 1,
"name" : "mongoSvr:27342",
"health" : 1,
"state" : 1,
"stateStr" : "PRIMARY",
"uptime" : 951,
생략 ...
},
{
"_id" : 2,
"name" : "mongoSvr:27343",
"health" : 1,
"state" : 2,
"stateStr" : "SECONDARY",
"uptime" : 944,
생략 ...
}
],
"ok" : 1
}
-- Secondary 변경
mongo --port 27343 -uroot -proot1122 admin
repl34:SECONDARY> use local
switched to db local
repl34:SECONDARY> rs.printReplicationInfo() ;
configured oplog size: 1024MB
log length start to end: 1633secs (0.45hrs)
oplog first event time: Mon Nov 22 2021 15:13:01 GMT+0900 (KST)
oplog last event time: Mon Nov 22 2021 15:40:14 GMT+0900 (KST)
now: Mon Nov 22 2021 15:40:18 GMT+0900 (KST)
repl34:SECONDARY> db.adminCommand({replSetResizeOplog: 1, size: 5000})
{ "ok" : 1 }
repl34:SECONDARY> rs.printReplicationInfo() ;
configured oplog size: 5000MB
log length start to end: 1683secs (0.47hrs)
oplog first event time: Mon Nov 22 2021 15:13:01 GMT+0900 (KST)
oplog last event time: Mon Nov 22 2021 15:41:04 GMT+0900 (KST)
now: Mon Nov 22 2021 15:41:07 GMT+0900 (KST)
-- Secondary 변경
mongo --port 27341 -uroot -proot1122 admin
repl34:SECONDARY> use local
switched to db local
repl34:SECONDARY> rs.printReplicationInfo() ;
configured oplog size: 1024MB
log length start to end: 1743secs (0.48hrs)
oplog first event time: Mon Nov 22 2021 15:13:01 GMT+0900 (KST)
oplog last event time: Mon Nov 22 2021 15:42:04 GMT+0900 (KST)
now: Mon Nov 22 2021 15:42:05 GMT+0900 (KST)
repl34:SECONDARY> db.adminCommand({replSetResizeOplog: 1, size: 5000})
{ "ok" : 1 }
repl34:SECONDARY> rs.printReplicationInfo() ;
configured oplog size: 5000MB
log length start to end: 1753secs (0.49hrs)
oplog first event time: Mon Nov 22 2021 15:13:01 GMT+0900 (KST)
oplog last event time: Mon Nov 22 2021 15:42:14 GMT+0900 (KST)
now: Mon Nov 22 2021 15:42:22 GMT+0900 (KST)
-- Primary 변경
mongo --port 27342 -uroot -proot1122 admin
repl34:PRIMARY> use local
switched to db local
repl34:PRIMARY> rs.printReplicationInfo() ;
configured oplog size: 1024MB
log length start to end: 1793secs (0.5hrs)
oplog first event time: Mon Nov 22 2021 15:13:01 GMT+0900 (KST)
oplog last event time: Mon Nov 22 2021 15:42:54 GMT+0900 (KST)
now: Mon Nov 22 2021 15:42:54 GMT+0900 (KST)
repl34:PRIMARY> db.adminCommand({replSetResizeOplog: 1, size: 5000})
{ "ok" : 1 }
repl34:PRIMARY> rs.printReplicationInfo() ;
configured oplog size: 5000MB
log length start to end: 1793secs (0.5hrs)
oplog first event time: Mon Nov 22 2021 15:13:01 GMT+0900 (KST)
oplog last event time: Mon Nov 22 2021 15:42:54 GMT+0900 (KST)
now: Mon Nov 22 2021 15:43:03 GMT+0900 (KST)