3

I am using mongodb 4.2 version. I am trying to make replicaset following this article but when I try to bind like in this screenshot

enter image description here

mongo service fails to restart and show errors like:

enter image description here

any ways to fix this? have tried all the Q&A about mongo from stackoverflow

sssanjaya
  • 569
  • 6
  • 21

3 Answers3

3

Try this :- bindIp: 127.0.0.1;192.168.1.178;192.168.1.111 replace comma(,) to semicolon(;)

raman dangol
  • 101
  • 1
  • 11
1

edit: My answer only addresses the problem of a failing mongodb service after system reboot. If your service is failing after a service restart on a running system you have a different problem.

The problem is that at the time of mongodb service start the IP address is not yet available.

To fix this you can set up a systmed service overwrite rule:

sudo mkdir -p /etc/systemd/system/mongodb.service.d
sudo vim /etc/systemd/system/mongodb.service.d/ip_bind.conf

Add the following lines

[Unit]                                                                           
After=network-online.target

This will overwrite the default rule After=network.target. On my system (Ubuntu 20.04) the default mongodb service configuration is located in /usr/lib/systemd/system/mongodb.service.

moiri
  • 41
  • 5
0

First of all, as bindIp parameter accepts string, the syntax of your value looks fine.

You can get the complete output of your service using journalctl command, you can use the following command,

journalctl -xe -u mongod.service

The logs there, will show you the complete error logs.

You can also check the logs of mongod process which is configured in your configuration file under systemLog.path.

You should be using the only IP Addresses at which the mongod will be listening, so you can check your IP addresses once again.

Below is my configuration file,

net:
   bindIp: 127.0.0.1,192.168.100.101
   port: 27018

It works just fine.

Shubham Vaishnav
  • 1,637
  • 6
  • 18
  • 1
    sorry, but doesn't work I tried and please see the question it is similar i guess. – sssanjaya Sep 30 '19 at 09:41
  • @sssanjaya Please add the logs to the question, to get a more clear view of the issue you are facing. I want to see what the mongod process complains about – Shubham Vaishnav Sep 30 '19 at 17:33