Mongodb, all replSet stuck in Startup2

I have a mongodb replication set with 2 node (node0, node1), one of which one of them (node1) fails.

given deleting all the data of node1 and restarting, it will take a lot of time, I finish node0 and rsync data in node1

after that I run node0 and node1. both replSet are stuck in STARTUP2, below is the log:

Sat Feb  8 13:14:22.031 [rsMgr] replSet I don't see a primary and I can't elect myself
Sat Feb  8 13:14:24.888 [rsStart] replSet initial sync pending
Sat Feb  8 13:14:24.889 [rsStart] replSet initial sync need a member to be primary or secondary to do our initial sync

How to solve this problem?

+3
source share
2 answers

EDIT 10/29/15: I found there an easier way to find my main resource using rs.reconfigwith the option {force: true}. Here you can find a detailed document here . Use with caution, although, as indicated in the document, this may result in a rollback.

2 , , , , , , . node .

, , 0, node1 , node . , node. , ,

Sat Feb  8 13:14:24.889 [rsStart] replSet initial sync need a member to be primary or secondary to do our initial sync

, , ( ). :

  • 0
  • node0 ( /var/lib/mongodb. /etc/mongodb.conf)
  • . * . ,
    1. , .
    2. .
node0, , node.

mongodb,

  • rs.initiate()
  • node1 : rs.add( "node1 domain name" );

, . .

, .

, , MongoDB 2.4.8. , , gurantee. . , , . Worth tryng;)

  • , . .
  • replSet = [set name], , .
  • node1 db.system.replset. , :

    {    "_id" : "rs0",    "": 5,    "": [{        "_id" : 0,        "host": "node0"   }, {        "_id" : 1,        "host": "node1"   }] }

{
    "_id": "rs0",
    "version": 5,
    "members": [{
        "_id": 0,
        "host": "node0"
    }]
}
  • replSet = [set name], ​​ , node0 .
  • node1 rs.add.

. , - .

+5

MMS. ReplicaSet 3- (2 + 1 , MMS-), STARTUP2 " , "

myReplicaSet:STARTUP2> rs.status()
{
        "set" : "myReplicaSet",
        "date" : ISODate("2015-01-17T21:20:12Z"),
        "myState" : 5,
        "members" : [
                {
                        "_id" : 0,
                        "name" : "server1.mydomain.com:27000",
                        "health" : 1,
                        "state" : 5,
                        "stateStr" : "STARTUP2",
                        "uptime" : 142,
                        "optime" : Timestamp(0, 0),
                        "optimeDate" : ISODate("1970-01-01T00:00:00Z"),
                        "lastHeartbeat" : ISODate("2015-01-17T21:20:12Z"),
                        "lastHeartbeatRecv" : ISODate("2015-01-17T21:20:11Z"),
                        "pingMs" : 0,
                        "lastHeartbeatMessage" : "initial sync need a member to be primary or secondary to do our initial sync"
                },
                {
                        "_id" : 1,
                        "name" : "server2.mydomain.com:27000",
                        "health" : 1,
                        "state" : 5,
                        "stateStr" : "STARTUP2",
                        "uptime" : 142,
                        "optime" : Timestamp(0, 0),
                        "optimeDate" : ISODate("1970-01-01T00:00:00Z"),
                        "infoMessage" : "initial sync need a member to be primary or secondary to do our initial sync",
                        "self" : true
                },
                {
                        "_id" : 3,
                        "name" : "server3.mydomain.com:27000",
                        "health" : 1,
                        "state" : 5,
                        "stateStr" : "STARTUP2",
                        "uptime" : 140,
                        "lastHeartbeat" : ISODate("2015-01-17T21:20:12Z"),
                        "lastHeartbeatRecv" : ISODate("2015-01-17T21:20:10Z"),
                        "pingMs" : 0
                }
        ],
        "ok" : 1
}

, yaoxing-. ReplicaSet MMS , . ... dir:

sudo rm -Rf /var/data/*

ReplicaSet On, .

0

All Articles