Book Image

MongoDB High Availability

By : Afshin Mehrabani
Book Image

MongoDB High Availability

By: Afshin Mehrabani

Overview of this book

Table of Contents (17 chapters)
MongoDB High Availability
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Deploying a replica set


Having completed the initialization steps, we can now start to define our first replica set. First of all, you need to run the mongod process on all machines through the following steps:

  1. Make sure that you have the configuration file in your machine, and then run the following command:

    mongod --config /etc/mongodb.conf
    

    Note

    In Unix operating systems, if you don't have sufficient permissions to run the command, you can use the sudo prefix. So the complete command will be sudo mongod --config /etc/mongodb.conf.

  2. After issuing the command, you should see the result depicted in the following screenshot:

  3. Because we set the fork property to true, mongod will run as a daemon in the background. So, in order to see the logs and outputs of mongod, you should use the defined logpath file. You can see the logfile content as shown in the following screenshot:

  4. For the next steps, you should use mongo interactive shell to run and configure the replica set.

  5. Run the mongo command from your...