Node.js 无法在Amazon Linux上启动mongoDB

Node.js 无法在Amazon Linux上启动mongoDB,node.js,linux,mongodb,amazon-web-services,Node.js,Linux,Mongodb,Amazon Web Services,我使用以下命令启动了mongoDB: mongod --auth --port 27017 --dbpath /var/lib/mongo 我能够用mongo shell成功地连接到mongo。 然后通过执行ctrl+c停止进程。 现在,当我再次尝试使用上述命令开始时,我得到了以下结果: {"t":{"$date":"2020-09-08T20:50:56.894+00:00"},"s":"I&qu

我使用以下命令启动了mongoDB:

 mongod  --auth --port 27017 --dbpath  /var/lib/mongo
我能够用mongo shell成功地连接到mongo。 然后通过执行
ctrl+c
停止进程。 现在,当我再次尝试使用上述命令开始时,我得到了以下结果:

{"t":{"$date":"2020-09-08T20:50:56.894+00:00"},"s":"I",  "c":"CONTROL",  "id":23285,   "ctx":"main","msg":"Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'"}
{"t":{"$date":"2020-09-08T20:50:56.896+00:00"},"s":"W",  "c":"ASIO",     "id":22601,   "ctx":"main","msg":"No TransportLayer configured during NetworkInterface startup"}
{"t":{"$date":"2020-09-08T20:50:56.896+00:00"},"s":"I",  "c":"NETWORK",  "id":4648601, "ctx":"main","msg":"Implicit TCP FastOpen unavailable. If TCP FastOpen is required, set tcpFastOpenServer, tcpFastOpenClient, and tcpFastOpenQueueSize."}
{"t":{"$date":"2020-09-08T20:50:56.897+00:00"},"s":"I",  "c":"STORAGE",  "id":4615611, "ctx":"initandlisten","msg":"MongoDB starting","attr":{"pid":21545,"port":27017,"dbPath":"/var/lib/mongo","architecture":"64-bit","host":"ip-172-31-35-217.ec2.internal"}}
{"t":{"$date":"2020-09-08T20:50:56.897+00:00"},"s":"I",  "c":"CONTROL",  "id":23403,   "ctx":"initandlisten","msg":"Build Info","attr":{"buildInfo":{"version":"4.4.0","gitVersion":"563487e100c4215e2dce98d0af2a6a5a2d67c5cf","openSSLVersion":"OpenSSL 1.0.2k-fips  26 Jan 2017","modules":[],"allocator":"tcmalloc","environment":{"distmod":"amazon2","distarch":"x86_64","target_arch":"x86_64"}}}}
{"t":{"$date":"2020-09-08T20:50:56.897+00:00"},"s":"I",  "c":"CONTROL",  "id":51765,   "ctx":"initandlisten","msg":"Operating System","attr":{"os":{"name":"Amazon Linux release 2 (Karoo)","version":"Kernel 4.14.138-114.102.amzn2.x86_64"}}}
{"t":{"$date":"2020-09-08T20:50:56.897+00:00"},"s":"I",  "c":"CONTROL",  "id":21951,   "ctx":"initandlisten","msg":"Options set by command line","attr":{"options":{"net":{"port":27017},"security":{"authorization":"enabled"},"storage":{"dbPath":"/var/lib/mongo"}}}}
{"t":{"$date":"2020-09-08T20:50:56.897+00:00"},"s":"E",  "c":"NETWORK",  "id":23024,   "ctx":"initandlisten","msg":"Failed to unlink socket file","attr":{"path":"/tmp/mongodb-27017.sock","error":"Operation not permitted"}}
{"t":{"$date":"2020-09-08T20:50:56.897+00:00"},"s":"F",  "c":"-",        "id":23091,   "ctx":"initandlisten","msg":"Fatal assertion","attr":{"msgid":40486,"file":"src/mongo/transport/transport_layer_asio.cpp","line":919}}
{"t":{"$date":"2020-09-08T20:50:56.897+00:00"},"s":"F",  "c":"-",        "id":23092,   "ctx":"initandlisten","msg":"\n\n***aborting after fassert() failure\n\n"}

所以我尝试了多种方法来停止这个过程。但这一过程并没有被扼杀。我还尝试使用
--shutdown
选项运行同一个命令,然后它说“killing process whatever”,但它挂起了,从未结束该命令。我还尝试使用不同的端口运行同一命令,但它也给了我错误:

{"t":{"$date":"2020-09-08T20:42:00.697+00:00"},"s":"I",  "c":"CONTROL",  "id":23285,   "ctx":"main","msg":"Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'"}
{"t":{"$date":"2020-09-08T20:42:00.699+00:00"},"s":"W",  "c":"ASIO",     "id":22601,   "ctx":"main","msg":"No TransportLayer configured during NetworkInterface startup"}
{"t":{"$date":"2020-09-08T20:42:00.699+00:00"},"s":"I",  "c":"NETWORK",  "id":4648601, "ctx":"main","msg":"Implicit TCP FastOpen unavailable. If TCP FastOpen is required, set tcpFastOpenServer, tcpFastOpenClient, and tcpFastOpenQueueSize."}
{"t":{"$date":"2020-09-08T20:42:00.699+00:00"},"s":"I",  "c":"STORAGE",  "id":4615611, "ctx":"initandlisten","msg":"MongoDB starting","attr":{"pid":21444,"port":27018,"dbPath":"/var/lib/mongo","architecture":"64-bit","host":"ip-172-31-35-217.ec2.internal"}}
{"t":{"$date":"2020-09-08T20:42:00.699+00:00"},"s":"I",  "c":"CONTROL",  "id":23403,   "ctx":"initandlisten","msg":"Build Info","attr":{"buildInfo":{"version":"4.4.0","gitVersion":"563487e100c4215e2dce98d0af2a6a5a2d67c5cf","openSSLVersion":"OpenSSL 1.0.2k-fips  26 Jan 2017","modules":[],"allocator":"tcmalloc","environment":{"distmod":"amazon2","distarch":"x86_64","target_arch":"x86_64"}}}}
{"t":{"$date":"2020-09-08T20:42:00.699+00:00"},"s":"I",  "c":"CONTROL",  "id":51765,   "ctx":"initandlisten","msg":"Operating System","attr":{"os":{"name":"Amazon Linux release 2 (Karoo)","version":"Kernel 4.14.138-114.102.amzn2.x86_64"}}}
{"t":{"$date":"2020-09-08T20:42:00.699+00:00"},"s":"I",  "c":"CONTROL",  "id":21951,   "ctx":"initandlisten","msg":"Options set by command line","attr":{"options":{"net":{"port":27018},"security":{"authorization":"enabled"},"storage":{"dbPath":"/var/lib/mongo"}}}}
{"t":{"$date":"2020-09-08T20:42:00.700+00:00"},"s":"E",  "c":"STORAGE",  "id":20557,   "ctx":"initandlisten","msg":"DBException in initAndListen, terminating","attr":{"error":"DBPathInUse: Unable to lock the lock file: /var/lib/mongo/mongod.lock (Resource temporarily unavailable). Another mongod instance is already running on the /var/lib/mongo directory"}}
{"t":{"$date":"2020-09-08T20:42:00.700+00:00"},"s":"I",  "c":"NETWORK",  "id":20562,   "ctx":"initandlisten","msg":"Shutdown: going to close listening sockets"}
{"t":{"$date":"2020-09-08T20:42:00.700+00:00"},"s":"I",  "c":"-",        "id":20520,   "ctx":"initandlisten","msg":"Stopping further Flow Control ticket acquisitions."}
{"t":{"$date":"2020-09-08T20:42:00.700+00:00"},"s":"I",  "c":"CONTROL",  "id":20565,   "ctx":"initandlisten","msg":"Now exiting"}
{"t":{"$date":"2020-09-08T20:42:00.700+00:00"},"s":"I",  "c":"CONTROL",  "id":23138,   "ctx":"initandlisten","msg":"Shutting down","attr":{"exitCode":100}}


您只停止了mongoshell(或者默认情况下,
mongod
分叉到后台,您没有直接的ctrl+c控制)


您可以使用
pkill-f mongod
终止名称中包含
mongod
的所有进程。不过,我不一定要在生产MongoDB上这样做,但这似乎是一个开发环境。

您只停止了Mongo shell(或者默认情况下,
mongod
分叉到后台,您没有直接的ctrl+c控制)


您可以使用
pkill-f mongod
终止名称中包含
mongod
的所有进程。不过,我不一定要在生产mongodb上这样做,但这似乎是一个开发环境。

这是我得到的错误:
{“t”:{“$date”:“2020-09-08T20:52:38.274+00:00”},“s”:“E”,“c”:“NETWORK”,“id”:23024,“ctx”:“initandlisten”,“msg”:“无法取消套接字文件链接”,“attr”:“{“path”:“/tmp/mongodb-27017.sock”,“error”:“不允许操作”{“t”:{“$date”:“2020-09-08T20:52:38.274+00:00”},“s”:“F”、“c”:“id”:23091,“ctx”:“initandlisten”、“msg”:“致命断言”、“attr”:{“msgid”:40486,“文件”:“src/mongo/transport/transport\u layer\u asio.cpp”,“line”:919}{“t”:{“t”:“2020-09-08T20:52:38+00:00”},“s”;“CTF”:“23092”:“id”:”initandlisten,“msg”:“\n\n**
您可能需要手动清理(=删除)该
/tmp/mongodb-27017.sock
。我这样做了,现在它再次给我错误代码9001“地址已在使用”“再次”?您以前从未提到过该错误代码…无论如何,在尝试启动新实例之前,您需要先确定是否有任何
mongod
实例正在运行;
ps aux
显示所有进程,
ss-ltpn
显示所有侦听套接字及其进程。非常感谢。我能够停止该进程。我还使用
mongod--auth--port 27017--dbpath/var/lib/mongo
重新启动了它。问题是,我希望它在后台运行。我如何在后台运行它?仅使用
systemctl start mongod
启动它失败,也没有传递
--auth
选项。这是我得到的错误:
{“t”:“$date“2020-09-08T20:52:38.274+00:00”},“s”:“E”,“c”:“NETWORK”,“id”:23024,“ctx”:“initandlisten”,“msg”:“无法断开套接字文件的链接”,“attr”:“{”path:“/tmp/mongodb-27017.sock”,“错误”:“不允许操作”}{”t:{”日期“$date:“2020-09-08T20:52:38:38:00”},“s”:“F”,“c:-”,“id”:initandlisten{“msgid”:40486,“文件”:“src/mongo/transport/transport_layer_asio.cpp”,“line”:919}{“t”:“$date”:“2020-09-08T20:52:38.274+00:00”},“s”:“F”,“c”:“-”,“id”:23092,“ctx”:“initandlisten”,“msg”:“\n\n**
您可能需要清理(=删除)那是手动的
/tmp/mongodb-27017.sock
。我这样做了,现在它再次给我错误代码9001“地址已在使用中”?您以前从未提到过该错误代码…无论如何,在尝试启动新实例之前,您需要先确定是否有任何
mongod
实例正在运行;
ps aux
显示所有进程,
ss-ltpn
显示所有侦听套接字及其进程。非常感谢。我能够停止该进程。我还使用
mongod--auth--port 27017--dbpath/var/lib/mongo
重新启动了它。问题是,我希望它在后台运行。我如何在后台运行它?仅使用
systemctl start mongod
启动它失败,并且没有传递
--auth
选项。