This is a super basic question that has been driving me up a wall. I
have been setting up a sharded and replicated environment using the
instructions at
http://www.mongodb.org/display/DOCS/Simple+Initial+Sharding+Architecture.
I did this once before and it worked fine. I started a new deployment
and am now running into the following error whenever I try to add the
shard:
mongos> db.adminCommand( { addShard : "shard1/
server1:27018,server2:27018,server3:27018" })
{
"ok" : 0,
"errmsg" : "couldn't connect to new shard mongos connectionpool:
connect failed shard1/server1:27018,server2:27018,server3:27018 :
connect failed to set shard1/
server1:27018,server2:27018,server3:27018"
}
My setup:
- 3 large EC2 machines (server1, server2, server3)
- mongod running as --shardsvr in --replSet "shard1" on port 27018
on each
- config server running on port 27019 on each
ps aux | grep mongo: (same for each of the 3 servers)
root 2503 0.0 0.0 23184 1336 ? Ss 15:04 0:00
sudo /usr/bin/mongod --shardsvr --dbpath /mnt/data/mongo/db --logpath
/mnt/data/mongo/mongodb.log --logappend --journal --rest --
replSet shard1
root 2522 0.0 0.0 23184 1328 ? Ss 15:04 0:00
sudo /usr/bin/mongod --configsvr --journal --dbpath /mnt/data/mongo/
configdb --logpath
/mnt/data/mongo/mongodb.log --logappend
- 1 small EC2 machine as appserver running mongos
ps aux | grep mongo:
root 2711 0.0 0.0 2400 1200 ? Ss 15:13 0:00
sudo /usr/bin/mongos --configdb
server1:27019,server2:27019,server3:27019
I've initialized the replica set across the machines:
PRIMARY> rs.conf()
{
"_id" : "shard1",
"version" : 1,
"members" : [
{
"_id" : 0,
"host" : "server1:27018",
"priority" : 2
},
{
"_id" : 1,
"host" : "server2:27018"
},
{
"_id" : 2,
"host" : "server3:27018",
"priority" : 0,
"hidden" : true
}
]
}
PRIMARY> rs.status()
{
"set" : "shard1",
"date" : ISODate("2011-10-11T15:31:39Z"),
"myState" : 1,
"members" : [
{
"_id" : 0,
"name" : "server1:27018",
"health" : 1,
"state" : 1,
"stateStr" : "PRIMARY",
"optime" : {
"t" : 1318345607000,
"i" : 1
},
"optimeDate" : ISODate("2011-10-11T15:06:47Z"),
"self" : true
},
{
"_id" : 1,
"name" : "server2:27018",
"health" : 1,
"state" : 2,
"stateStr" : "SECONDARY",
"uptime" : 1481,
"optime" : {
"t" : 1318345607000,
"i" : 1
},
"optimeDate" : ISODate("2011-10-11T15:06:47Z"),
"lastHeartbeat" : ISODate("2011-10-11T15:31:37Z"),
"pingMs" : 0
},
{
"_id" : 2,
"name" : "server3:27018",
"health" : 1,
"state" : 2,
"stateStr" : "SECONDARY",
"uptime" : 1485,
"optime" : {
"t" : 1318345607000,
"i" : 1
},
"optimeDate" : ISODate("2011-10-11T15:06:47Z"),
"lastHeartbeat" : ISODate("2011-10-11T15:31:38Z"),
"pingMs" : 0
}
],
"ok" : 1
}
And ports 27017-27019 are open on the machines. On the appserver
(where mongos is running) I can do the following:
jake@appserver:~$ mongo server1:27018
MongoDB shell version: 2.0.0
connecting to: server1:27018/test
PRIMARY> exit
bye
jake@appserver:~$ mongo server1:27019
MongoDB shell version: 2.0.0
connecting to: server1:27019/test
> exit
bye
So I know I can connect to the machines, so why the heck can't I add
this shard??
I'm sure this is a super basic mistake somewhere but any help is
hugely appreciated,
J