Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does the mongoimport command for a replica set require all replica set members including the arbiter?

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.

like image 684
Miguel Mendoza Avatar asked May 15 '15 17:05

Miguel Mendoza


1 Answers

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.

like image 72
Abhay PS Avatar answered Oct 12 '22 22:10

Abhay PS