0

I am trying to configure a replica set with three nodes: node A, B and C. I execute the rs.add()'s from node A and after that rs.status() shows that the three nodes are PRIMARY. Moreover node B and C have 0 pingMs. If I execute rs.status() from node B or C the only node listed is the self (As PRIMARY). I tried adding an arbiter but it didn't work (it behaved as the nodes B and C). I think this can be a networking problem but I can't figure it out.

Edit: This is the output for netstat -anp|grep 27017:

tcp        0      0 0.0.0.0:27017           0.0.0.0:*               LISTEN      -
tcp        0      0 10.0.1.211:55772        10.0.1.213:27017        TIME_WAIT   -
tcp        0      0 127.0.0.1:50509         127.0.0.1:27017         ESTABLISHED -
tcp        0      0 127.0.0.1:27017         127.0.0.1:50509         ESTABLISHED -
tcp        0      0 10.0.1.211:55774        10.0.1.213:27017        TIME_WAIT   -
tcp        0      0 10.0.1.211:55776        10.0.1.213:27017        ESTABLISHED -
tcp        0      0 10.0.1.211:39180        10.0.1.212:27017        ESTABLISHED -
tcp        0      0 10.0.1.211:39178        10.0.1.212:27017        TIME_WAIT   -
tcp        0      0 10.0.1.211:39176        10.0.1.212:27017        TIME_WAIT   -
unix  2      [ ACC ]     STREAM     LISTENING     3291267  -                   /tmp/mongodb-27017.sock

the private ips for the node B and C are 10.0.1.212 and 10.0.1.213 respectively (they appear to have an established connection in the 27017 port according to the netstat output).

miguel
  • 111
  • 2
  • Sorry, my mistake. Please refer to http://stackoverflow.com/questions/12522349/mongodb-all-nodes-in-replica-set-are-primary – miguel Oct 25 '12 at 05:41

1 Answers1

0

Sounds like the mongo process on Node A didn't actually manage to contact the other two nodes. There are three big arrows pointing to that:

  1. Node A reports all are in PRIMARY. Primary election happens after connection is established. If connection is not yet established, it'll show PRIMARY on everything.
  2. Ping=0. If a connection is established, this should be non-zero.
  3. Nodes B & C haven't heard of any other nodes. If connection happened, they'd have been told that the other nodes are there.

At this point I'd make double sure that...

  • Any firewalls are passing the right port through (usually 27017, but check /etc/mongodb.conf to be certain)
  • Mongo is listening to the expected ports on Nodes B & C.
    • netstat -anp should show a LISTEN port for the Mongo process. Make sure that port's the one you're expecting.
sysadmin1138
  • 133,124
  • 18
  • 176
  • 300
  • I am not sure about how to do the first thing you say (I am new to linux). I configured the mongodb.conf file to listen to the 27017 port and I didn't specify a bind_ip (According to http://www.mongodb.org/display/DOCS/Security+and+Authentication#SecurityandAuthentication-IPAddressBinding "To enable listening on all interfaces, remove the bind_ip option from your server configuration file"). The netstat command shows LISTEN (All the output is up) in the 27017 port. – miguel Oct 02 '12 at 03:23
  • @miguel `sudo iptables -L` will give you the output for that. Fixing it depends on your distro. – sysadmin1138 Oct 02 '12 at 11:23
  • I am using debian and the ifconfig command doesn't have a -L option. What does it do? – miguel Oct 02 '12 at 11:59
  • @miguel I had the wrong command, see the edited comment. – sysadmin1138 Oct 02 '12 at 12:10
  • in every node it shows "policy ACCEPT" for every chain – miguel Oct 02 '12 at 13:22