MongoDb:无法更改其oplog大小

时间:2015-11-05 11:50:16

标签: mongodb

我需要通过对现有成员进行操作来更改oplog大小。 (不使用具有预先配置的所需oplog大小的其他成员)

我没有使用这本官方手册:https://docs.mongodb.org/manual/tutorial/change-oplog-size/ 表明在独立模式下运行时可以找到oplog.rs 这是错的。至少在我的情况下。 所以,请任何人指出我正确的方向来完成我的任务

我已经采取行动来表明问题

首先,已登录到SECONDARY成员并转储其oplog.rs以确保它存在:

# mongodump --db local --collection 'oplog.rs' --port 27018
connected to: 127.0.0.1:27018
Thu Nov  5 13:26:44.369 DATABASE: local  to     dump/local
Thu Nov  5 13:26:44.370         local.oplog.rs to dump/local/oplog.rs.bson
Thu Nov  5 13:26:44.410                  273 objects
Thu Nov  5 13:26:44.410         Metadata for local.oplog.rs to dump/local/oplog.rs.metadata.json

检查已倾倒的内容:

# find dump/ -ls
917559    4 drwxr-xr-x   3 root     root         4096 Nov  5 13:26 dump/
917560    4 drwxr-xr-x   2 root     root         4096 Nov  5 13:26 dump/local
917561 9516 -rw-r--r--   1 root     root      9742693 Nov  5 13:26 dump/local/oplog.rs.bson
917562    4 -rw-r--r--   1 root     root           79 Nov  5 13:26 dump/local/oplog.rs.metadata.json

所以oplog.rs存在于辅助中并且其中包含一些数据。 删除转储目录..

# rm -rf dump

然后,切换到独立......

# mongod --port 37018 --dbpath /var/lib/mongodb/mongod-oplog-test2&
[4] 25587
# Thu Nov  5 13:29:41.690 [initandlisten] MongoDB starting : pid=25587 port=37018 dbpath=/var/lib/mongodb/mongod-oplog-test2 64-bit host=mongohost.net.local
Thu Nov  5 13:29:41.690 [initandlisten] db version v2.4.14
Thu Nov  5 13:29:41.690 [initandlisten] git version: nogitversion
Thu Nov  5 13:29:41.690 [initandlisten] build info: Linux buildvm-24.phx2.fedoraproject.org 3.19.5-200.fc21.x86_64 #1 SMP Mon Apr 20 19:51:56 UTC 2015 x86_64 BOOST_LIB_VERSION=1_41
Thu Nov  5 13:29:41.690 [initandlisten] allocator: tcmalloc
Thu Nov  5 13:29:41.690 [initandlisten] options: { dbpath: "/var/lib/mongodb/mongod-oplog-test2", port: 37018 }
Thu Nov  5 13:29:41.715 [initandlisten] journal dir=/var/lib/mongodb/mongod-oplog-test2/journal
Thu Nov  5 13:29:41.715 [initandlisten] recover : no journal files present, no recovery needed
Thu Nov  5 13:29:41.739 [websvr] admin web console waiting for connections on port 38018
Thu Nov  5 13:29:41.741 [initandlisten] waiting for connections on port 37018

检查是否可以通过mongodump找到oplog.rs,期望看到与上次在副本模式下运行时相同的结果:

# mongodump --db local --collection 'oplog.rs' --port 37018
Thu Nov  5 13:51:17.614 [initandlisten] connection accepted from 127.0.0.1:54388 #10 (1 connection now open)
Thu Nov  5 13:51:17.615 DATABASE: local  to     dump/local

# find dump/ -ls
917559    4 drwxr-xr-x   3 root     root         4096 Nov  5 13:51 dump/
917560    4 drwxr-xr-x   2 root     root         4096 Nov  5 13:51 dump/local

我们在这里什么都看不到。

检查我们是否可以访问oplog.rs ...

#  mongo --port 37018
MongoDB shell version: 2.4.14
connecting to: 127.0.0.1:37018/test
> use local;
switched to db local
> show tables;
startup_log
>

并且没有oplog.rs集合......

是时候修理手册还是我理解错了?

1 个答案:

答案 0 :(得分:0)

我发现了什么问题,我希望这个案例也会被记录下来:

我的mongo.conf包含指令:

directoryperdb = true

所以我应该在命令行中使用指令--directoryperdb来独立运行:

mongod --directoryperdb --port 37018 --dbpath /var/lib/mongodb/mongod-oplog-test2