Mongodb3.6.0开启oplog

官网上安装的话,其配置在/etc/mongo.conf中,

replication:   #注意需要把replication的#注释掉
   oplogSizeMB: 1024
   replSetName: rs

然后登录到mongo shell里执行命令:

>use admin

>rs.initiate()
出现如下内容:
{
    "info2" : "no configuration specified. Using a default configuration for the set",
    "me" : "127.0.0.1:27017",
    "ok" : 1,
    "operationTime" : Timestamp(1513250472, 1),
    "$clusterTime" : {
        "clusterTime" : Timestamp(1513250472, 1),
        "signature" : {
            "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
            "keyId" : NumberLong(0)
        }
    }
}
rs:SECONDARY>
这样就有了oplog了
之后输入如下内容:
rs:SECONDARY>use local

rs:PRIMARY> db.getCollection('oplog.rs').find({})db.getCollection('oplog.rs').find({})
其内容如下:
{ "ts" : Timestamp(1513250472, 1), "h" : NumberLong("4812645723671343880"), "v" : 2, "op" : "n", "ns" : "", "wall" : ISODate("2017-12-14T11:21:12.994Z"), "o" : { "msg" : "initiating set" } }
{ "ts" : Timestamp(1513250475, 1), "t" : NumberLong(1), "h" : NumberLong("827254446641096030"), "v" : 2, "op" : "n", "ns" : "", "wall" : ISODate("2017-12-14T11:21:15Z"), "o" : { "msg" : "new primary" } }
{ "ts" : Timestamp(1513250475, 2), "t" : NumberLong(1), "h" : NumberLong("5457590822814226556"), "v" : 2, "op" : "c", "ns" : "config.$cmd", "ui" : UUID("a267e744-0a99-4603-a0b7-7aa0d3d8c350"), "wall" : ISODate("2017-12-14T11:21:15.010Z"), "o" : { "create" : "transactions", "idIndex" : { "v" : 2, "key" : { "_id" : 1 }, "name" : "_id_", "ns" : "config.transactions" } } }
{ "ts" : Timestamp(1513250475, 3), "t" : NumberLong(1), "h" : NumberLong("-3522893346090865982"), "v" : 2, "op" : "c", "ns" : "admin.$cmd", "ui" : UUID("5ae78f34-bf7e-4c3e-bb12-7bba002f29d3"), "wall" : ISODate("2017-12-14T11:21:15.035Z"), "o" : { "create" : "system.keys", "idIndex" : { "v" : 2, "key" : { "_id" : 1 }, "name" : "_id_", "ns" : "admin.system.keys" } } }
{ "ts" : Timestamp(1513250475, 4), "t" : NumberLong(1), "h" : NumberLong("1565510383389618261"), "v" : 2, "op" : "i", "ns" : "admin.system.keys", "ui" : UUID("5ae78f34-bf7e-4c3e-bb12-7bba002f29d3"), "wall" : ISODate("2017-12-14T11:21:15.035Z"), "o" : { "_id" : NumberLong("6499361300781465601"), "purpose" : "HMAC", "key" : BinData(0,"9cCwGmKbJypLCx8VHiKvqlWxmuA="), "expiresAt" : Timestamp(1521026475, 0) } }
{ "ts" : Timestamp(1513250475, 5), "t" : NumberLong(1), "h" : NumberLong("1762183746673036721"), "v" : 2, "op" : "i", "ns" : "admin.system.keys", "ui" : UUID("5ae78f34-bf7e-4c3e-bb12-7bba002f29d3"), "wall" : ISODate("2017-12-14T11:21:15.035Z"), "o" : { "_id" : NumberLong("6499361300781465602"), "purpose" : "HMAC", "key" : BinData(0,"ITPpoqhDNiUfzYKrYkIWNeb4H6k="), "expiresAt" : Timestamp(1528802475, 0) } }
{ "ts" : Timestamp(1513250495, 1), "t" : NumberLong(1), "h" : NumberLong("2481746203346628102"), "v" : 2, "op" : "n", "ns" : "", "wall" : ISODate("2017-12-14T11:21:35.010Z"), "o" : { "msg" : "periodic noop" } }
{ "ts" : Timestamp(1513250505, 1), "t" : NumberLong(1), "h" : NumberLong("6172448640479246868"), "v" : 2, "op" : "n", "ns" : "", "wall" : ISODate("2017-12-14T11:21:45.010Z"), "o" : { "msg" : "periodic noop" } }
{ "ts" : Timestamp(1513250515, 1), "t" : NumberLong(1), "h" : NumberLong("5167433713763117371"), "v" : 2, "op" : "n", "ns" : "", "wall" : ISODate("2017-12-14T11:21:55.010Z"), "o" : { "msg" : "periodic noop" } }
{ "ts" : Timestamp(1513250525, 1), "t" : NumberLong(1), "h" : NumberLong("-8139691655562346113"), "v" : 2, "op" : "n", "ns" : "", "wall" : ISODate("2017-12-14T11:22:05.010Z"), "o" : { "msg" : "periodic noop" } }
{ "ts" : Timestamp(1513250535, 1), "t" : NumberLong(1), "h" : NumberLong("4967730097253328416"), "v" : 2, "op" : "n", "ns" : "", "wall" : ISODate("2017-12-14T11:22:15.020Z"), "o" : { "msg" : "periodic noop" } }
{ "ts" : Timestamp(1513250545, 1), "t" : NumberLong(1), "h" : NumberLong("-3092670673082419572"), "v" : 2, "op" : "n", "ns" : "", "wall" : ISODate("2017-12-14T11:22:25.020Z"), "o" : { "msg" : "periodic noop" } }
{ "ts" : Timestamp(1513250555, 1), "t" : NumberLong(1), "h" : NumberLong("5833772852597909912"), "v" : 2, "op" : "n", "ns" : "", "wall" : ISODate("2017-12-14T11:22:35.021Z"), "o" : { "msg" : "periodic noop" } }
{ "ts" : Timestamp(1513250565, 1), "t" : NumberLong(1), "h" : NumberLong("4831685641831355782"), "v" : 2, "op" : "n", "ns" : "", "wall" : ISODate("2017-12-14T11:22:45.021Z"), "o" : { "msg" : "periodic noop" } }
{ "ts" : Timestamp(1513250575, 1), "t" : NumberLong(1), "h" : NumberLong("1617364877544031542"), "v" : 2, "op" : "n", "ns" : "", "wall" : ISODate("2017-12-14T11:22:55.022Z"), "o" : { "msg" : "periodic noop" } }
{ "ts" : Timestamp(1513250585, 1), "t" : NumberLong(1), "h" : NumberLong("6473139400268087780"), "v" : 2, "op" : "n", "ns" : "", "wall" : ISODate("2017-12-14T11:23:05.022Z"), "o" : { "msg" : "periodic noop" } }
{ "ts" : Timestamp(1513250595, 1), "t" : NumberLong(1), "h" : NumberLong("-9213531685567738440"), "v" : 2, "op" : "n", "ns" : "", "wall" : ISODate("2017-12-14T11:23:15.022Z"), "o" : { "msg" : "periodic noop" } }
{ "ts" : Timestamp(1513250605, 1), "t" : NumberLong(1), "h" : NumberLong("-6744315517194319156"), "v" : 2, "op" : "n", "ns" : "", "wall" : ISODate("2017-12-14T11:23:25.023Z"), "o" : { "msg" : "periodic noop" } }
{ "ts" : Timestamp(1513250615, 1), "t" : NumberLong(1), "h" : NumberLong("-5232395029001119960"), "v" : 2, "op" : "n", "ns" : "", "wall" : ISODate("2017-12-14T11:23:35.023Z"), "o" : { "msg" : "periodic noop" } }
{ "ts" : Timestamp(1513250625, 1), "t" : NumberLong(1), "h" : NumberLong("1307855744845507452"), "v" : 2, "op" : "n", "ns" : "", "wall" : ISODate("2017-12-14T11:23:45.023Z"), "o" : { "msg" : "periodic noop" } }

你可能感兴趣的:(Mongodb3.6.0开启oplog)