[英]Why does the status of mongo throw me (code = exited, status = 48)?
I am experiencing extreme slowness with mongo.我正在经历 mongo 的极度缓慢。 Earlier when I put sudo systemctl status mongodb mongo I appeared Online and in green.
早些时候,当我输入 sudo systemctl status mongodb mongo 时,我出现在网上并且呈绿色。 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'.
This started to happen after an unexpected restart of Google VPS.这在 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.
在任何情况下,mongo 服务都在工作,所以在基础上写入和读取通常只会更慢。 Anyone know how to solve the problem?
任何人都知道如何解决这个问题?
I got error code 48 when i tried to run mongodb.尝试运行 mongodb 时出现错误代码 48。
Here is the output:这是输出:
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'.
My solution was changing the default port, because this error occurs when the port for MongoDB is already in use.我的解决方案是更改默认端口,因为当 MongoDB 的端口已在使用时会发生此错误。
Step 1: open conf file to edit.第一步:打开conf文件进行编辑。
sudo vim /etc/mongod.conf须藤 vim /etc/mongod.conf
Step 2: find port and change it.第2步:找到端口并更改它。
net: port: 27017 -> default port before any change net: port: 27017 -> 更改前的默认端口
After changing port, my issue solved :更改端口后,我的问题解决了:
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.
I hope this works for you.我希望这对你有用。
Some ubuntu users have a problem with ports一些ubuntu用户有端口问题
Because the ports will run automatically when the OS opens!因为当操作系统打开时端口会自动运行!
If you have this issue, change the ports will not useful a lot!如果你有这个问题,改变端口不会有用很多! kill the port of mongod, as a default is => 27017
杀死mongod的端口,默认为=> 27017
sudo kill -9 $(sudo lsof -t -i:27017)
then然后
sudo systemctl start mongod
sudo systemctl status mongod
It will return它会回来
● mongod.service - MongoDB Database Server
Loaded: loaded (/lib/systemd/system/mongod.service; disabled; vendor preset: enabled)
Active: active (running) since Tue 2021-08-17 09:47:31 EEST; 2s ago
Docs: https://docs.mongodb.org/manual
Main PID: 7119 (mongod)
Memory: 166.7M
CGroup: /system.slice/mongod.service
└─7119 /usr/bin/mongod --config /etc/mongod.conf
For me the problem was in bindIP.对我来说,问题出在 bindIP 中。 I was trying to configure remote access using
bindIp: 127.0.0.1,mongodb_server_ip
我试图使用
bindIp: 127.0.0.1,mongodb_server_ip
So do也一样
sudo nano /etc/mongod.conf
Then然后
bindIp 127.0.0.1
Then然后
sudo systemctl start mongod
sudo systemctl status mongod
Result结果
● mongod.service - MongoDB Database Server
Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2021-03-03 07:59:40 UTC; 3min 47s ago
Docs: https://docs.mongodb.org/manual
Main PID: 910 (mongod)
Memory: 174.8M
CGroup: /system.slice/mongod.service
└─910 /usr/bin/mongod --config /etc/mongod.conf
Mar 03 07:59:40 ip-172-31-17-169 systemd[1]: Started MongoDB Database Server.
在我的情况下,mongo 之前没有正确停止并且有一个活动进程,我不得不优雅地杀死它,并且在它开始之后一切都很好。
I have solved issue through stopping service which is running on the port 27017. This happens especially you run mongod service with root priviledges then try to start it again with another user with sudo priviledges.我已经通过停止在端口 27017 上运行的服务解决了问题。这种情况尤其发生在您以 root 权限运行 mongod 服务,然后尝试使用另一个具有 sudo 权限的用户再次启动它。 So, if you don't mind about the service has been started by another user, you can kill the process on the port you run mongod service, such as:
因此,如果您不介意该服务已被其他用户启动,您可以在您运行 mongod 服务的端口上杀死该进程,例如:
sudo fuser -k 27017/tcp
I had the same issue, then I realized my docker container port is running on the same port.我遇到了同样的问题,然后我意识到我的 docker 容器端口正在同一个端口上运行。 Either change the docker container port or change the mongo port.
更改 docker 容器端口或更改 mongo 端口。
I have been able to fixed the issue.我已经能够解决这个问题。 The mongod service process tries to run on the same port and this was as a result of previously running mongod service with root privileged on ubuntu. I had to kill the process on the port mongod service is listening to without worrying.
mongod 服务进程试图在同一个端口上运行,这是由于之前在 ubuntu 上以 root 特权运行 mongod 服务的结果。我不得不终止 mongod 服务正在监听的端口上的进程而不用担心。
sudo fsuer -k 2701/tcp
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.