我无法更改 mongoDB (WSL2 Arch) 的 dbpath,我运行以下命令:
sudo mongod --dbpath /home/arijit/work/data/
数据文件夹权限:
drwxr-xr-x 2 mongodb mongodb 4096 Aug 9 10:00 data/
我得到的错误信息:
{"t":{"$date":"2020-08-09T11:55:45.163+05:30"},"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-08-09T11:55:45.228+05:30"},"s":"W", "c":"ASIO", "id":22601, "ctx":"main","msg":"No TransportLayer configured during NetworkInterface startup"}
{"t":{"$date":"2020-08-09T11:55:45.229+05:30"},"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-08-09T11:55:45.231+05:30"},"s":"I", "c":"STORAGE", "id":4615611, "ctx":"initandlisten","msg":"MongoDB starting","attr":{"pid":2643,"port":27017,"dbPath":"/home/arijit/work/data/","architecture":"64-bit","host":"ARIJIT-PC-wsl"}}
{"t":{"$date":"2020-08-09T11:55:45.231+05:30"},"s":"I", "c":"CONTROL", "id":23403, "ctx":"initandlisten","msg":"Build Info","attr":{"buildInfo":{"version":"4.4.0","gitVersion":"563487e100c4215e2dce98d0af2a6a5a2d67c5cf","openSSLVersion":"OpenSSL 1.1.1g 21 Apr 2020","modules":[],"allocator":"tcmalloc","environment":{"distmod":"ubuntu1804","distarch":"x86_64","target_arch":"x86_64"}}}}
{"t":{"$date":"2020-08-09T11:55:45.231+05:30"},"s":"I", "c":"CONTROL", "id":51765, "ctx":"initandlisten","msg":"Operating System","attr":{"os":{"name":"Arch","version":"rolling"}}}
{"t":{"$date":"2020-08-09T11:55:45.232+05:30"},"s":"I", "c":"CONTROL", "id":21951, "ctx":"initandlisten","msg":"Options set by command line","attr":{"options":{"storage":{"dbPath":"/home/arijit/work/data/"}}}}
{"t":{"$date":"2020-08-09T11:55:45.268+05:30"},"s":"E", "c":"STORAGE", "id":20568, "ctx":"initandlisten","msg":"Error setting up listener","attr":{"error":{"code":9001,"codeName":"SocketException","errmsg":"Address already in use"}}}
{"t":{"$date":"2020-08-09T11:55:45.389+05:30"},"s":"I", "c":"CONTROL", "id":20565, "ctx":"initandlisten","msg":"Now exiting"}
{"t":{"$date":"2020-08-09T11:55:45.389+05:30"},"s":"I", "c":"CONTROL", "id":23138, "ctx":"initandlisten","msg":"Shutting down","attr":{"exitCode":48}}
我尝试删除/var/lib/mongodb/mongod.lock 文件,然后运行更改 dbpath 的命令,但结果相同。
最佳答案
根据@Gibbs 的回答,该错误表示该端口已被另一个进程使用。您可以使用
检查并确认ps aux | grep -v grep | grep mongod
输出应该是这样的
user 73044 0.2 0.2 5501992 17176 ?? S 11:02AM 0:07.32 mongod --config /usr/local/etc/mongod.conf --fork
73044
是 PID
然后你可以用
终止进程kill -9 <PID> # Replace <PID> with the PID provided in the output...in my case 73044
您现在可以尝试再次启动 mongod
mongod --dbpath /home/arijit/work/data/
关于mongodb - 无法更改 mongodb 的 dbpath,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63323397/