Upgrade to Pro — share decks privately, control downloads, hide ads and more …

RS Setup Automation using Python

RS Setup Automation using Python

- RS Setup Automation using Python

Aniket Maithani

November 20, 2020
Tweet

More Decks by Aniket Maithani

Other Decks in Programming

Transcript

  1. Replica Set • A replica set in MongoDB is a

    group of mongod processes that maintain the same data set.
  2. Why do we need Replica Set? • High Availability •

    Better Performance Image ref: https://docs.mongodb.com/manu al/_images/replica-set-read- write-operations- primary.bakedsvg.svg
  3. PyMongo + Python • Used the following libraries along with

    Python- 3.7 • PyMongo – Native Python Driver for MongDB • SSH2-Python – Substitute for Paramiko and faster compared to other libraries • Terraform – Infrastructure
  4. Server Spawning • Using simple terraform script spawned 4 servers.

    • Marked them as Primary, S2, S3 and Arbiter
  5. Steps Involved • Setup IP of machines in /etc/hosts file

    in each machine. 10.2.2.1 mongo1 10.2.2.2 mongo2 10.2.2.3 mongo3
  6. Copy certificate in each of the machines Copy config file

    (mongo.conf) update in each machine and restart the machine
  7. Summary • Took me about 2 days to test this

    up and run it on production. • Challenges : – Ensuring no downtime – Implementation – Security Check list • Use of TF and making collection read only • Easy flow control of the Python script • Documentation for further improvements