无法更改mongodb的dbpath

时间:2020-08-09 06:58:27

标签: 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但结果相同。

2 个答案:

答案 0 :(得分:4)

基于@Gibbs的答案,该错误表示该端口已在使用其他进程。您可以使用

检查并确认
while not done:
    events = pygame.event.get()
    for event in events: # User did something
        if event.type == pygame.QUIT: # If user clicked close
            done = True # Flag that we are done so we exit this loop
 
    # Set the screen background
    screen.fill(BLUE)
    screen.blit(TextSurf, TextRect)

    # Button 1 Control
    button.render(screen)
    if button.clicked(events):
        print("Game Logic goes here")
    
    button2.render(screen)
    if button2.clicked(events):
        print("Game Logic Here")
    pygame.display.flip()

输出应如下所示

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 PID

您可以使用以下方法终止该进程

73044

您现在可以尝试通过

重新开始 mongod

kill -9 <PID> # Replace <PID> with the PID provided in the output...in my case 73044

答案 1 :(得分:1)

错误有所不同

{“错误”:{“代码”:9001,“ codeName”:“ SocketException”,“ errmsg”:“地址已在使用中”}}}

这意味着端口已被另一个进程使用。

尝试检查ps -ef | grep portConfigured。默认的mongo端口为27017

如果端口中正在运行其他进程,则必须在启动mongo时通过传递--port portNumber来更改端口。