1 / 23

M ongoDB Replica,Shard Cluster

M ongoDB Replica,Shard Cluster. 中央大學電算中心 楊素秋 2014-05-05. OUTLINE. 1. MongoDB Replica 2. Deploy a Replica Set 3. Sharing Cluster 4 . Deploy a Sharded Cluster 5. C onclusion. 1. MongoDB Replica. P rovides redundancy protects a database from loss of a single server

nairi
Download Presentation

M ongoDB Replica,Shard Cluster

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. MongoDBReplica,ShardCluster 中央大學電算中心 楊素秋 2014-05-05

  2. OUTLINE • 1. MongoDBReplica • 2. Deploy a Replica Set • 3. Sharing Cluster • 4. Deploy a Sharded Cluster • 5. Conclusion

  3. 1. MongoDB Replica • Provides redundancy • protects a database from • loss of a single server • Increases data availability • recover from • hardware failure • service interruptions

  4. 2. Deploy a Replica Set • 安裝/啟動 mongoDB on each hosts • http://docs.mongodb.org/manual/tutorial/install-mongodb-on-red-hat-centos-or-fedora-linux/ • 設定 /etc/mongod.conf • service mongod restart • 在 primary host (140.115.2.32) • rs.initiate() • rs.add(“140.115.2.32:27017”) • rs.add(“140.115.2.31:27017”) • rs.addArb(“140.115.2.34:27017”)

  5. 2. Deploy a Replica Set(cont.) • Priority • cfg = rs.conf() • cfg.members[0].priority = 2.0 • cfg.members[1].priority = 0.5 • rs.reconfig(cfg)

  6. 2. Deploy a Replica Set(cont.) • Slave Node • MongoDBManager.java public static synchronized DB getDB() throws Exception { if(mongo == null) { mongo = new Mongo(); mongo.slaveOk(); } return mongo.getDB("fdns"); } public static synchronized Mongo getMongo() throws Exception { if(mongo == null) { mongo = new Mongo(); mongo.slaveOk(); } return mongo; }

  7. 2. Deploy a Replica Set(cont.) • Slave Node • mongo shell • use fdns • rs.slaveOk() • show collections • mongo shell • db.collectionName.remove() // FAIL • db.collectionName.drop()

  8. 3. Sharing Cluster • Single machine challenges • High query rates • exhaust CPU capacity • Larger data sets • exceed the storage capacity • Referances • http://docs.mongodb.org/manual/core/sharding-introduction/ • http://docs.mongodb.org/manual/core/sharded-cluster-components/

  9. 3. Sharing Cluster(cont.) • Sharded Cluster Components • Shards • holds a subset of a collection’s data • a single mongodinstance, or a replica set • Config Servers • a mongodinstance • holds metadata about the cluster • metadata maps chunks to shards

  10. 3. Sharing Cluster (cont.) • Routing Instances • a mongosinstance • routes the reads and writes from applications to the shards • Applications do not access the shards directly

  11. 3. Sharing Cluster (cont.) • Vertical scaling • adds more CPU and storage resources to increase capacity • horizontal scaling (Sharding) • divides the data set • distributes data over multiple servers(shards) • Each shard is an independent database • shards make up a single logical database

  12. Range based partitioning • MongoDB divides the data set into ranges • determined by the shard key values to provide

  13. Hash Based Sharding • MongoDB computes a hash of a field’s value • uses these hashes to create chunks.

  14. 4. Deploy a Shard Cluster • http://docs.mongodb.org/manual/tutorial/deploy-shard-cluster/

  15. 5. Conclusion • Replica Set ** • Primary : service • Secondary : Data Mining • Apache Mahout: cluster, classification • Mining flooding, attacks traffic • Arbiter • Sharing Cluster • Load balance • Scalability

More Related