码迷,mamicode.com
首页 > 其他好文 > 详细

Deploy a Sharded Cluster

时间:2015-02-12 12:08:46      阅读:119      评论:0      收藏:0      [点我收藏+]

标签:

  • Start the Config Server Database Instances
for example : 
mongod --configsvr --dbpath <path> --port <port>
mongod --configsvr --dbpath /data/configdb --port 27019
 
In production deployments, you must deploy exactly three config server instances, each running on different servers
to assure good uptime and data safety. In test environments, you can run all three instances on a single server.
 
  • Start the mongos Instances
for example : 
mongos --configdb <config server hostnames>
mongos --configdb cfg0.example.net:27019,cfg1.example.net:27019,cfg2.example.net:27019
 
  • deploy replica sets for each shard
A shard can be a standalone mongod or a replica set. In a production environment, each shard should be a replica set.
for example : 
cfg = ...
rs.initiate(cfg)
rs.conf()
rs.status()
rs.add("<hostname><:port>")

  • Add Shards to the Cluster
for example : 
sh.addShard("rs1/mongodb0.example.net:27017")
 
  • Enable Sharding for a Database
for example : 
sh.enableSharding("<database>")
 
  • Enable Sharding for a Collection
for example : 
sh.shardCollection("<database>.<collection>", shard-key-pattern)
sh.shardCollection("events.alerts", { "_id": "hashed" } )
 
 

Deploy a Sharded Cluster

标签:

原文地址:http://www.cnblogs.com/li603572310/p/4287682.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!