20

I am trying to create a replica set with MongoDb, the servers hostnames are:

hostname hostname-1 hostname-2

Each of these has all the relevant hostnames detailed in their /etc/hosts file (They;re all running Ubuntu 10.04 64-bit)

When I do an rs.initiate on one node everything seems to start well. Running rs.status(); shows:

{
    "set" : "vega",
    "date" : ISODate("2012-01-22T19:15:55Z"),
    "myState" : 1,
    "members" : [
        {
            "_id" : 0,
            "name" : "hostname:27017",
            "health" : 1,
            "state" : 1,
            "stateStr" : "PRIMARY",
            "optime" : {
                "t" : 1327254848000,
                "i" : 1
            },
            "optimeDate" : ISODate("2012-01-22T17:54:08Z"),
            "self" : true
        }
    ],
    "ok" : 1
}

The problem comes when I try to add a new member to the replica set. I use the command rs.add(hostname-1); and I get the following error:

{
    "assertion" : "need most members up to reconfigure, not ok : vega-1:27017",
    "assertionCode" : 13144,
    "errmsg" : "db assertion failure",
    "ok" : 0
}

I've tried numerous combinations of using the hostname, IP address, both with and without the port number and I always get the same problem. The hostname is resolving, i've tried ping hostname-1 and it works fine.

Does anybody have any ideas as to what could be causing this issue?

Unfortunately in the Mongo documentation there are no examples of setting up a replica set in the real world scenario, only using three instances on the same machine which is clearly useless.

Thanks in advance for any help!

Community
  • 1
  • 1
sicr
  • 2,148
  • 5
  • 23
  • 27
  • First place I'd look is in the 'mongodb.log' file for each server. Probably some good hints in there as to (a) whether the servers are talking to each other at all, and if so (b) what the primary server finds objectionable about the joiner. – dampier Jan 23 '12 at 04:51

6 Answers6

15

Remove this in your configuration:

bind_ip = 127.0.0.1

That option is currently incompatible with mongodb replica sets.

KatieK
  • 13,586
  • 17
  • 76
  • 90
10

That error happens when you're adding nodes that aren't "up" (yet). It sounds like either "hostname-1" is unreachable (not in /etc/hosts, no DNS) or it is reachable but isn't running mongodb with the replSet configuration parameter set

phatduckk
  • 1,775
  • 1
  • 14
  • 17
3
{
    "errmsg" : "exception: need most members up to reconfigure, not ok : server2:27017",
    "code" : 13144,
    "ok" : 0
}

I encountered the above error in Mongo 2.4.9. My mistake here is that I didn't specify replSet in the mongo config of the new replica member. rs.add("server2:27017") worked well after.

user241
  • 131
  • 2
2

similar problem i had , the solution was to have a keyfile. http://docs.mongodb.org/manual/tutorial/deploy-replica-set-with-auth/#create-the-key-file-to-be-used-by-each-member-of-the-replica-set

Shimon Doodkin
  • 4,310
  • 34
  • 37
2

Unfortunately in the Mongo documentation there are no examples of setting up a replica set in the real world scenario, only using three instances on the same machine which is clearly useless.

Agreed, it's pretty poor. That example should be completely removed from the docs.

There is another way to start a replica set and that is by using the rs.configure() command. You can also specify all three nodes at once and then issue the rs.inititiate().

See here for an example of specifying all nodes before initiating.

See here for more details on the various commands.

Gates VP
  • 44,957
  • 11
  • 105
  • 108
0

You may need to check the mongod is running on the second node before you add the second node to node1. If it is running rs.add() and then check rs.status().