How to handle master changed during mongorestore? I have a very large dump data(18GB) need to restore. I tried to use mongorestore to restore the data to a replica set. But the restore process canceled because of error restoring from orders.bson: insertion error: not master. I think this is because the master get changed in the replica set. Is there a way for me to restore the data and stop changing primary on the replica set roles?
Yes and no. You need to check from log file, why primary status was moved to other node, because it's not happened without reason.

You can always change your rs.conf() so, one node have higher priority than other, so it stays primary as long as it can. 

But in this situation you still need to check from mongod.log file reason why replica sets nodes voted that move primary status was necessary.