This command allows changing the primary shard for sharded database. The primary will hold all unsharded collections in that database.
mongos only This command is only available on a sharded system through "mongos".
Drain Shard First
When using this with existing data with sharded collections you must be very careful. You must drain the shard which is the primary shard before running this command because it will move all collections in the database.
This command is meant to be run on an offline system and only in the case where you need to remove a shard.
> db.adminCommand({movePrimary:<dbname>, to:<shard-name>})
//enable sharding on the database, and move it to the shard01
> use test1 //new database
> db.adminCommand({enablesharding : "test1"})
> db.adminCommand({movePrimary : "test1", to : "shard01" })
//This will affect new collections on the test1 db
PLEASE POST QUESTIONS IN THE USER GROUPS FORUM. Post non-question comments and helpful hints here.
blog comments powered by Disqus