Mongodb 的特殊数据库—local详解

Mongodb 保留了一个特殊的数据库——local,local数据库里面的内容是不能复制的
1、local包含哪些collections、
me
oplog.rs
replset.election
replset.minvalid
startup_log
system.replset
2、me
shard1:PRIMARY> db.me.find({})
{ "_id" : ObjectId("59f54dc5b459bbacc3f2e271"), "host" : "Mongodb-test-05" }
记录本机情况,本机hostname
3、oplog.rs
oplog的集合
shard1:PRIMARY> db.oplog.rs.find({}).limit(1).pretty();
{
"ts" : Timestamp(1517552496, 2062),
"t" : NumberLong(10),
"h" : NumberLong("-5383463938642272409"),
"v" : 2,
"op" : "u",
"ns" : "z3dbus.Z3_CAP_INFO_SUBS",
"o2" : {
"_id" : "002466.SZ-1-20180202"
},
"o" : {
"$set" : {
"day_array.1" : {
"period" : 2,
"inflow" : NumberLong(599221863),
"outflow" : NumberLong(619053038),
"netflow" : NumberLong(-19831175),
"chg_pct" : 0
}
}
}
}
ts: 8字节的时间戳,由4字节unix timestamp + 4字节自增计数表示。这个值很重要,在选举(如master宕机时)新primary时,会选择ts最大的那个secondary作为新primary
op:1字节的操作类型
"i": insert
"u": update
"d": delete
"c": db cmd
"db":声明当前数据库 (其中ns 被设置成为=>数据库名称+ '.')
"n": no op,即空操作,其会定期执行以确保时效性
ns:操作所在的namespace
o:操作所对应的document,即当前操作的内容(比如更新操作时要更新的的字段和值)
o2: 在执行更新操作时的where条件,仅限于update时才有该属性
4、replset.election
shard1:PRIMARY> db.replset.election.find({}).pretty();
{
"_id" : ObjectId("59f54e88b459bbacc3f2e296"),
"term" : NumberLong(10),
"candidateIndex" : NumberLong(0)
}


5、replset.minvalid
在replica set 内部使用,用于跟踪同步状态(track sync status)
shard1:PRIMARY> db.replset.minvalid.find({}).pretty();
{
"_id" : ObjectId("59f54e7db459bbacc3f2e282"),
"ts" : Timestamp(1515047241, 1),
"t" : NumberLong(9),
"oplogDeleteFromPoint" : Timestamp(0, 0)
}


6、startup_log
shard1:PRIMARY> db.startup_log.find({}).limit(1).pretty();
{
"_id" : "Mongodb-test-05-1509248453496",
"hostname" : "Mongodb-test-05",
"startTime" : ISODate("2017-10-29T03:40:53Z"),
"startTimeLocal" : "Sun Oct 29 11:40:53.496",
"cmdLine" : {
"config" : "/data/servers/mongodb/shard1/shard1.conf",
"net" : {
"http" : {
"enabled" : false
},
"port" : 27011
},
"processManagement" : {
"fork" : true,
"pidFilePath" : "/data/servers/mongodb/shard1/shard1.pid"
},
"replication" : {
"oplogSizeMB" : 10000,
"replSet" : "shard1"
},
"sharding" : {
"clusterRole" : "shardsvr"
},
"storage" : {
"dbPath" : "/data/servers/mongodb/shard1/data",
"directoryPerDB" : true,
"mmapv1" : {
"preallocDataFiles" : false
}
},
"systemLog" : {
"destination" : "file",
"logAppend" : true,
"path" : "/data/servers/mongodb/shard1/logs/shard1.log"
}
},
"pid" : NumberLong(38903),
"buildinfo" : {
"version" : "3.4.4",
"gitVersion" : "888390515874a9debd1b6c5d36559ca86b44babd",
"modules" : [ ],
"allocator" : "tcmalloc",
"javascriptEngine" : "mozjs",
"sysInfo" : "deprecated",
"versionArray" : [
3,
4,
4,
0
],
"openssl" : {
"running" : "disabled",
"compiled" : "disabled"
},
"buildEnvironment" : {
"distmod" : "",
"distarch" : "x86_64",
"cc" : "/opt/mongodbtoolchain/v2/bin/gcc: gcc (GCC) 5.4.0",
"ccflags" : "-fno-omit-frame-pointer -fno-strict-aliasing -ggdb -pthread -Wall -Wsign-compare -Wno-unknown-pragmas -Winvalid-pch -Werror -O2 -Wno-unused-local-typedefs -Wno-unused-function -Wno-deprecated-declarations -Wno-unused-but-set-variable -Wno-missing-braces -fstack-protector-strong -fno-builtin-memcmp",
"cxx" : "/opt/mongodbtoolchain/v2/bin/g++: g++ (GCC) 5.4.0",
"cxxflags" : "-Woverloaded-virtual -Wno-maybe-uninitialized -std=c++11",
"linkflags" : "-pthread -Wl,-z,now -rdynamic -Wl,--fatal-warnings -fstack-protector-strong -fuse-ld=gold -Wl,--build-id -Wl,-z,noexecstack -Wl,--warn-execstack -Wl,-z,relro",
"target_arch" : "x86_64",
"target_os" : "linux"
},
"bits" : 64,
"debug" : false,
"maxBsonObjectSize" : 16777216,
"storageEngines" : [
"devnull",
"ephemeralForTest",
"mmapv1",
"wiredTiger"
]
}
}


7、system.replset
保存replica set 的配置文件(可通过shell下rs.conf()查询或者直接查询)
shard1:PRIMARY> db.system.replset.find({}).limit(1).pretty();
{
"_id" : "shard1",
"version" : 1,
"protocolVersion" : NumberLong(1),
"members" : [
{
"_id" : 0,
"host" : "10.77.4.37:27011",
"arbiterOnly" : false,
"buildIndexes" : true,
"hidden" : false,
"priority" : 2,
"tags" : {

},
"slaveDelay" : NumberLong(0),
"votes" : 1
},
{
"_id" : 1,
"host" : "10.77.4.38:27011",
"arbiterOnly" : false,
"buildIndexes" : true,
"hidden" : false,
"priority" : 1,
"tags" : {

},
"slaveDelay" : NumberLong(0),
"votes" : 1
},
{
"_id" : 2,
"host" : "10.77.4.39:27011",
"arbiterOnly" : true,
"buildIndexes" : true,
"hidden" : false,
"priority" : 1,
"tags" : {

},
"slaveDelay" : NumberLong(0),
"votes" : 1
}
],
"settings" : {
"chainingAllowed" : true,
"heartbeatIntervalMillis" : 2000,
"heartbeatTimeoutSecs" : 10,
"electionTimeoutMillis" : 10000,
"catchUpTimeoutMillis" : 2000,
"getLastErrorModes" : {

},
"getLastErrorDefaults" : {
"w" : 1,
"wtimeout" : 0
},
"replicaSetId" : ObjectId("59f54e7db459bbacc3f2e27d")
}
}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值