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/

rastasheep
  • 10,416
  • 3
  • 27
  • 37
arman
  • 414
  • 2
  • 6
  • 19
  • this might help: http://stackoverflow.com/questions/40711829/this-node-was-not-started-with-the-replset-option – Val Dec 23 '16 at 05:44
  • I tried it but this error was coming, bash: init_replica.js: No such file or directory – arman Dec 23 '16 at 06:05
  • 1
    Check if you're running another mongod ? if yes kill it first. Then possibly it should work. – Futur Sep 20 '17 at 17:22

5 Answers5

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} )
Pang
  • 9,564
  • 146
  • 81
  • 122
piyush sachdeva
  • 416
  • 4
  • 14
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.

gzc
  • 8,180
  • 8
  • 42
  • 62
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
Araz Jafaripur
  • 927
  • 2
  • 12
  • 32
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()

Sathnindu Kottage
  • 1,083
  • 6
  • 17
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.

arman
  • 414
  • 2
  • 6
  • 19