我试图在新的mongo副本成员
时进行基准测试我专门查找副本运行初始同步所花费的时间以及新成员解析此类操作的时间戳的确切持续时间。
是否有日志会向我提供此信息?
我目前在mongo shell中使用以下脚本。
MAXSCRIPT_RUN_ITERATIONS = 1800 // approximately 30 minutes
for (var i = 0; i < MAXSCRIPT_RUN_ITERATIONS; i++) {
sleep(1000);
var currentdate = new Date();
var datetime = new Date().toLocaleString();
var rsStatus = rs.status()
var members = rsStatus.members
// Change this index depending on the # of members in your set
var resyncmember = members[0]
var resyncMemberState = resyncmember.stateStr
print("--------------")
print("Member Count: " + members.length + " " + datetime)
for (var n = 0; n < members.length; n++){
var member = members[n]
print("HOST: " + member.name + " State: " + member.stateStr)
}
if (resyncMemberState == "SECONDARY"){
print("########################")
var currentdate = new Date();
print("resyncMember finished: " + datetime)
print("########################")
break
}
}
答案 0 :(得分:1)
您没有说明您正在运行的版本,因此我将提供有关3.0(3.2)的信息应该是相同的。
在mongodb日志中查找以下条目:
2016-02-25T14:59:43.684+0000 I REPL [rsSync] initial sync drop all databases
2016-02-25T14:59:43.684+0000 I REPL [rsSync] initial sync clone all databases
2016-02-25T14:59:43.688+0000 I REPL [rsSync] initial sync cloning db: admin
2016-02-25T14:59:43.833+0000 I REPL [rsSync] initial sync cloning db: db1
2016-02-26T10:31:33.763+0000 I REPL [rsSync] initial sync cloning db: test
2016-02-26T11:27:48.480+0000 I REPL [rsSync] initial sync data copy, starting syncup
2016-02-26T11:27:48.481+0000 I REPL [rsSync] oplog sync 1 of 3
2016-02-26T11:27:49.043+0000 I REPL [ReplicationExecutor] syncing from: xxxxxxxxxx:27017
2016-02-26T11:27:49.059+0000 I REPL [SyncSourceFeedback] replset setting syncSourceFeedback to xxxxxxxxxx:27017
2016-02-26T11:30:05.649+0000 I REPL [rsSync] oplog sync 2 of 3
2016-02-26T11:30:05.657+0000 I REPL [rsSync] initial sync building indexes
2016-02-26T11:30:05.657+0000 I REPL [rsSync] initial sync cloning indexes for : admin
2016-02-26T11:30:05.760+0000 I REPL [rsSync] initial sync cloning indexes for : db1
2016-02-26T11:43:37.262+0000 I REPL [rsSync] initial sync cloning indexes for : test
2016-02-26T11:43:48.271+0000 I REPL [rsSync] oplog sync 3 of 3
2016-02-26T11:43:48.319+0000 I REPL [rsSync] initial sync finishing up
2016-02-26T11:43:48.319+0000 I REPL [rsSync] replSet set minValid=56d03a74:1
2016-02-26T11:43:48.321+0000 I REPL [rsSync] initial sync done
2016-02-26T11:43:48.332+0000 I REPL [ReplicationExecutor] transition to RECOVERING
2016-02-26T11:43:48.348+0000 I REPL [ReplicationExecutor] transition to SECONDARY
如您所见,您可以看到初始同步过程的每个阶段的信息,以及何时转换到 SECONDARY 节点。你会看到比这更多的线条,但我已经减少了以显示你应该寻找的东西。
如果您使用的是Linux或Mac计算机,则可以使用与以下命令类似的命令查看此实时(确保在添加新节点之前运行此命令,否则您可能会遗漏某些行)
tail -f /path/to/mongodb.log | grep REPL
这将在添加条目时监视您的日志文件,并仅显示其中包含字符串REPL的行。记得在获得所需信息后终止tail
命令。