node.js - 无法在 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}}
解决方案
您只停止了 Mongo shell(或者mongod
默认情况下可能分叉到后台,并且您没有直接 ctrl+c 控制它)。
您可以使用pkill -f mongod
以终止mongod
名称中的所有进程。不过,我不一定会在生产 MongoDB 上这样做,但这似乎是一个开发环境。
推荐阅读
- ansible - 如何在 Ansible Playbook 中使用变量
- python - OPC(服务器和客户端)与 python
- angular - Angular - 单例服务更改仅针对一个组件
- spotfire - 在 spotfire 中保存用户输入
- powershell-core - 如何在 PowerShell 核心中创建永久别名文件?
- javascript - Javascript 运算符“in”不适用于浮点数
- swift - Render text with SKRenderer
- java - 如何检查 JAVA 代码(保留在数据库中)是否正确完成或突然终止?
- xamarin.forms - Xamarin iOS build error - Native linking failed (Link Framework SDKs Only)
- django - 对于 nginx,我是在为这个 url https://localhost:3000 监听端口 443 还是端口 3000?