如何在mongodb集群中添加碎片?
我在debian机器上设置了mongodb 3.2集群,配置如下如何在mongodb集群中添加碎片?,mongodb,cluster-computing,Mongodb,Cluster Computing,我在debian机器上设置了mongodb 3.2集群,配置如下 # Config Server - mongod.conf storage: dbPath: /data/mongodb journal: enabled: true systemLog: destination: file logAppend: true path: /var/log/mongodb/mongod.log net: port: 27019 bindIp: 0.0.0.0
# Config Server - mongod.conf
storage:
dbPath: /data/mongodb
journal:
enabled: true
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
net:
port: 27019
bindIp: 0.0.0.0
replication:
replSetName: rs0
sharding:
clusterRole: "configsvr"
# Shard Server 1 - mongod.conf
storage:
dbPath: /data/mongodb
journal:
enabled: true
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
net:
port: 27017
bindIp: 0.0.0.0
replication:
replSetName: rs0
# Shard Server 2 - mongod.conf
storage:
dbPath: /data/mongodb
journal:
enabled: true
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
net:
port: 27017
bindIp: 0.0.0.0
replication:
replSetName: rs0
并运行mongos在查询路由器服务器上添加碎片
$)mongos--configdb mongo配置:27019
但我不能添加碎片
mongos> sh.addShard("rs0/mongo-db1:27017")
{
"ok" : 0,
"errmsg" : "Cannot add rs0/mongo-db1:27017 as a shard since it is part of a config server replica set",
"code" : 96
}
mongos> sh.addShard("rs0/mongo-db1:27017")
{
"ok" : 0,
"errmsg" : "Surprised to discover that mongo-db1:27017 does not believe it is a config server",
"code" : 72
}
getSharmap命令
mongos> db.runCommand("getShardMap");
{
"map" : {
"config" : "rs0/mongo-db1:27017,mongo-db2:27017",
"mongo-db1:27017" : "rs0/mongo-db1:27017,mongo-db2:27017",
"mongo-db2:27017" : "rs0/mongo-db1:27017,mongo-db2:27017",
"rs0/mongo-config:27019" : "rs0/mongo-config:27019",
"rs0/mongo-db1:27017,mongo-db2:27017" : "rs0/mongo-db1:27017,mongo-db2:27017"
},
"ok" : 1
}
这是mongos日志
2016-04-06T15:05:14.243+0000 I切分[Balancer]即将将元数据事件记录到操作日志:{u id:“mongo-router1-2016-04-06T15:05:14.243+0000-570525aa6b2b3378bb9daf56”,服务器:“mongo-router1”,客户端地址:,时间:新日期(1459955114243),内容:“Balancer.round”,ns:,详细信息:{executionTimeMillis:3,ErrorOccurd:true,errmsg:“无法从配置服务器获取更新的碎片列表,因为惊奇地发现mongo-db1:27017不相信它是配置服务器”}
我缺少什么。?由于您尝试添加的碎片位于rs0副本集中,并且rs0持有您的配置服务器,因此它将不允许您创建碎片。请尝试将其添加到其他副本集中,如rs1,这样应该可以工作