首页 > 解决方案 > 无法在 Amazon Linux 上启动 mongoDB

问题描述

我使用以下命令启动了 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选项运行相同的命令,然后它说“杀死任何进程”,但它仍然挂起并且从未结束命令。我还尝试使用不同的端口运行相同的命令,但它也给了我错误:

{"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}}

标签: node.jslinuxmongodbamazon-web-services

解决方案


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

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


推荐阅读