Mongodb(code=exited,status=14)失败,但没有任何明确的错误

z8dt9xmd  于 2023-04-20  发布在  Go
关注(0)|答案(7)|浏览(527)

我有VPS与Ubuntu 18.04 LTSMongodb和我的脚本工作,直到3天前罚款,但突然我的托管服务器被重新启动(我从托管公司购买),当我的服务器再次启动,我看到我的网站不工作,没有连接到数据库.结果的systemctl status mongod是:

mongod.service - MongoDB Database Server
   Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Thu 2020-10-29 22:47:35 +0330; 17h ago
     Docs: https://docs.mongodb.org/manual
  Process: 2800 ExecStart=/usr/bin/mongod --config /etc/mongod.conf (code=exited, status=14)
 Main PID: 2800 (code=exited, status=14)

Oct 29 22:47:35 MYHOSTNAME systemd[1]: Started MongoDB Database Server.
Oct 29 22:47:35 MYHOSTNAME systemd[1]: mongod.service: Main process exited, code=exited, status=14/n/a
Oct 29 22:47:35 MYHOSTNAME systemd[1]: mongod.service: Failed with result 'exit-code'.

当我重新启动服务时,什么也没有发生。我检查了/var/log/mongodb/mongod.log,这是日志:

2020-10-30T15:53:39.251+0330 I REPL     [signalProcessingThread] Stepping down the ReplicationCoordinator for shutdown, waitTime: 10000ms
2020-10-30T15:53:39.458+0330 I CONTROL  [signalProcessingThread] Shutting down the LogicalSessionCache
2020-10-30T15:53:39.460+0330 I NETWORK  [signalProcessingThread] shutdown: going to close listening sockets...
2020-10-30T15:53:39.460+0330 I NETWORK  [signalProcessingThread] removing socket file: /tmp/mongodb-27017.sock
2020-10-30T15:53:39.461+0330 I NETWORK  [signalProcessingThread] Shutting down the global connection pool
2020-10-30T15:53:39.461+0330 I STORAGE  [signalProcessingThread] Shutting down the PeriodicThreadToAbortExpiredTransactions
2020-10-30T15:53:39.462+0330 I REPL     [signalProcessingThread] Shutting down the ReplicationCoordinator
2020-10-30T15:53:39.462+0330 I SHARDING [signalProcessingThread] Shutting down the ShardingInitializationMongoD
2020-10-30T15:53:39.463+0330 I COMMAND  [signalProcessingThread] Killing all open transactions
2020-10-30T15:53:39.463+0330 I -        [signalProcessingThread] Killing all operations for shutdown
2020-10-30T15:53:39.463+0330 I NETWORK  [signalProcessingThread] Shutting down the ReplicaSetMonitor
2020-10-30T15:53:39.463+0330 I CONTROL  [signalProcessingThread] Shutting down free monitoring
2020-10-30T15:53:39.464+0330 I CONTROL  [signalProcessingThread] Shutting down free monitoring
2020-10-30T15:53:39.466+0330 I FTDC     [signalProcessingThread] Shutting down full-time data capture
2020-10-30T15:53:39.466+0330 I FTDC     [signalProcessingThread] Shutting down full-time diagnostic data capture
2020-10-30T15:53:39.470+0330 I STORAGE  [signalProcessingThread] Shutting down the HealthLog
2020-10-30T15:53:39.471+0330 I STORAGE  [signalProcessingThread] Shutting down the storage engine
2020-10-30T15:53:39.472+0330 I STORAGE  [signalProcessingThread] WiredTigerKVEngine shutting down
2020-10-30T15:53:39.472+0330 I STORAGE  [signalProcessingThread] Shutting down session sweeper thread
2020-10-30T15:53:39.472+0330 I STORAGE  [signalProcessingThread] Finished shutting down session sweeper thread
2020-10-30T15:53:39.648+0330 I STORAGE  [signalProcessingThread] shutdown: removing fs lock...
2020-10-30T15:53:39.648+0330 I -        [signalProcessingThread] Dropping the scope cache for shutdown
2020-10-30T15:53:39.648+0330 I CONTROL  [signalProcessingThread] now exiting
2020-10-30T15:53:39.648+0330 I CONTROL  [signalProcessingThread] shutting down with code:0

我做了telnet localhost 27017,它工作正常,连接(它的远程连接关闭)。
我手动删除了/tmp/mongodb-27017.sock,检查了/var/log/mongodb/var/lib/mongodb的所有权,一切都是正确的。我还在两个文件夹上做了chown -R mongodb:mongodb,以纠正它们,如果在突然重启期间发生任何不正确的所有权,但没有任何效果。
顺便说一下,当我运行/usr/bin/mongod --config /etc/mongod.conf命令时,我的网站运行,我可以登录到我的用户帐户等。我目前正在screen中执行此操作以运行我的网站,但我不知道如何找到问题并修复它。
你能帮我检查一下MongoDB的问题以及如何修复它吗?还有像nginx -t测试配置文件,有没有类似的命令?我读了man mongod,但没有发现任何问题。

编辑后新增/etc/mongodb.conf内容

# mongod.conf

# for documentation of all options, see:
#   http://docs.mongodb.org/manual/reference/configuration-options/

# Where and how to store data.
storage:
  dbPath: /var/lib/mongodb
  journal:
    enabled: true
#  engine:
#  mmapv1:
#  wiredTiger:

# where to write logging data.
systemLog:
  destination: file
  logAppend: true
  path: /var/log/mongodb/mongod.log

# network interfaces
net:
  port: 27017
  bindIp: 127.0.0.1

# how the process runs
processManagement:
  timeZoneInfo: /usr/share/zoneinfo

security:
  authorization: enabled

#operationProfiling:

#replication:

#sharding:

## Enterprise-Only Options:

#auditLog:

#snmp:
k2fxgqgv

k2fxgqgv1#

试试这个,它对我很有效:

sudo chown -R mongodb:mongodb /var/lib/mongodb
sudo chown mongodb:mongodb /tmp/mongodb-27017.sock    
sudo service mongod restart
3pmvbmvn

3pmvbmvn2#

在我的例子中,用户是mongod,/var/lib文件夹中的文件夹是mongo,因此我必须运行此命令

chown -R mongod:mongod /var/lib/mongo/
chown mongod:mongod /tmp/mongodb-27017.sock

systemctl restart mongod
syqv5f0l

syqv5f0l3#

我通过使用grepping mongo在/var/log/syslog中进行彻底的调查来解决这个问题。
我做了chown -R mongodb:mongodb /var/lib/mongodb/并终止了我的screen命令,然后重新启动mongod服务,然后检查status,所以现在服务和我的网站运行没有问题。

更好的解决方案,运行以下命令:

chown -R mongodb:mongodb /var/lib/mongodb/
systemctl restart mongod
rkttyhzu

rkttyhzu4#

1.转到/tmp并找到mongodb sock
cd /tmp; ls -l *.sock
1.更改.sock文件的所有者,它以前被命名为mongodb-27017.sock,但如果你发现它是一个不同的名字,也没关系。
chown -R mongod:mongod /var/lib/mongo
chown mongod:mongod mongodb-27017.sock
如果结果是这样:无效用户:mongod:mongod则意味着mongodb的用户和组不是mongod。

omhiaaxx

omhiaaxx5#

我知道这是一个迟来的答案,但由于这个问题是Ubuntu for mongodb中的一个已知问题,我建议这样做:
1.创建一个名为/root/mongo.sh的文件,内容如下:

chown -R mongodb:mongodb /var/lib/mongodb/
systemctl restart mongod

1.在终端运行chmod +x /root/mongo.sh
1.通过运行crontab -e将其添加到crontab:

0 2 * * * /root/mongo.sh

现在它每天凌晨2:00运行此文件,您不必担心。
如果您在白天看到此问题,请仅运行以下命令:

/root/mongo.sh
qyyhg6bp

qyyhg6bp6#

我杀死了所有进程已经运行一个接一个的名称mongo

root@lancer:/mongodb# ps -ef | grep mongo
root       721 27584  0 Sep27 pts/7    00:00:00 sudo nano mongo.conf
root       722   721  0 Sep27 pts/7    00:00:00 nano mongo.conf
root       736 27584  0 Sep27 pts/7    00:00:00 sudo nano mongo.conf
root       737   736  0 Sep27 pts/7    00:00:00 nano mongo.conf
root       779 27584  0 Sep27 pts/7    00:00:00 sudo nano mongo.conf
root       780   779  0 Sep27 pts/7    00:00:00 nano mongo.conf
root       873 27584  0 Sep27 pts/7    00:00:00 vi mongo.conf
root      1102     1  0 Sep27 ?        00:03:34 mongod --dbpath /mongodb/data --logpath /mongodb/log/mongod.log --fork
root      1150 27584  0 Sep27 pts/7    00:00:02 mongosh
root     10858  5566  0 Sep20 pts/7    00:00:00 sudo systemctl status mongod
root     12386 27584  0 16:27 pts/7    00:00:00 vi mongod.conf
root     13091 27584  0 16:48 pts/7    00:00:00 sudo systemctl status mongod
root     13092 13091  0 16:48 pts/7    00:00:00 systemctl status mongod
root     13258 27584  0 16:52 pts/7    00:00:00 sudo adduser mongod
root     13459 27584  0 16:52 pts/7    00:00:00 sudo adduser mongodb
root     13507 13460  0 16:53 pts/7    00:00:00 /usr/bin/chfn mongodb
root     14091 27584  0 17:37 pts/7    00:00:00 mongo
root     16620 27584  0 20:32 pts/7    00:00:00 grep --color=auto mongo
root     19169 27584  0 11:25 pts/7    00:00:00 vi mongod.service
root     24606 22371  0 Sep27 pts/7    00:00:00 mongo
root     24763 22371  0 Sep27 pts/7    00:00:00 vi mongodb.conf
root     29184 27584  0 Sep27 pts/7    00:00:00 sudo nano /lib/systemd/system/mongod.service
root     29185 29184  0 Sep27 pts/7    00:00:00 nano /lib/systemd/system/mongod.service 

and then did

root@lancer:/# sudo systemctl start mongod
root@lancer:/# sudo systemctl status mongod

● mongod.service - High-performance, schema-free document-oriented database
   Loaded: loaded (/lib/systemd/system/mongod.service; disabled; vendor preset: enabled)
   Active: active (running) since Tue 2021-09-28 20:39:09 IST; 33s ago
 Main PID: 16836 (mongod)

然后它开始成功运行。

dxpyg8gm

dxpyg8gm7#

检查**/etc/mongod.conf**-它引用了

pidFilePath: /var/run/mongodb/mongod.pid  # location of pidfile

检查**/var/run**(没有mongodb)

mkdir -p /var/run/mongodb
chown mongod.mongod /var/run/mongodb
systemctl daemon-reload
systemctl start mongod
systemctl status mongod

这看起来像是成功了...但它没有
来源:https://stackoverflow.com/a/71384602/2182349
在CentOS7机器上,我将这些行添加到**/lib/systemd/system/mongod.service**

ExecStartPre=/usr/bin/mkdir -p /var/run/mongodb
ExecStartPre=/usr/bin/chown -R mongod.mongod /var/run/mongodb
ExecStartPre=/usr/bin/chmod 0755 /var/run/mongodb
PermissionsStartOnly=true
PIDFile=/var/run/mongodb/mongod.pid
Type=forking

mongod --version db version v5.0.15

相关问题