mongodb - Mongodb sh.status() 显示不存在的数据库和分片
问题描述
我在以下配置中有一组 3.6 的集群:
- 1个蒙古人
- 1 个具有 3 个节点的配置集群
- 2 个具有 2 个节点的副本集
- 和 1 名仲裁员。
当我检查分片的存在时,从 mongos 告诉我分片存在,但我不能db.collection.findOne()
一位开发人员告诉我他sh.status()
在 replicaset1 上运行,它显示分片已设置并且数据库不存在。
sh.status() 结果:
' Currently enabled: yes
balancer:
Currently enabled: yes
Currently running: unknown
Failed balancer rounds in last 5 attempts: 0
Migration Results for the last 24 hours:
No recent migrations
databases:
{ "_id" : "config", "primary" : "config", "partitioned" : true }
config.system.sessions
shard key: { "_id" : 1 }
unique: false
balancing: true
chunks:
ReplSet1 3
ReplSet2 2
{ "_id" : { "$minKey" : 1 } } -->> {
"_id" : {
"id" : UUID("000067db-c834-477d-8700-920426e12345"),
"uid" : BinData(0,"47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=")
}
} on : ReplSet2 Timestamp(2, 0)
{
"_id" : {
"id" : UUID("000067db-c834-477d-8700-920426e12345"),
"uid" : BinData(0,"4DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=")
}
} -->> {
"_id" : {
"id" : UUID("56660623-f818-4679-8fc4-a526ad551234"),
"uid" : BinData(0,"47EQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=")
}
} on : ReplSet2 Timestamp(3, 0)
{
"_id" : {
"id" : UUID("56660623-f818-4679-8fc4-a526ad555678"),
"uid" : BinData(0,"47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=")
}
} -->> {
"_id" : {
"id" : UUID("acbc3edc-cd98-4225-bcae-8722fee12345"),
"uid" : BinData(0,"47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=")
}
} on : ReplSet1 Timestamp(3, 1)
{
"_id" : {
"id" : UUID("acbc3edc-cd98-4225-bcae-8722fee73f7b"),
"uid" : BinData(0,"47EQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=")
}
} -->> {
"_id" : {
"id" : UUID("bb92af6a-78a6-47ae-841b-fd2e15a0a86d"),
"uid" : BinData(0,"47DQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=")
}
} on : ReplSet1 Timestamp(2, 4)
{
"_id" : {
"id" : UUID("bb92af6a-78a6-47ae-841b-fd2e15a0ad"),
"uid" : BinData(0,"47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=")
}
} -->> { "_id" : { "$maxKey" : 1 } } on : ReplSet1 Timestamp(1, 3)
{ "_id" : "evt", "primary" : "ReplSet1", "partitioned" : true }
dbname.stuff_metadata
shard key: { "sec_id" : 1 }
unique: false
balancing: true
chunks:
ReplSet1 11
ReplSet2 11
too many chunks to print, use verbose if you want to force print
dbname.collectname
shard key: { "collec_id" : 1 }
unique: false
balancing: true
chunks:
ReplSet1 104
ReplSet2 101
too many chunks to print, use verbose if you want to force print
{ "_id" : "dbname_staging", "primary" : "ReplSet1", "partitioned" : false }
{ "_id" : "anotherdb", "primary" : "ReplSet1", "partitioned" : false }
{ "_id" : "staging_db", "primary" : "ReplSet1", "partitioned" : false }
{ "_id" : "test", "primary" : "ReplSet1", "partitioned" : false }
{ "_id" : "tester", "primary" : "ReplSet2", "partitioned" : true }
tester.shtest
shard key: { "boog" : 1 }
unique: false
balancing: true
chunks:
ReplSet2 1
{ "boog" : { "$minKey" : 1 } } -->> { "boog" : { "$maxKey" : 1 } } on : ReplSet2 Timestamp(1, 0)
'
我不知道这是何时或如何设置的——也不知道他为什么sh.status()
从复制品中跑出来。但我们在这里。
解决方案
我创建了一个没有数据的分支新分片集群并sh.status
在其上运行:
MongoDB Enterprise mongos> sh.status()
--- Sharding Status ---
sharding version: {
"_id" : 1,
"minCompatibleVersion" : 5,
"currentVersion" : 6,
"clusterId" : ObjectId("5e8e7025c985066cd8a6965c")
}
shards:
{ "_id" : "shard01", "host" : "shard01/localhost:14442,localhost:14443", "state" : 1 }
{ "_id" : "shard02", "host" : "shard02/localhost:14444,localhost:14445", "state" : 1 }
active mongoses:
"4.3.4" : 2
autosplit:
Currently enabled: yes
balancer:
Currently enabled: yes
Currently running: no
Failed balancer rounds in last 5 attempts: 0
Migration Results for the last 24 hours:
No recent migrations
databases:
{ "_id" : "config", "primary" : "config", "partitioned" : true }
指出了一个数据库,我假设它是配置数据库。
推荐阅读
- java - Java - 如何读取同一目录中的所有文件
- c++ - 用于计算的“|”或“&”与内部 IF 语句之间的区别
- sitefinity - sitefinity ControllerToolboxItem 与 MVC 控制器
- discord.py - Discord.py 错误处理不输出消息?
- c - 如何将纪元 unix 时间转换为 TOD 时钟(STCK)?
- sql - 从文本字段中提取数据
- ios - 当我单击 TabBar 项目时,整个 TabBar 消失....,Swift,Xcode
- javascript - 如何在 Discord.js 中设置 cron 作业
- javascript - useState() 钩子传递的函数可以在函数内多次重新渲染它们的组件吗?
- javascript - Firebase.auth().useEmulator 不是函数