Comments Off on Adding a new server to a Mongo replica set
and posted in Just For Fun

Ok, so you have a new mongo server setup and you want to add it to an existing replica set.  Lets just make this easy, we will talk authentication another time.  Assume this time you have your mongo server installed, you have the firewall setup to allow remote connections.

  1. edit the mongod.conf file – usually in /etc/mongod.conf
    make sure it is configured to listen on all interfaces, or the one you want…
    Make sure you add the same replica set name so that it can join the group.
  2. Login to your current primary mongo server
  3. execute this command to add it
    rs.add({“_id” : 3, “host” : “servername:27017”, “tags” : {“dc”: “dcname”}})
    you can also add priority and such, but just keeping things simple here.
  4. Now the new server will sync the data and then it will be ready to go!
Comments are closed.