我在我的AWS EC2实例中有一个独立的MongoDB实例。我打算把它换成Mongo Atlas。前提条件是将MongoDB实例转换为副本集。
下面是我的mongo.conf文件的代码:
# mongodb.conf
# Where to store the data.
dbpath=/opt/bitnami/mongodb/data/db
#where to log
logpath=/opt/bitnami/mongodb/log/mongodb.log
logappend=true
bind_ip = 127.0.0.1
port = 27017
# Enable journaling, http://www.mongodb.org/display/DOCS/Journaling
journal=true
# Enable smaller default file size for MongoDB
# Also reduces size of journal files from 1G to 128M
#smallfiles=true
# Enables periodic logging of CPU utilization and I/O wait
#cpu = true
# Turn on/off security. Off is currently the default
#noauth = true
auth = true
# Verbose logging output.
#verbose = true
# Inspect all client data for validity on receipt (useful for
# developing drivers)
#objcheck = true
# Enable db quota management
#quota = true
# Set oplogging level where n is
# 0=off (default)
# 1=W
# 2=R
# 3=both
# 7=W+some reads
#oplog = 0
# Diagnostic/debugging option
#nocursors = true
# Ignore query hints
#nohints = true
setParameter = enableLocalhostAuthBypass=0
unixSocketPrefix=/opt/bitnami/mongodb/tmp
fork = true
setParameter = enableLocalhostAuthBypass=0
# Replication Options
replication:
replSetName: res0
# in replicated mongo databases, specify here whether this is a slave or master
#slave = true
#source = master.example.com
# Slave only: specify a single database to replicate
#only = master.example.com
# or
#master = true
#source = slave.example.com我使用下面的命令来创建副本集:
sudo mongod --port 27017 --dbpath /opt/bitnami/mongodb --replSet res0 --bind_ip localhost我得到以下错误:
NoMatchingDocument: Did not find replica set configuration document in local.system.replset我还应该在mongo.conf文件中更改哪些内容?
发布于 2020-07-01 16:59:18
我也有同样的问题,但我解决了以下步骤:
我在Windows服务器上。Mongo DB shell版本3.0.4。下面的屏幕截图中的错误与您提到的相同

所以我将Mongo shell交换机连接到本地。
使用以下命令。请注意,SIR是我的副本集名称
cfg = { _id:"SIR" , members:
[{ _id:0,host:"localhost:27017"}]
};
rs.initiate(cfg)结果

发布于 2021-03-23 23:12:53
我正在使用bitnami/mongodb helm chart将mongodb部署到我们的自定义k8s集群,因为在默认情况下它是cluster.local,并且导致在主机地址中使用错误的集群域运行mongodb,所以忘记覆盖values.yaml文件中的clusterDomain变量时会出现这个错误:
mongodb 14:59:37.35 WARN ==> Problem initiating replica set
request: rs.initiate({"_id":"rs0", "members":[{"_id":0,"host":"temp-mongo-0.temp-mongo-headless.default.svc.**cluster.local**:27017","priority":5}]})
response: MongoDB shell version v4.4.4
connecting to: mongodb://127.0.0.1:27017/admin?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("dc48d2bc-269b-4710-95b8-525b7768fa72") }
MongoDB server version: 4.4.4
{
"ok" : 0,
"errmsg" : "No host described in new configuration with {version: 1, term: 0} for replica set rs0 maps to this node",
"code" : 93,
"codeName" : "InvalidReplicaSetConfig"
}
byehttps://stackoverflow.com/questions/58338218
复制相似问题