简体   繁体   English

mongodb集群:使用keyFile进行身份验证后,它报告碎片的套接字异常

[英]mongodb cluster:after use keyFile for authentication ,it report socket exception for shard

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() 我使用mongodb --keyfile参数配置经过身份验证的mongodb集群。是的,我首先在不进行身份验证的情况下将admin用户添加到admin db中,然后使用--keyFile重新启动mongodb。是的,之后,身份验证需要但是当我尝试addUser()或show dbs或show collections或db.collection.find()时,它报告错误: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... 有时是共享的,有时是shard2或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. 我检查了每个分片健康(我有3个分片,每个分片都有3个复制集),所有分片成员的健康状况均为1,即可以。

So ,any one can help me? 那么,有人可以帮助我吗?

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: 我检查了/var/data/master/log.log上的日志,它说:keyfile的权限太开放了。这意味着,我不应该授予此类文件太高的权限。因此,我在下面运行命令每个mongodb集群成员:

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. 但是我可以成功ping通这些配置服务器的网络端口,它证明这些配置服务器实际上在正常工作。

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! 最终我得到了原因:这是因为我先启动mongos进程,然后再启动3个配置服务器的mongod实例。当mongos启动时,它试图连接到配置服务器,但是随后启动了配置服务器,所以,它无法到达它们。只有当我首先启动这3个配置服务器,然后再启动mongos实例时,问题才解决!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM