Why does the status of mongo throw me (code = exited, status = 48)?

Fra*_*tto 5 mongodb google-compute-engine

I am experiencing extreme slowness with mongo. Earlier when I put sudo systemctl status mongodb mongo I appeared Online and in green. Now after a few days he started to throw me away

 mongodb.service - High-performance, schema-free document-oriented database
   Loaded: loaded (/etc/systemd/system/mongodb.service; disabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Fri 2019-11-29 08:55:07 -03; 3 days ago
  Process: 13231 ExecStart = / usr / bin / mongod --quiet --config /etc/mongod.conf (code = exited, status = 48)
 Main PID: 13231 (code = exited, status = 48)

Nov 29 08:55:07 production-power systemd [1]: Started High-performance, schema-free document-oriented database.
Nov 29 08:55:07 production-power systemd [1]: mongodb.service: Main process exited, code = exited, status = 48 / n / a
Nov 29 08:55:07 production-power systemd [1]: mongodb.service: Unit entered failed state.
Nov 29 08:55:07 production-power systemd [1]: mongodb.service: Failed with result 'exit-code'.
Run Code Online (Sandbox Code Playgroud)

This started to happen after an unexpected restart of Google VPS. I think it may be the cause of slowness. In any case, the mongo service is working, so write and read at the base normally nothing but slower. Anyone know how to solve the problem?

You*_*mad 25

一些 ubuntu 用户遇到端口问题

\n

因为当操作系统打开时,端口会自动运行!

\n

如果你遇到这个问题,更改端口不会有多大用处!\n杀死 mongod 的端口,默认为 => 27017

\n
sudo kill -9 $(sudo lsof -t -i:27017)\n
Run Code Online (Sandbox Code Playgroud)\n

然后

\n
sudo systemctl start mongod\nsudo systemctl status mongod\n
Run Code Online (Sandbox Code Playgroud)\n

它会返回

\n
\xe2\x97\x8f mongod.service - MongoDB Database Server\n\nLoaded: loaded (/lib/systemd/system/mongod.service; disabled; vendor preset: enabled)\n\nActive: active (running) since Tue 2021-08-17 09:47:31 EEST; 2s ago\n\n   Docs: https://docs.mongodb.org/manual\n\nMain PID: 7119 (mongod)\n\n Memory: 166.7M\n\n CGroup: /system.slice/mongod.service\n\n         \xe2\x94\x94\xe2\x94\x807119 /usr/bin/mongod --config /etc/mongod.conf\n
Run Code Online (Sandbox Code Playgroud)\n


Dra*_*ire 10

对我来说问题出在bindIP上。我试图使用配置远程访问bindIp: 127.0.0.1,mongodb_server_ip

\n

也如此

\n
sudo nano /etc/mongod.conf\n
Run Code Online (Sandbox Code Playgroud)\n

然后

\n
bindIp 127.0.0.1\n
Run Code Online (Sandbox Code Playgroud)\n

然后

\n
sudo systemctl start mongod\nsudo systemctl status mongod\n
Run Code Online (Sandbox Code Playgroud)\n

结果

\n
\xe2\x97\x8f mongod.service - MongoDB Database Server\n     Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled)\n     Active: active (running) since Wed 2021-03-03 07:59:40 UTC; 3min 47s ago\n       Docs: https://docs.mongodb.org/manual\n   Main PID: 910 (mongod)\n     Memory: 174.8M\n     CGroup: /system.slice/mongod.service\n             \xe2\x94\x94\xe2\x94\x80910 /usr/bin/mongod --config /etc/mongod.conf\n\nMar 03 07:59:40 ip-172-31-17-169 systemd[1]: Started MongoDB Database Server.\n
Run Code Online (Sandbox Code Playgroud)\n

  • 是的,但现在您只能接受来自本地计算机的连接。 (13认同)

cem*_*tin 9

当我尝试运行 mongodb 时出现错误代码 48。

这是输出:

sudo service mongod status
? mongod.service - MongoDB Database Server
   Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Tue 2019-12-31 13:15:04 +03; 33min ago
     Docs: https://docs.mongodb.org/manual
 Main PID: 18645 (code=exited, status=48)

Dec 31 13:15:03 cem systemd[1]: Started MongoDB Database Server.
Dec 31 13:15:04 cem systemd[1]: mongod.service: Main process exited, code=exited, status=48/n/a
Dec 31 13:15:04 cem systemd[1]: mongod.service: Failed with result 'exit-code'.
Run Code Online (Sandbox Code Playgroud)

我的解决方案是更改默认端口,因为当 MongoDB 的端口已被使用时会发生此错误。

第一步:打开conf文件进行编辑。

须藤vim /etc/mongod.conf

步骤2:找到端口并更改它。

net: 端口: 27017 -> 任何更改前的默认端口

更改端口后,我的问题解决了:

sudo service mongod status
? mongod.service - MongoDB Database Server
   Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled)
   Active: active (running) since Tue 2019-12-31 13:48:32 +03; 1s ago
     Docs: https://docs.mongodb.org/manual
 Main PID: 25254 (mongod)
   CGroup: /system.slice/mongod.service
           ??25254 /usr/bin/mongod --config /etc/mongod.conf

Dec 31 13:48:32 cem systemd[1]: Started MongoDB Database Server.
Run Code Online (Sandbox Code Playgroud)

我希望这对你有用。