m ongodb replica,shard cluster

Download M ongoDB Replica,Shard Cluster

Post on 24-Feb-2016




0 download

Embed Size (px)


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 - PowerPoint PPT Presentation


mongoDB Replica Set

MongoDB Replica,Shard Cluster 2014-05-05OUTLINE1. MongoDB Replica2. Deploy a Replica Set3. Sharing Cluster4. Deploy a Sharded Cluster5. Conclusion

1. MongoDB ReplicaProvides redundancyprotects a database fromloss of a single serverIncreases data availabilityrecover fromhardware failureservice interruptions

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.confservice mongod restart primary host (

Priority cfg = rs.conf()cfg.members[0].priority = 2.0 cfg.members[1].priority = 0.5rs.reconfig(cfg) 2. Deploy a Replica Set (cont.)Slave Node MongoDBManager.java

2. Deploy a Replica Set (cont.) 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; }Slave Node mongo shelluse fdnsrs.slaveOk()show collectionsmongo shelldb.collectionName.remove() // FAILdb.collectionName.drop() 2. Deploy a Replica Set (cont.) 3. Sharing ClusterSingle machine challengesHigh query ratesexhaust CPU capacityLarger data setsexceed the storage capacityReferanceshttp://docs.mongodb.org/manual/core/sharding-introduction/http://docs.mongodb.org/manual/core/sharded-cluster-components/

3. Sharing Cluster(cont.)Sharded Cluster ComponentsShards holds a subset of a collections dataa single mongod instance, or a replica setConfig Serversa mongod instanceholds metadata about the clustermetadata maps chunks to shards3. Sharing Cluster (cont.)Routing Instances a mongos instanceroutes the reads and writes from applications to the shardsApplications do not access the shards directly

3. Sharing Cluster (cont.)Vertical scalingadds more CPU and storage resources to increase capacityhorizontal scaling (Sharding)divides the data setdistributes data over multiple servers(shards)Each shard is an independent databaseshards make up a single logical database

Range based partitioningMongoDB divides the data set into rangesdetermined by the shard key values to provide

Hash Based ShardingMongoDB computes a hash of a fields valueuses these hashes to create chunks.

4. Deploy a Shard Clusterhttp://docs.mongodb.org/manual/tutorial/deploy-shard-cluster/5. ConclusionReplica Set **Primary : serviceSecondary : Data MiningApache Mahout: cluster, classificationMining flooding, attacks trafficArbiter Sharing ClusterLoad balanceScalability

View more >