首页 > 解决方案 > MongoDB分片

问题描述

我是 mongodb 的新手。我想创建一个具有单个副本集的 Shard Cluster,将来,如果我想扩展它会很容易。

现在,有 4 台 Ubuntu 机器,其中 1 台用作路由器(mongos),其余 3 台用作副本集(主要、次要、次要)。

# mongod.conf

# for documentation of all options, see:
#   http://docs.mongodb.org/manual/reference/configuration-options/

# Where and how to store data.
storage:
  dbPath: /mnt/md0/data/mongodb/dbdata/
  journal:
    enabled: true
#  engine:

#  wiredTiger:

# where to write logging data.
systemLog:
  destination: file
  logAppend: true
  path: /mnt/md0/data/mongodb/logs/mongod.log

# network interfaces
net:
  port: 27017
  bindIp: 127.0.0.1

#processManagement:

security:
  keyFile: /opt/mongo/mongo-keyfile

#operationProfiling:

replication:
  replSetName: rs0

sharding:
  clusterRole: configsvr

## Enterprise-Only Options:

#auditLog:

#snmp:**strong text**


#mongos.conf

 # where to write logging data.

systemLog:
  destination: file
  logAppend: true
  path: /var/log/mongodb/mongos.log

# network interfaces
net:
  port: 27017
  #bindIp: 127.0.0.1,192.10.10.10

security:
  keyFile: /opt/mongo/mongo-keyfile

sharding:
  configDB: rs0/Primary_Rs:27017,Secondary1_Rs:27017,Secondary2_Rs:27017

当我尝试在 mongos 控制台中添加 Shard 时,出现错误

请帮我解决这个问题。先感谢您

标签: mongodbubuntu-16.04

解决方案


看到你的 conf 文件中有 2 个分片部分......第一个将 clusterRole 配置为 configsvr => 删除/评论这个,然后重试


推荐阅读