Port number change in replicaset

Hi Team,

We have a 2 node replicaset in production. I need to change the port number in two nodes. How can i achieve this

maybe this? assume you have node A and B

  1. remove A from replica set (if primary, go with B first)
  2. restart A on a different port
  3. add A back
  4. if B is primary, step down
  5. remove B from replica set.
  6. repeat step 2 and 3.