0

In config file I have:

   systemLog:
        destination: file
        logAppend: true
        path: c:\data\log\mongod.log
    storage:
        dbPath: c:\data\db
        journal:
            enabled: true
    replication:
       replSetName: "rs0"
    net:
       bindIp: 127.0.0.1
       port: 27017
    security:
         authorization: enabled

enter image description here

I'm trying to connect using mongod process like in documentation:

C:\Program Files\MongoDB\Server\3.6\bin> mongod --auth --dbpath /data/db --config C:\Program Files\MongoDB\Server\3.6\mongod.cfg

And getting:

Error reading config file: No such file or directory
try 'C:\Program Files\MongoDB\Server\3.6\bin\mongod.exe --help' for more information

enter image description here

Then trying with quotes

C:\Program Files\MongoDB\Server\3.6\bin> mongod --auth --dbpath /data/db --config "C:\Program Files\MongoDB\Server\3.6\mongod.cfg"

and getting:

2018-07-02T02:49:21.272+0300 I CONTROL [main] log file "c:\data\log\mongod.log" exists; moved to "c:\data\log\mongod.log.2018-07-01T23-49-21".

enter image description here Starting mongo, then show dbs and see: enter image description here

If I'm writting this snippet (without config), everything is fine:

mongod --auth --dbpath /data/db --bind_ip 127.0.0.1

enter image description here With mongo: enter image description here What I'm doing wrong? I appreciate any help.

3
  • If you use --config, you don't need those other parameters, because your config have those already.
    – JJussi
    Jul 2 '18 at 14:38
  • I think there are some missing information here. The config you posted says that you're running a replica set node, but only one of them. This will put them into SECONDARY status, and the reason why you need rs.slaveOk() to query it. What is your goal? Are you trying to run MongoDB for development? Where did you get the steps from?
    – kevinadi
    Jul 5 '18 at 2:36
  • @KevinAdistambha not yet, just learning now. the goal is to learn more about the possibilities of technology
    – invzbl3
    Jul 5 '18 at 11:47
0

Solution

  1. To avoid the error like: not master and slaveOk = false need always using the command: rs.slaveOk().
  2. To avoid typing rs.slaveOk() every time need to add rs.slaveOk() in .mongorc.js file check here and here
  3. More detail information.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.