Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

MongoDB Replication Cluster

1,249 views

Published on

MongoDB Replication Cluster

Published in: Technology, News & Politics
  • Be the first to comment

MongoDB Replication Cluster

  1. 1. MongDB Replication Anuchit Chalothorn anuchit@redlinesoft.net
  2. 2. ● 1 Primary ● 2 or more Secondary Architecture
  3. 3. Replication Cluster Architecture
  4. 4. Election for new Primary
  5. 5. Setup All machine install MongoDB wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.6.1.tgz tar zxvf mongodb-linux-x86_64-2.6.1.tgz -C /opt/ export PATH=$PATH:/opt/mongodb-linux-x86_64-2.6.1/bin mkdir -p /data/rs0-0 /data/rs0-1 /data/rs0-2
  6. 6. Primary Start MongoDB service for primary mongod --dbpath /data/rs0-0 --replSet rs0 --smallfiles --oplogSize 128
  7. 7. Secondary 1 Start MongoDB service for primary mongod --dbpath /data/rs0-1 --replSet rs0 --smallfiles --oplogSize 128
  8. 8. Secondary 2 Start MongoDB service for primary mongod --dbpath /data/rs0-2 --replSet rs0 --smallfiles --oplogSize 128
  9. 9. Initial Replica Set Connect to Primary and initial replica set rs.initiate()
  10. 10. Add secondary Add your secondary servers to replica set rs.add("YOUR-SECONDARY-SERVER-1:27017") rs.add("YOUR-SECONDARY-SERVER-2:27017")
  11. 11. Check replica set config Use rs.conf() to check your replica set config rs.conf()
  12. 12. Check replica set status Use rs.status() to check your replica set status rs.status()
  13. 13. Test your cluster Load sample data to primary server and see how 2 secondary replicate data from primary, shutdown primary server and see how cluster election new primary from the exist secondary machine.

×