MongoDB Replication Cluster

998 views
901 views

Published on

MongoDB Replication Cluster

Published in: Technology, News & Politics
0 Comments
8 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
998
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
59
Comments
0
Likes
8
Embeds 0
No embeds

No notes for slide

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.

×