mongodb - 数据不移动到新的分片服务器 mongodb
问题描述
我在我的 mongodb 集群中添加了一个分片服务器。添加新的分片服务器后,我在主节点上收到此错误。
DBException thrown :: caused by ::
CannotImplicitlyCreateCollection{ ns: "config.system.sessions" }:
request doesn't allow collection to be created implicitly
新的分片服务器是新的,之前没有任何数据。
我是如何添加分片服务器的?
我创建了一个文件 /etc/mongod.conf (就像我的其他分片服务器一样)
sharding:
clusterRole: shardsvr
replication:
replSetName: shardReplicaSet10
storage:
dbPath: /mnt/mongodb
systemLog:
traceAllExceptions: true
path: /mnt/log/mongodb/out.log
logAppend: true
logRotate: rename
destination: file
processManagement:
fork: true
net:
bindIp: localhost,172.6.7.5
然后我在这个replicaSet中有另一个成员具有相同的配置文件,只是bindIp被改变了。
我连接到我的 mongos 节点并添加了副本集
sh.addShard("shardReplicaSet10/172.6.7.5:27018,172.6.7.6:27018")
我可以确认我已经使用 rs.initiate() 启动了副本集
解决方案
事实证明,每当我们添加一个新的分片副本集时,我们都需要手动给它一个身份。我尝试了这个答案中给出的步骤
https://dba.stackexchange.com/a/227877
它奏效了。在分片副本集的主节点上,只需执行以下操作:
use admin
并添加身份
db.system.version.insert({
"_id" : "shardIdentity",
"clusterId" : ObjectId("5f098ac1077eb0e078fd5c1e"),
"shardName" : "NameOfYourShardReplicaSet",
"configsvrConnectionString" : "configReplicaSet/ipofconfigserver:27019,ipofotherconfigserver:27019"
})
您可以通过使用获取集群 ID
sh.status()
在任何 mongos 集群上。
推荐阅读
- oracle - 使用 count(*) 在 SQL 过程中获取多于一行
- mysql - mysql选择范围内的日期时间对象
- hyperledger-cello - 无法登录到 Hyperledger Cello 操作员仪表板
- vue.js - 在vue js中使用数组列表预先输入
- python - Python:从字典中创建收盘价的数据框
- javascript - 线性模式不适用于具有单独组件的 mat-horizontal-stepper
- r - 如何创建一个函数来重复连接另一列中每个字母或数字的一个字符串变量?
- docker - 如何在 Docker 中更改挂载目录的所有者
- git - 使用 rebase vs merge 与 master 同步功能
- dart - 在小部件树中使用 const 会提高性能吗?