Reputation: 3079
I use mongodb --keyfile parameter to config a authenticated mongodb cluster.Yes, I at first add an admin user to admin db without the authentication ,and then ,I restart the mongodb with --keyFile.Yes, after that , the authentication takes effect.But when I tried to addUser() or show dbs or show collections or db.collection.find(), it reports error: mongos> db.system.users.find()
error: {
"$err" : "socket exception [CONNECT_ERROR] for shard4/192.168.10.10:10004,192.168.10.12:10004",
"code" : 11002,
"shard" : "config"
}
sometimes, it is shared1,sometimes it is shard2 or shard3...
I checked every shard heath(I have 3 shards ,each shard have 3 replication set), all shard member's health status is 1,namely ok.
So ,any one can help me?
Upvotes: 1
Views: 722
Reputation: 3079
I checked the log on /var/data/master/log.log, it said: the permission of keyfile is too open.That means,I shouldn't have given such a file too high permission.So ,I run command below for every mongodb cluster member:
sudo chmod 700 /var/data/keyfile
And I checked the log again , the permission problem solved,but the socked exception error remains.
But I can ping to these config server net port successfully,it proves that actually these config server is working properly.
So ,why these config server cannot be connected ? Finally I get the reason: it is because I firstly start the mongos process and then the 3 config servers' mongod instance .When mongos is started , it is trying to connect to the config server ,but the config server is started afterwards,so ,it cannot reach them.Only when I started these 3 config server at first and then started the mongos instance ,problem solved!
Upvotes: 1