Mongo服务启动或重启始终失败

时间:2022-05-05 23:41:26

I've installed mongodb then I've created a mongo service:

我已经安装了mongodb然后我创建了一个mongo服务:

 [Unit]
    Description=High-performance, schema-free document-oriented database
    After=network.target

    [Service]
    User=mongodb
    ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf

    [Install]
    WantedBy=multi-user.target

But When I launch the service and then I check the status, I get always this error:

但是当我启动该服务然后检查状态时,我总是得到这个错误:

● mongodb.service - High-performance, schema-free document-oriented database
   Loaded: loaded (/etc/systemd/system/mongodb.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Mon 2017-04-24 13:08:55 UTC; 6min ago
  Process: 1094 ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf (code=exited, status=48)
 Main PID: 1094 (code=exited, status=48)

Apr 24 13:08:54 ip-172-31-37-163 systemd[1]: Started High-performance, schema-free document-oriented database.
Apr 24 13:08:55 ip-172-31-37-163 systemd[1]: mongodb.service: Main process exited, code=exited, status=48/n/a
Apr 24 13:08:55 ip-172-31-37-163 systemd[1]: mongodb.service: Unit entered failed state.
Apr 24 13:08:55 ip-172-31-37-163 systemd[1]: mongodb.service: Failed with result 'exit-code'.

3 个解决方案

#1


6  

The problem was in config file and changing

问题出在配置文件和更改中

bindIp: 127.0.0.1, X.X.X.X

bindIp:127.0.0.1,X.X.X.X

to

bindIp: [127.0.0.1, X.X.X.X]

bindIp:[127.0.0.1,X.X.X.X]

Solved my issue

解决了我的问题

#2


1  

In MongoDB 3.6 the brackets proposed by @Chlebta did not work for me, returning the error:

在MongoDB 3.6中,@ Chlebta提出的括号对我不起作用,返回错误:

mongod.service: Main process exited, code=exited, status=2/INVALIDARGUMENT

mongod.service:退出主进程,代码=退出,状态= 2 / INVALIDARGUMENT

My mistake was separating the IP addresses with commas and spaces. There has to be only commas between the addresses:

我的错误是用逗号和空格分隔IP地址。地址之间只能有逗号:

bindIp: 127.0.0.1,X.X.X.X,Y.Y.Y.Y

#3


0  

I just reboot system (sudo reboot) it is working for me. i don't know why.

我刚刚重启系统(sudo reboot)它对我有用。我不知道为什么。

#1


6  

The problem was in config file and changing

问题出在配置文件和更改中

bindIp: 127.0.0.1, X.X.X.X

bindIp:127.0.0.1,X.X.X.X

to

bindIp: [127.0.0.1, X.X.X.X]

bindIp:[127.0.0.1,X.X.X.X]

Solved my issue

解决了我的问题

#2


1  

In MongoDB 3.6 the brackets proposed by @Chlebta did not work for me, returning the error:

在MongoDB 3.6中,@ Chlebta提出的括号对我不起作用,返回错误:

mongod.service: Main process exited, code=exited, status=2/INVALIDARGUMENT

mongod.service:退出主进程,代码=退出,状态= 2 / INVALIDARGUMENT

My mistake was separating the IP addresses with commas and spaces. There has to be only commas between the addresses:

我的错误是用逗号和空格分隔IP地址。地址之间只能有逗号:

bindIp: 127.0.0.1,X.X.X.X,Y.Y.Y.Y

#3


0  

I just reboot system (sudo reboot) it is working for me. i don't know why.

我刚刚重启系统(sudo reboot)它对我有用。我不知道为什么。