Giter Site home page Giter Site logo

mongodb_failover_tests's Introduction

mongodb-dr-test

Deployment Architecture Reference :

http://docs.mongodb.org/manual/core/replica-set-architectures/ , http://docs.mongodb.org/manual/tutorial/deploy-geographically-distributed-replica-set/ , http://docs.mongodb.org/manual/tutorial/add-replica-set-arbiter/

Assume P1 is primary, S1 and S2 secondary nodes.

Happy Path Scenario

start the test server by pointing to a Dev / PreProd MongoDB Replicaset MONGODB_REPLICASET=P1:27017, S1:27017, S2:27017 node server.js

Now to test the setup by simply inserting and querying documents : curl -XPOST 'http://localhost:3004/rest/api/' -d '{itemName:"iPhone", price:"200”}' curl -XGET 'http://localhost:3004/rest/api/count/'

DR Scenario - 1

Incidence - S1 / S2 goes down.

Failover Test :

MongoDB should continue to work without interruption.

Writes / Reads should succeed curl -XPOST 'http://localhost:3004/rest/api/' -d '{itemName:"iPhone", price:"200”}' curl -XGET 'http://localhost:3004/rest/api/count/'

Recovery Test :

S1 / S2 is up again MongoDB should perform without issues. Writes / Reads should succeed curl -XPOST 'http://localhost:3004/rest/api/' -d '{itemName:"iPhone", price:"200”}' curl -XGET 'http://localhost:3004/rest/api/count/'

DR Scenario - 2

Incidence - Primary P1 goes down

Failover Test :

MongoDB should perform without issues. One of the secondary in DAL should become Primary Writes / Reads should succeed

curl -XPOST 'http://localhost:3004/rest/api/' -d '{itemName:"iPhone", price:"200”}' curl -XGET 'http://localhost:3004/rest/api/count/' Recovery Test :

Old Primary is up again. Writes / Reads should succeed curl -XPOST 'http://localhost:3004/rest/api/' -d '{itemName:"iPhone", price:"200”}' curl -XGET 'http://localhost:3004/rest/api/count/'

DR Scenario - 3

Incidence - Both S1 and S2 go down.

Failover Test :

MongoDB P1 will become read-only.

Take backup of PRIMARY db

mongodump -oplog --out /app/backup/mongodump-mm-dd-yyyy tar -zcvf mongodump-mm-dd-yyyy.tar.gz /app/bkup/mongodump-mm-dd-yyyy scp mongodump-mm-dd-yyyy.tar.gz p1_:~/temp/

Force secondary to become primary

start mongo shell

mongo cfg = rs.conf()

Find and set the member id of the

for example, cfg.members = [cfg.members[2]] // here members[2] is the surviving one ! rs.reconfig(cfg,{force : true})

Now Writes / Reads should succeed curl -XPOST 'http://localhost:3004/rest/api/' -d '{itemName:"iPhone", price:"200”}' curl -XGET 'http://localhost:3004/rest/api/count/'

Recovery Test :

both S1 and S2 are up.

Add the members to replicaset

login to the box S1 and S2 and start mongod in each box using the start script start mongo shell of primary mongod mongo rs.add() rs.add() Check Replicaset status : rs.conf() and rs.status()

mongodb_failover_tests's People

Contributors

kaniska avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.