mongodb - 无法更改 mongodb 的 dbpath

标签 mongodb windows-subsystem-for-linux

我无法更改 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

73044PID

然后你可以用

终止进程
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/

相关文章:

Mongodb计算查询--累积乘法

mongodb - Map Reduce 标记计数范围按日期和类别

ubuntu - 如何在 Windows 应用程序的 ubuntu 中运行 docker?

c++ - 无法在 vs2017 的 linux 子系统上包含 header

c++ - 如何在WSL 2中读取物理内存?

node.js - 如何修复 : 'MongoError: authentication fail' @MongoDB Atlas

json - 将两个具有相同列/索引的 pandas DataFrame 连接到一个 DataFrame

bash - 在 shell 脚本中使用 mongodb 的结果

linux - bash 脚本中无法访问系统环境变量

c++ - WSL 中 QT 的动态链接不起作用但在 docker 容器中工作