MongoDB关闭代码:12

4urapxun  于 2023-04-29  发布在  Go
关注(0)|答案(3)|浏览(118)

我昨天已经保存了我的数据,但是当我试图通过命令提示符打开我的MongoDB并触发命令mongod时,它抛出了以下消息

>C:\mongodb\bin>mongod
>2018-07-20T16:21:25.350+0530 I CONTROL  [main] Automatically disabling TLS 1.0, >to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
>2018-07-20T16:21:25.842+0530 I CONTROL  [initandlisten] MongoDB starting : >pid=13544 port=27017 dbpath=C:\data\db\ 64-bit host=DESKTOP-4H7RM2O
>2018-07-20T16:21:25.842+0530 I CONTROL  [initandlisten] targetMinOS: Windows >7/Windows Server 2008 R2
>2018-07-20T16:21:25.843+0530 I CONTROL  [initandlisten] db version v4.0.0
>2018-07-20T16:21:25.843+0530 I CONTROL  [initandlisten] git version: >3b07af3d4f471ae89e8186d33bbb1d5259597d51
>2018-07-20T16:21:25.843+0530 I CONTROL  [initandlisten] allocator: tcmalloc
>2018-07-20T16:21:25.843+0530 I CONTROL  [initandlisten] modules: none
>2018-07-20T16:21:25.843+0530 I CONTROL  [initandlisten] build environment:
>2018-07-20T16:21:25.843+0530 I CONTROL  [initandlisten]     distmod: 2008plus->ssl
>2018-07-20T16:21:25.843+0530 I CONTROL  [initandlisten]     distarch: x86_64
>2018-07-20T16:21:25.843+0530 I CONTROL  [initandlisten]     target_arch: x86_64
>2018-07-20T16:21:25.844+0530 I CONTROL  [initandlisten] options: {}
>2018-07-20T16:21:25.844+0530 I STORAGE  [initandlisten] exception in >initAndListen: NonExistentPath: Data directory C:\data\db\ not found., >terminating
>2018-07-20T16:21:25.844+0530 I CONTROL  [initandlisten] now exiting
>2018-07-20T16:21:25.844+0530 I CONTROL  [initandlisten] shutting down with >code:100
>
**Here is the command Prompt output when I fire mongo command**

    <C:\mongodb\bin>mongo
    <MongoDB shell version v4.0.0
    <connecting to: mongodb://127.0.0.1:27017
    <2018-07-20T16:28:01.594+0530 E QUERY    [js] Error: couldn't connect to server <127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to <127.0.0.1:27017 :: caused by :: No connection could be made because the target <machine actively refused it. :
    <connect@src/mongo/shell/mongo.js:251:13
    <@(connect):1:6
    <exception: connect failed

这是我的日志文件,显示error =shutting down,代码为:12

>2018-07-20T15:43:37.425+0530 I CONTROL  [initandlisten] ** WARNING: Access >control is not enabled for the database.
>2018-07-20T15:43:37.425+0530 I CONTROL  [initandlisten] **          Read and >write access to data and configuration is unrestricted.
>2018-07-20T15:43:37.425+0530 I CONTROL  [initandlisten] 
>2018-07-20T15:43:37.425+0530 I CONTROL  [initandlisten] ** WARNING: This server >is bound to localhost.
>2018-07-20T15:43:37.425+0530 I CONTROL  [initandlisten] **          Remote >systems will be unable to connect to this server. 
>2018-07-20T15:43:37.425+0530 I CONTROL  [initandlisten] **          Start the >server with --bind_ip <address> to specify which IP 
>2018-07-20T15:43:37.425+0530 I CONTROL  [initandlisten] **          addresses it >should serve responses from, or with --bind_ip_all to
>2018-07-20T15:43:37.426+0530 I CONTROL  [initandlisten] **          bind to all >interfaces. If this behavior is desired, start the
>2018-07-20T15:43:37.426+0530 I CONTROL  [initandlisten] **          server with >--bind_ip 127.0.0.1 to disable this warning.
>2018-07-20T15:43:37.426+0530 I CONTROL  [initandlisten] 
>2018-07-20T15:43:40.388+0530 I FTDC     [initandlisten] Initializing full-time >diagnostic data capture with directory 'C:/mongodb/data/db/diagnostic.data'
>2018-07-20T15:43:40.499+0530 I NETWORK  [initandlisten] waiting for connections >on port 27017
>2018-07-20T15:45:42.106+0530 I CONTROL  [thread1] Ctrl-C signal
>2018-07-20T15:45:42.106+0530 I CONTROL  [consoleTerminate] got CTRL_C_EVENT, >will terminate after current cmd ends
>2018-07-20T15:45:42.106+0530 I NETWORK  [consoleTerminate] shutdown: going to >close listening sockets...
>2018-07-20T15:45:42.325+0530 I CONTROL  [consoleTerminate] Shutting down free >monitoring
>2018-07-20T15:45:42.326+0530 I FTDC     [consoleTerminate] Shutting down full->time diagnostic data capture
>2018-07-20T15:45:42.334+0530 I STORAGE  [consoleTerminate] WiredTigerKVEngine >shutting down
>2018-07-20T15:45:45.543+0530 I STORAGE  [consoleTerminate] shutdown: removing fs >lock...
>2018-07-20T15:45:45.543+0530 I CONTROL  [consoleTerminate] now exiting
>2018-07-20T15:45:45.543+0530 I CONTROL  [consoleTerminate] shutting down with >code:12

我已经确保我的数据路径是正确的,但无法解决这个问题。

2ekbmq32

2ekbmq321#

请尝试以下内容:

Mac: Documents/mongodb/bin/mongod --dbpath Documents/data/db/
Window: "C:\Program Files\MongoDB\Server\3.6\bin\mongod.exe" --dbpath d:\test\mongodb\data

你只需要设置db路径。
您可以将存储数据库路径设置为配置文件:看看这个
并检查这个窗口安装。

ztigrdn8

ztigrdn82#

如果你使用的是Linux,只给予增加存储文件的权限,然后重新启动mongodb就可以了。默认存储文件为var/lib/mongodb。要给予更高的权限,请用途:chmod 777 mongod.

deyfvvtc

deyfvvtc3#

我假设你已经使用以下命令将mongo /data/db挂载到本地文件夹中:

volumes:

      - "./configs/mongodb_data:/data/db"

然后你应该运行这个命令来恢复数据:

chmod 777 /root/it_has_alternatives/configs/mongodb_data

docker container run --rm -v /root/it_has_alternatives/configs/mongodb_data:/data/db mongo:6.0.4-jammy mongod --repair

如果你的docker有一些严重的问题,你可以运行以下命令来修复它:

  • 确保所有Docker容器都已关闭:docker compose down
  • 删除有问题的覆盖层2:sudo rm -R /var/lib/docker/overlay2
  • 删除图像:sudo rm -R /var/lib/docker/image
  • 清除任何其他缓存数据:sudo docker system prune -f
  • 重启docker服务:sudo systemctl restart docker

相关问题