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

Failover testing


In this section, we will deactivate the specific nodes to force the replica set to make an election and change the nodes' role.

First of all, we will deactivate one of the secondary nodes by stopping the mongod service on the secondary machine.

Right after stopping the service of mongod3.replicaset.com, the replica set will set this node as an unreachable secondary node, as shown in the following screenshot:

The status of the replica set shows that the third member has an issue, so this member becomes unavailable until the replica set gets a ping from it. After starting the service again, the members' status changes again as shown in the following screenshot:

Note

Network issues or hardware failure on the member's machine also has the same result as stopping the MongoDB service.

For the next test, we will halt the primary node's service. After stopping the service in the primary node, the replica set uses an election process to choose the next primary node from secondary nodes...