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

Migrating a standalone mongod instance


Basically, there are two ways to move a standalone mongod instance to another server:

  • Convert it to a replica set and follow replica set migration

  • Move dbpath to the new server manually

However, the first approach is recommended since it has less outage. We will introduce both methods in further sections.

Converting an existing instance to a replica set

There are some straightforward steps to convert a standalone instance to a replica set. As you already learned in previous chapters, a replica set should have a name. This name is configurable via a configuration file or command-line parameters for the mongod process.

In order to define the replica set's name, you can use the replSet setting. For instance, the following configuration file sets the replica set name to rs1:

logpath = /var/log/mongodb.log
port = 27017
fork = true
replSet = rs1

Also, you can use the following command-line parameters:

mongod --port 27017 --dbpath /var/log/mongodb.log --replSet rs1...