2018-07-17T19:04:27.343+0800 I REPL [ReplicationExecutor] syncing from: 10.204.11.48:9303 2018-07-17T19:04:27.347+0800 W REPL [rsBackgroundSync] we are too stale to use 10.204.11.48:9303 as a syncsource 2018-07-17T19:04:27.347+0800 I REPL [ReplicationExecutor] could not find member to sync from 2018-07-17T19:04:27.347+0800 E REPL [rsBackgroundSync] too stale to catch up -- entering maintenance mode 2018-07-17T19:04:27.347+0800 I REPL [rsBackgroundSync] our last optime : (term: -1, timestamp: Jul 16 11:55:17:103bb) 2018-07-17T19:04:27.347+0800 I REPL [rsBackgroundSync] oldest available is (term: -1, timestamp: Jul 17 12:49:36:9ffb) 2018-07-17T19:04:27.347+0800 I REPL [rsBackgroundSync] See http://dochub.mongodb.org/core/resyncingaverystalereplicasetmember 2018-07-17T19:04:27.347+0800 I REPL [ReplicationExecutor] going into maintenance mode with 1856 other maintenance mode tasks in progress
显然节点脱离集群时间过长,已经不能同其他节点同步。这种情况下可以通过两种方式将节点重新加入集群。 第一种方法:Automatically Sync a Member 这种方式比较简单,先关闭阶段,清空 data 目录,重启节点。然后就会自动重新同步 具体: a. 关闭节点 db.shutdownServer() b. 清空data目录 mv data data_old ;mkdir data c.启动节点 mongod -f /etc/mongodb9303.cnf 如下是启动之后开始同步的日志。
2018-07-17T21:38:01.131+0800 I REPL [ReplicationExecutor] This node is 10.204.11.50:9303 in the config 2018-07-17T21:38:01.131+0800 I REPL [ReplicationExecutor] transition to STARTUP2 2018-07-17T21:38:01.131+0800 I ASIO [NetworkInterfaceASIO-Replication-0] Connecting to 10.204.11.48:9303 2018-07-17T21:38:01.132+0800 I REPL [ReplicationExecutor] Member 10.204.11.70:9303 is now in state ARBITER 2018-07-17T21:38:01.134+0800 I ASIO [NetworkInterfaceASIO-Replication-0] Successfully connected to 10.204.11.48:9303, took 3ms (1 connections now open to 10.204.11.48:9303) 2018-07-17T21:38:01.134+0800 I REPL [ReplicationExecutor] Member 10.204.11.48:9303 is now in state PRIMARY 2018-07-17T21:38:01.572+0800 I NETWORK [initandlisten] connection accepted from 10.204.11.48:59332 #2 (2 connections now open) 2018-07-17T21:38:01.587+0800 I ACCESS [conn2] Successfully authenticated as principal __system on local 2018-07-17T21:38:02.131+0800 I REPL [rsSync] ****** 2018-07-17T21:38:02.131+0800 I REPL [rsSync] creating replication oplog of size: 20480MB... 2018-07-17T21:38:02.133+0800 I STORAGE [rsSync] Starting WiredTigerRecordStoreThread local.oplog.rs 2018-07-17T21:38:02.133+0800 I STORAGE [rsSync] The size storer reports that the oplog contains 0 records totaling to 0 bytes 2018-07-17T21:38:02.133+0800 I STORAGE [rsSync] Scanning the oplog to determine where to place markers for truncation 2018-07-17T21:38:02.137+0800 I REPL [rsSync] ****** 2018-07-17T21:38:02.137+0800 I REPL [rsSync] initial sync pending 2018-07-17T21:38:02.140+0800 I REPL [rsSync] no valid sync sources found in current replset to do an initial sync 2018-07-17T21:38:02.968+0800 I NETWORK [initandlisten] connection accepted from 10.204.11.50:54890 #3 (3 connections now open) 2018-07-17T21:38:03.140+0800 I REPL [rsSync] initial sync pending 2018-07-17T21:38:03.140+0800 I REPL [ReplicationExecutor] syncing from: 10.204.11.48:9303 2018-07-17T21:38:03.144+0800 I REPL [rsSync] initial sync drop all databases 2018-07-17T21:38:03.144+0800 I STORAGE [rsSync] dropAllDatabasesExceptLocal 1 2018-07-17T21:38:03.144+0800 I REPL [rsSync] initial syncclone all databases 2018-07-17T21:38:03.304+0800 I REPL [rsSync] fetching and creating collections for admin 2018-07-17T21:38:03.306+0800 I REPL [rsSync] fetching and creating collections for dmp_edata_leju_com 2018-07-17T21:38:05.698+0800 I REPL [rsSync] fetching and creating collections fortest 2018-07-17T21:38:05.699+0800 I REPL [rsSync] initial sync cloning db: admin 2018-07-17T21:38:05.707+0800 I INDEX [rsSync] build index on: admin.system.users properties: { v: 1, key: { _id: 1 }, name: "_id_", ns: "admin.system.users" }