【问题标题】:Cant start mongoDB on Amazon Linux无法在 Amazon Linux 上启动 mongoDB
【发布时间】:2020-09-09 04:51:55
【问题描述】:

我使用以下命令启动 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.js linux mongodb amazon-web-services


    【解决方案1】:

    您只是停止了 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":"Failed to unlink socket file","attr":{"path":"/tmp/mongodb-27017.sock","error":"Operation not permitted"}} {"t":{"$date":"2020-09-08T20:52:38.274+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: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 选项。
    猜你喜欢
    • 2021-10-01
    • 2014-10-08
    • 2021-10-12
    • 2016-05-04
    • 2016-03-09
    • 1970-01-01
    • 2014-03-09
    • 1970-01-01
    • 2012-10-15
    相关资源
    最近更新 更多