Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't start mongod with config file

Tags:

mongodb

I installed mongodb on windows 8.1

then I use command promp to navigate to D:\mongodb\bin

then I use this command

mongod.exe --config D:\mongodb\mongodb.conf

The content of mongodb.conf

bind_ip = 127.0.0.1,100.100.100.100
port = 3979
quiet = true
dbpath = D:\mongodb\data\db
logpath = D:\mongodb\data\log\mongodb.log
logappend = true
journal = true

But mongod doesn't start. If I use mongod.exe (without using config file), it works perfectly

UPDATE:

My intention is simple: change default port to another port and only allow access from certain IP addresses.

I was using the configuration for Ubuntu. Thanks to Panda_Claus that pointed out the new configuration.

So I changed the configuration to

net:
   bindIp: 127.0.0.1,100.100.100.100
   port: 3979

The problem is, when I start mongod with this configuration, it got error then automatically exits

ERROR: listen(): bind() failed errno:10049 The requested address is not valid in its context. for socket: 100.100.100.100:3979

So how do I allow only localhost and a specific IP address (in this case is 100.100.100.100) to connect to mongodb?

UPDATE 2

I used the configuration from maerics

net:
  bindIp: 127.0.0.1,192.168.10.104
  port: 3979
storage:
  dbPath: D:\mongodb\data\db
  journal:
    enabled: true
systemLog:
  destination: file
  path: D:\mongodb\data\log\mongodb.log
  quiet: true
  logAppend: true

Interestingly, using this, I can only connect to db on local machine, other LAN computer can't connect to

192.168.10.104:3979. 

However, if I remove the

systemLog:
  destination: file
  path: D:\mongodb\data\log\mongodb.log
  quiet: true
  logAppend: true

other computers in LAN network are able connect to the database.

like image 847
haipham23 Avatar asked Aug 08 '14 18:08

haipham23


People also ask

Where is the mongod conf file?

dbPath is /var/lib/mongodb; this setting specifies where MongoDB should store its files. systemLog. path is /var/log/mongodb/mongod. log; this is the path where mongod will write its output.


1 Answers

The config file must be valid YAML.

Try modifying the sample file provided with the documentation, for example:

net:
  bindIp: 127.0.0.1
  port: 3979
storage:
  dbPath: D:\mongodb\data\db
  journal:
    enabled: true
systemLog:
  destination: file
  path: D:\mongodb\data\log\mongodb.log
  quiet: true
  logAppend: true
like image 149
maerics Avatar answered Oct 14 '22 11:10

maerics