MongoDB---一些常见错误总结

来源:互联网 发布:java 调用maven 编辑:程序博客网 时间:2024/06/05 12:14
1.在 王文龙 所写的 《MongoDB 实战》 中,写到:
 
创建主从key 文件,用于标识集群的私钥的完整路径,如果各个实例的key file 内容不一 致,程序将不能正常用。
 
我误以为 –keyFile 是各个节点之间的认证方式。其实不是的。各个节点之间的确认关系参数是 –replSet。只要此参数后面的内容一致。Replica Set 就可以创建成功。
 
在官方文档中提到:
 
You do not need to use the –auth option, too (although there’s no harm in doing so), –keyFile implies –auth. –auth does not imply –keyFile.
 
也就是说keyFile 其实包含了auth 的作用。
 
而当你加了 –keyFile 参数后,如果你要添加Shard,则会收到报错:
 
need to login
 

这和加了auth 的报错一致。


2.route 启动的时候,连接config 不可以以localhost 为地址链接。不然会遇到以下错误:
 
“errmsg”: “can’t use localhost as a shard since all shards need to communicate. either use all shards and configdbs in localhost or all in actual IPs host: 172.16.5.104:20000 isLocalHost:0″
 
3.如果不以localhost 为地址链接,那么config 启动的时候不能加 –auth 选项,不然会在log文件中遇到以下错误:
 
ERROR: config servers not in sync! not authorized, did you start with –keyFile?
 
此时进程无法启动
 
4.在route 和config 准备完毕后,通过route 以远程IP 为地址添加shard,则报错:(有 –auth 参数)
 
db.runCommand({addshard:’a1:28010′})
{
“ok” : 0,
“errmsg”: “failed listing a1:28010′s databases:{ errmsg: \”need to login\”, ok: 0.0 }”
}
 
 
5. 依旧保留 –auth 参数,添加用户后,再添加shard。报错:
 
“errmsg” : “couldn’t connect to new shard DBClientBase::findN: transport error: a1:28010 query: { getlasterror: 1 }”

0 0
原创粉丝点击