I have two servers in a replica set. rep2-1 and rep2-2. I want to rebuild the secondary off of the primary (to compact the data files due to a high degree of fragmentation). In the past, to do this I simply shut down the secondary, blow away the data directory, and start it back up and wait for it to sync with the primary.
But when I tried to do that this morning, I'm getting a weird error. I double checked, and rep2-1 is primary and rep2-2 is secondary.
(on rep2-1)
> db.isMaster()
{
"setName" : "set2",
"ismaster" : true,
"secondary" : false,
"hosts" : [
"rep2-1:27018",
"rep2-2:27018"
],
"ok" : 1
}
(on rep2-2)
> db.isMaster()
{
"setName" : "set2",
"ismaster" : false,
"secondary" : true,
"hosts" : [
"rep2-2:27018",
"rep2-1:27018"
],
"primary" : "rep2-1:27018",
"ok" : 1
}
When I shut down rep2-2, any operations I try to make through mongos are giving me this error:
> db.my_collection.count()
Fri Nov 5 12:38:38 uncaught exception: count failed: { "errmsg" : "not master", "ok" : 0 }
> db.my_collection.find()
error: { "$err" : "not master", "code" : 10107 }
I connected to rep2-1 and ran db.isMaster(), and now it says it's not master:
> use my_db
switched to db my_db
> db.isMaster()
{
"setName" : "set2",
"ismaster" : false,
"secondary" : false,
"hosts" : [
"cuegg-data-rep2-1:27018",
"rep2-2:27018"
],
"ok" : 1
}
When I bring rep2-2 back up, everything is fine again.
Any suggestions?
Luke
--
Luke Ehresman
lu...@ehresman.org
Tebros Systems,
LLC - http://tebros.com