For most replica sets, the hostnames in the host field never change. However, if organizational needs change, you might need to migrate some or all host names. If this is your case, take a look at the following procedure:
From mongoDB replica set primary node (in our case, node 1), execute the following commands:
Then, go to the second node (that maybe has been chosen as the primary node):
Before go out mongoDB interpreter, check if everything is OK now:
If you want to go further, I suggest you to check this post.