I have 2 replica sets that have some sharded databases and I am attempting to migrate to a standard 3 box replica set without sharding.
MongoDB 2.6.9
Here is sh.status()
--- Sharding Status ---
sharding version: {
"_id" : 1,
"version" : 4,
"minCompatibleVersion" : 4,
"currentVersion" : 5,
"clusterId" : ObjectId("520d987c7a2704256a159b7e")
}
shards:
{ "_id" : "data1", "host" : "data1/1.1.1.1:27017,1.1.1.2:27017,1.1.1.3:27017" }
{ "_id" : "data2", "host" : "data2/1.1.1.4:27017,1.1.1.5:27017,1.1.1.6:27017" }
databases:
{ "_id" : "admin", "partitioned" : false, "primary" : "config" }
{ "_id" : "staging", "partitioned" : true, "primary" : "data2" }
staging.content.chunks
shard key: { "files_id" : 1 }
chunks:
data1 1
data2 1
{ "files_id" : { "$minKey" : 1 } } -->> { "files_id" : ObjectId("XXXXXXXXXXXXXXX") } on : data1 Timestamp(2, 0)
{ "files_id" : ObjectId("XXXXXXXXXXXXXXXXXX") } -->> { "files_id" : { "$maxKey" : 1 } } on : data2 Timestamp(2, 1)
{ "_id" : "production", "partitioned" : true, "primary" : "data2" }
production.content.chunks
shard key: { "files_id" : 1 }
chunks:
data2 3856
data1 21109
too many chunks to print, use verbose if you want to force print
{ "_id" : "test", "partitioned" : false, "primary" : "data2" }
{ "_id" : "local", "partitioned" : false, "primary" : "data1" }
{ "_id" : "alpha-staging", "partitioned" : false, "primary" : "data2" }
{ "_id" : "beta-staging", "partitioned" : false, "primary" : "data2" }
{ "_id" : "alpha-production", "partitioned" : false, "primary" : "data1" }
{ "_id" : "beta-production", "partitioned" : false, "primary" : "data1" }The first task would be to migrate the data to one partition using movePrimary so for example I would run db.runCommand( { movePrimary:"beta-production", to:"data2"})
My question is this: Would I be able to continue to write to the 'bat-production' database while it is being moved? If not, what other solutions are there for a 'live' migration?
For the sharded dbs(staging,production) do I run movePrimary and then removeShard "data1"?
-dave