mongodb - mongos 从不同应用程序查询时返回空集合
问题描述
我们使用带有 2 个分片的分片 MongoDB 配置。有几个前端应用程序,它们通过mongos服务(安装在每个应用程序服务器上)检索数据。
问题是在某些时候从应用程序服务器#1 运行相同的查询将返回空集合,而从应用程序服务器#3 运行相同的查询将返回正确的结果。
在运行刷新命令之前,应用程序服务器 #1 上的问题仍然存在。正如文件所述:
“您应该只需要在 movePrimary 运行后或手动清除巨型块标志后运行 flushRouterConfig。”
但是,Primary 既没有移动,也没有清除标志。
任何想法为什么会发生这种情况?
配置文件
# mongos.conf
# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/
# where to write logging data.
systemLog:
destination: file
logAppend: false
logRotate: rename
path: /var/log/mongos.log
# how the process runs
processManagement:
fork: true # fork and run in background
pidFilePath: /var/run/mongos.pid # location of pidfile
# network interfaces
net:
port: 27017
bindIp: 127.0.0.1,94.130.167.133,192.168.0.1 # Listen to local interface only, comment to listen on all interfaces.
security:
keyFile: /var/lib/database/mongos/.keyfile
sharding:
configDB: myproject-config/192.168.0.15:27027,192.168.0.16:27017,192.168.0.17:27017
printShardingStatus()
MongoDB shell version: 3.2.8
connecting to: cron0.myproject.smapps.org:27017/test
config.locks collection empty or missing. be sure you are connected to a mongos
--- Sharding Status ---
sharding version: {
"_id" : 1,
"minCompatibleVersion" : 5,
"currentVersion" : 6,
"clusterId" : ObjectId("2c5bc3fd9b2385s9613b0la5")
}
shards:
{ "_id" : "myproject0", "host" : "myproject0/192.168.0.11:27017,192.168.0.12:27017", "state" : 1, "tags" : [ ] }
{ "_id" : "myproject1", "host" : "myproject1/192.168.0.13:27017,192.168.0.18:27017", "state" : 1, "tags" : [ "game" ] }
{ "_id" : "myproject2", "host" : "myproject2/192.168.0.26:27017,192.168.0.28:27017", "state" : 1, "tags" : [ "game" ] }
active mongoses:
"4.0.6" : 14
balancer:
Currently enabled: yes
Currently running: no
Failed balancer rounds in last 5 attempts: 0
Migration Results for the last 24 hours:
8 : Success
databases:
{ "_id" : "myproject", "primary" : "myproject0", "partitioned" : true, "version" : { "uuid" : BinData(4,"+YxjwrKzTuekDlKutwT1IA=="), "lastMod" : 1 } }
...
解决方案
推荐阅读
- r - 按组使用 cov.wt 和 data.table 的加权相关性
- angular - 您可以将 GET 方法中的数据分配给 Angular 8 中的外部变量吗?
- javascript - 执行 jquery ajax 代码而不打开执行它的网页
- python - 从句子中提取相关日期和位置
- facebook-graph-api - 如何从 App Scoped Facebook ID 中查找 App ID
- python - 使用 for 循环更新 Python 类中的列表
- postgresql - 如何在 PostgresSQL 中的文本数组中查找重叠
- php - PHP 上使用 FPDF 的多个访问控制允许来源
- google-apps-script - 两个表单报告到同一电子表格中的不同选项卡。提交任一表单时,我正在运行的脚本触发器。我如何限制一个?
- python-3.x - ANTLR 获取所有函数参数