error in using rs.initiate() in mongo
Asked Answered
R

5

13

I want to turn on the replication in monga. So when I tried to use rs.initiate I get the following errorrs.initiate()

{
    "ok" : 0,
    "errmsg" : "This node was not started with the replSet option",
    "code" : 76,
    "codeName" : "NoReplicationEnabled"
}

I am new to this so I don't know how to correct it. I am following these guidelines https://blog.jixee.me/how-to-use-mongo-connector-with-elasticsearch/

Regardless answered 23/12, 2016 at 5:40 Comment(3)
this might help: #40712329Yeung
I tried it but this error was coming, bash: init_replica.js: No such file or directoryRegardless
Check if you're running another mongod ? if yes kill it first. Then possibly it should work.Towrope
R
9

If you are running on windows, it might have been running as a service and probably you are still connected with your old server.

use the below command to shutdown any running instance and then start all the instances again:

db.adminCommand( { shutdown : 1} )
Ruthi answered 24/10, 2018 at 14:16 Comment(0)
R
3

Refer official doc deploy-replica-set to setup mongo replica set.

specifies the replica set name through the --replSet command-line option:

mongod --replSet "rs0"

You can also specify the replica set name in a configuration file.

Recrystallize answered 23/12, 2016 at 5:47 Comment(1)
I tried this option but still its not working. But the error is still coming.Regardless
K
1

You can add replSet to MongoDb config file in: /etc/mongodb.conf

replSet = test

If not work in latest mongodb add this:

replSetName = test
Kelm answered 14/8, 2018 at 12:40 Comment(0)
L
1

You have to edit mongod.conf first. In windows, you could find it in program files. In MacOSX, Probably you have installed MongoDB via homebrew.

So do the following steps on your terminal,

nano /opt/homebrew/etc/mongod.conf

Add the following code at the end of the document

replication:
  replSetName: rs0
  oplogSizeMB: 100

Finally save it

Now You have to restart MongoDB

Now run the code on mongo

rs.initiate()

Leo answered 9/6, 2021 at 9:43 Comment(0)
R
0

This problem was solved when I installed another doc manager. The command for the same is

sudo pip install 'mongo-connector[elastic2]'

I don't know exactly how it happened but when I tried to connect to Elastic search using mongo-connector I faced the following problem: No handlers were found for logger "mongo-connector.util" Then I installed another doc manager for mongodb and along with mongo-connector problem this problem was also solved. I think there was some clash between the elastic search doc manager and mongo doc manager.

Regardless answered 29/12, 2016 at 18:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.