3

First of all I know this has the same title as mine, but in my case it's not the wrong port.

I want to setup sharding on my local machine I start with the following command:

mongod --shardsvr --replSet rs1 --port 27017 --dbpath D:\mongo\data1\db

Then do the following:

mongo --port 27017
rs.initiate({_id : "rs1", version: 1, members: [ {_id : 0, "host" : "localhost:27017"} ] })

I'm still getting the following:

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

I already tried by changing localhost with 127.0.0.1 but doesn't work. I've searched for a while now, but the only solution people are giving the wrong port, while i'm 100% certain that this isn't the case here.

Anyone know how to fix?

Thanks in advance!

JC97
  • 1,530
  • 2
  • 23
  • 44
  • 1
    I tried to reproduce your error. This worked fine (on my machine). Perhaps the dbpath has already been used by another mongod instance? Could you try and use another dbpath? – mbuechmann Aug 09 '18 at 14:39
  • I tried with a new data folder on C: drive, still the same :/ – JC97 Aug 09 '18 at 14:45
  • For some reason it's working when I pick a port > 20, can't explain why since it's a fresh windows & mongo install & I haven't run any command before that. – JC97 Aug 09 '18 at 14:58
  • I just wanted to ask if you can connect, when you do not start the server. There must be another instance running. – mbuechmann Aug 09 '18 at 14:59
  • Apperently I can. Tried it myself. On 27017 I can connect, 18 & 19 not but those doesn't work either. Does mongodb start instances on its own? Because I remember a year ago I didn't have any problems like this. – JC97 Aug 09 '18 at 15:11
  • Depends on your installation, I guess. I wonder why you could start a second daemon on the same port without error. – mbuechmann Aug 10 '18 at 06:14

1 Answers1

2

Problem was that mongoDB automatically launches an instance apperently. If i use ports >= 20 it works, but 17-19 not. I can only connect to 27017 though, 18 & 19 doesn't work.

But my 100% sure that it wasn't about ports was obviously wrong!

JC97
  • 1,530
  • 2
  • 23
  • 44
  • Do you mean that it launches a Windows service automatically when you install via the MSI installer? – Nic Cottrell Aug 09 '18 at 20:11
  • Apparently. I used a fresh windows install & a fresh mongodb install with robo3t – JC97 Aug 10 '18 at 09:02
  • 3
    Thanks for pointing in the right direction. To close the service on Windows go to Taskmanager > Services, and stop the MongoDB service. Then the command should run fine. – Jeffrey Roosendaal Apr 08 '19 at 09:48