5

I am running MongoDB 2.6.2 and I have a replica set with a primary, secondary and an arbiter. Are there any adverse effects to running a mongoimport command with only one or two of the replica set members?

More specifically, does the arbiter need to be specified in the --host option of the mongoimport command? The documentation clearly describes the hostname format (here), but does not warn against how many of the members need to be specified.

  • You can specify only a single seed member. It will obtain the set configuration from that member. Its as easy as giving it a try – Ori Dar May 15 '15 at 17:54

1 Answers1

5

mongoimport command should be run on primary host as this is an insert operation and all insert can be done on primary node only. Secondary nodes cannot entertain write operation directly. In a replicaset, primary node gets the data first and then secondary nodes reads the primary node's oplog and replicate the operations.

Simply put, if you are using a replicaset and you want import data using mongoimport then you must pass primary node as host to mongoimport command.

Also, mongoimport command does't care about arbiter. All it cares is, if it can write data to the node or not. In case of replicaset, you can insert data only on primary node.

Abhay PS
  • 4,015
  • 5
  • 25
  • 32
  • Thank you for the response Abhay, I will mark yours as the accepted answer; however, I think that the mongoimport command should also contain the secondary members in the event that the primary instance goes down and the secondary becomes primary. – Miguel Mendoza May 15 '15 at 19:13
  • It's also worth noting that if one of the mongo instances is down for whatever reason, a mongoimport including the primary and secondary hosts will indicate a failed connection. – Miguel Mendoza May 19 '15 at 16:33