Trying to create set but getting error

I am using mongodb 7.0.4 in parrotos.

I am using this code to create replica set

    _id: "rs1",
    members: [
        {_id: 0, host: "localhost:27018"},
        {_id: 1, host: "localhost:27019"},
        {_id: 2, host: "localhost:27020"}

but it is giving me error

MongoServerError: This node was not started with replication enabled.
    at Connection.onMessage (/usr/lib/mongodb-compass/resources/app.asar.unpacked/node_modules/@mongosh/node-runtime-worker-thread/dist/worker-runtime.js:2:840034)
    at MessageStream.<anonymous> (/usr/lib/mongodb-compass/resources/app.asar.unpacked/node_modules/@mongosh/node-runtime-worker-thread/dist/worker-runtime.js:2:837920)
    at MessageStream.emit (node:events:513:28)
    at p (/usr/lib/mongodb-compass/resources/app.asar.unpacked/node_modules/@mongosh/node-runtime-worker-thread/dist/worker-runtime.js:2:863891)
    at MessageStream._write (/usr/lib/mongodb-compass/resources/app.asar.unpacked/node_modules/@mongosh/node-runtime-worker-thread/dist/worker-runtime.js:2:862512)
    at writeOrBuffer (node:internal/streams/writable:392:12)
    at _write (node:internal/streams/writable:333:10)
    at Writable.write (node:internal/streams/writable:337:10)
    at Socket.ondata (node:internal/streams/readable:766:22)
    at Socket.emit (node:events:513:28)

what should I do?

Check replication parameter in your config files (all 3 nodes)

1 Like

opened this file /etc/mongod.conf

# mongod.conf

# for documentation of all options, see:

# Where and how to store data.
  dbPath: /var/lib/mongodb
#  engine:
#  wiredTiger:

# where to write logging data.
  destination: file
  logAppend: true
  path: /var/log/mongodb/mongod.log

# network interfaces
  port: 27017

# how the process runs
  timeZoneInfo: /usr/share/zoneinfo





nothing extra about all 3 nodes

Hi @Golu_Rajak

the problem is here:

from the documentation:

so you need to edit the configuration files of the various instances correctly.