I am a newbie for setting up the server environment and mongoDB. This may sounds something really simple, however, I really need your help on it.
I am trying to conn
Thanks for @wdberkeley and @anhlc brought up the clue.
I looked at the log file under /var/log/mongodb/mongod.log. It shows the failing reason for the problem.
2015-03-17T16:08:17.274-0400 I CONTROL [initandlisten] options: { config: "/etc/mongod.conf", net: { bindIp: "127.0.0.1, 192.168.184.155" }, storage: { dbPath: "/var/lib/mongodb" }, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongod.log" } }
2015-03-17T16:08:17.332-0400 I NETWORK [initandlisten] getaddrinfo(" 192.168.184.155") failed: Name or service not known
So the mongo.conf file is sensitive to space, which I happened to add and should have noticed. Also just as @anhlc pointed out, 96.88.169.145 is not a valid IP address for VM. So that one also contribute to the error.
Great thanks for both of your help! Hope this may help if someone happened to run into the same problem.
I am running 3.6 on SUSE 12.x and had an issues using comma separated IP lists. I fixed the issue by bindIp: 0.0.0.0
The default /etc/mongod.conf file has this entry for network interfaces:
# network interfaces
net:
port: 27017
bindIp: 127.0.0.1
This corresponds to the --bind-ip arg
parameter on the command line. Notice the dash notation converted to camel case. To expose the database running in a VM to the host, it's simplest to bind the database to all interfaces for testing purposes. This will cover situations where the VM is using a NAT interface or bridged interface. The command line parameter is --bind_ip_all
which does not have a parameter, it's existence corresponds to the bindIPAll: true
parameter in the configuration file. Therefore, the configuration file should be changed to:
# network interfaces
net:
port: 27017
bindIpAll: true
Notice the bindIp
parameter is removed.
It should also be noted that it is possible to add parameters to the command line that override parameters in the config file. Normally, mongod is run with the --config /etc/mongod.conf
parameter. It's easier to change the config file instead of hunting down the script what runs it as a daemon and getting systemd
to reload and use it.
For details on the YAML-ness of the config file vs. parameters on the command line, see the documentation currently at https://docs.mongodb.com/manual/reference/configuration-options/
If you are running mongod on a VM using NAT, the default port 27017
will not be exposed to the host. It will be necessary to map a port on the host to this port in the guest VM. That's beyond the scope of this answer, but a little research will provide a method used for the VM software you are using (VirtualBox, VMware, etc.)
If all you want to do is connect to this machine over the network you do NOT need to modify the bind_ip
value.
In your case you need to follow the following steps.
If you are not sure how to do any of this steps. Check out a blog post that I wrote that goes more in details how to do this.
Hope this helps.
The bindIp rule with comma separated IP addresses is only meant for known ethernet interfaces, or for the 0.0.0.0 and 127.0.0.1 rules. You can only use the ip addresses of your system's Network Interface Cards. If this list contains an unknown IP address, i.e. an IP of another system, your MongoDb instance will not restart and hence you're not able to connect. To check if your MongoDb instance is running, run the following:
$ sudo systemctl status mongod
If you would like to make your MongoDb instance available to other systems on your network, you'll want to bind the local IP associated with the private network. To determine network interface configuration easily, just run an ifconfig from the command line:
$ ifconfig
This will list all available IP addresses that you can use in the bindIp rule. Most certainly, the IP address 96.88.169.145 that you use is not a valid IP address or unknown by your system.
In Mongo 3.*,
use a bracket such as
net:
port: 27017
bindIp : [127.0.0.1,10.0.0.2,10.0.0.3]