Using MongoDB | Sharding | Adding One More Shard | Part 3
Posted By : Amit Kumar | 25-Feb-2014
Setup Sharding in MongoDB in Ubuntu With Two Shard(3 Mongo Instance as Replica Set),One Router and Three Config Server
Continue from the previous blog “Sharding Part 2” (http://www.oodlestechnologies.com/blogs/Using-MongoDB-%7C-Sharding-%7C-Adding-Two-More-Config-Servers-%7C-Part-2) , now in this blog we will add one more shard servers in sharded cluster.
Initials :
1.)First You must go through the previous blog of this series (http://www.oodlestechnologies.com/blogs/Using-MongoDB-%7C-Sharding-%7C-Adding-Two-More-Config-Servers-%7C-Part-2)
2.) In my previous blog i have used only one shard server, Now i am using total two shard each containing 3 mongod instance (mongo-1,mongo-2,mongo-3,mongo-4,mongo-5,mongo-6)
3.) Make sure you can access each mongo console server from other mongo servers
Configuration for New Shard (mongo-4,mongo-5,mongo-6)
In this section i will discuss configuration for one more shard i.e. total of two shard in sharded cluster. Basically in previous blog of this series i have added one shard in cluster.I assumed that we have rs2(shard_name) as second shard with 3 mongod instance running and mongo-4 is the primary node of this shard.
Step 1:
Goto mongos console i.e execute below commands/query in router-1 server.
Code Snippet :-
mongo sh.addShard("rs2/ip-address-of-mongo-4-machine:27017");
Step 2:
Clear configuration cache history. Use below commands.
Code Snippet :-
use admin; db.adminCommand("flushRouterConfig");
Step 3:
Now shutdown all mongod, mongos process.
Step 4:
And restart both shard(each mongod instance) ,config servers(each mongod instance),and query router(mongos instance) with correct configuration. [Note : exactly same what we did in previous blog]
For more information you can see this MongoDB tutorial for Sharding.
http://docs.mongodb.org/manual/core/sharding/Thanks
Amit
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
Amit Kumar
Amit is a bright Groovy and Grails developer and has worked on development of various SaaS applications using Grails framework.