I have some problems with creating mongoDB shard cluster. I try to use 4 servers: 3 for mongo databases (host1, host2 and host3) and one for application side (for mongos process). On each database server I start 4 processes:
$ mongod --configsvr --smallfiles --noprealloc --port 27020 --dbpath /mongodb/conf --logappend --logpath=/mongodb/logs/logsmongodcfg.log $ mongod --shardsvr --smallfiles --noprealloc --replSet repl1 --port 27030 --dbpath /mongodb/repl1 --logappend --logpath=/mongodb/logs/mongod_shard1.log $ mongod --shardsvr --smallfiles --noprealloc --replSet repl2 --port 27031 --dbpath /mongodb/repl2 --logappend --logpath=/mongodb/logs/mongod_shard2.log $ mongod --shardsvr --smallfiles --noprealloc --replSet repl3 --port 27032 --dbpath /mongodb/repl3 --logappend --logpath=/mongodb/logs/mongod_shard3.log
As you can see on each server in cluster we have one config server and 3 mongod servers for replication implementation. On application server I start only one mongos process:
mongos --configdb host1:27020,host2:27020,host3:27020 --port 27017 --logappend --logpath=/var/log/mongo/mongos.log
After this I try to configure sharding:
mongo 127.0.0.1:27017/admin
db.runCommand( { addShard : "repl1/host1:27030,host2:27030,host3:27030" } ); db.runCommand( { addShard : "repl2/host1:27031,host2:27031,host3:27031" } ); db.runCommand( { addShard : "repl3/host1:27032,host2:27032,host3:27032" } );
And this scheme is working, but there is one big problem. If i try to shutdown one of the hosts, mongos can't connect to the other hosts and to the new primary replications. In mongos logs I get such information:
Thu Jun 14 21:10:37 [CheckConfigServers] DBClientCursor::init call() failed Thu Jun 14 21:10:37 [ReplicaSetMonitorWatcher] trying reconnect to host1:27030 Thu Jun 14 21:10:42 [ReplicaSetMonitorWatcher] reconnect host1:27030 failed couldn't connect to server host1:27030 Thu Jun 14 21:10:42 [ReplicaSetMonitorWatcher] trying reconnect to host1:27032 Thu Jun 14 21:10:47 [ReplicaSetMonitorWatcher] reconnect host1:27032 failed couldn't connect to server host1:27032 Thu Jun 14 21:10:56 [LockPinger] SyncClusterConnection connecting to [host1:27020]
So if any of 3 config servers goes down mongos got connection exception. What's wrong and how to resolve this problem?