Converting a standalone server into a replica set

To convert a standalone server into a replica set, we first need to cleanly shut down the mongo server:

> use admin
> db.shutdownServer()

Then, we start the server with the --replSet configuration option via the command line (which we will do here), or by using a configuration file, as we will explain in the next section:

  1. First, we connect (via the mongo shell) to the new replica set enabled instance, as follows:
> rs.initiate()
  1. Now, we have the first server of our replica set. We can add the other servers (which must have also been started with --replSet) by using the mongo shell, as follows
> rs.add("<hostname><:port>")
Double-check the replica set configuration by using rs.conf(). Verify the replica set status by using rs.status().
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset