Docker-compose and mongoDB: 任何兼容版本下启动WiredTiger失败?
Docker-compose and mongoDB: Failed to start up WiredTiger under any compatibility version?
我有以下 docker-compose
文件:
version: "3"
services:
#
# APIs
#----------------------------------------------
pokerstats:
image: pokerstats
container_name: pokerstats
ports:
- 8080:8080
depends_on:
- db
#
# Utilities
#----------------------------------------------
db:
image: mongo
container_name: mongo
volumes:
- ./data/db:/data/db
ports:
- "27018:27017"
environment:
MONGO_INITDB_ROOT_USERNAME: admin
MONGO_INITDB_ROOT_PASSWORD: admin
MONGO_INITDB_DATABASE: pokerStats
这在我添加 volumes
之前工作正常。但是,当我 运行: docker-compose up -d
时,mongo 容器会立即停止,并且在日志中我会看到错误:
2020-04-10T19:17:17.313+0000 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=1457M,cache_overflow=(file_max=0M),session_max=33000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000,close_scan_interval=10,close_handle_minimum=250),statistics_log=(wait=0),verbose=[recovery_progress,checkpoint_progress],
2020-04-10T19:17:17.772+0000 E STORAGE [initandlisten] WiredTiger error (1) [1586546237:772524][29:0x7fe9f284fb00], connection: __posix_open_file, 667: /data/db/WiredTiger.wt: handle-open: open: Operation not permitted Raw: [1586546237:772524][29:0x7fe9f284fb00], connection: __posix_open_file, 667: /data/db/WiredTiger.wt: handle-open: open: Operation not permitted
2020-04-10T19:17:17.784+0000 E STORAGE [initandlisten] WiredTiger error (17) [1586546237:784001][29:0x7fe9f284fb00], connection: __posix_open_file, 667: /data/db/WiredTiger.wt: handle-open: open: File exists Raw: [1586546237:784001][29:0x7fe9f284fb00], connection: __posix_open_file, 667: /data/db/WiredTiger.wt: handle-open: open: File exists
2020-04-10T19:17:17.785+0000 I STORAGE [initandlisten] WiredTiger message unexpected file WiredTiger.wt found, renamed to WiredTiger.wt.1
2020-04-10T19:17:17.788+0000 E STORAGE [initandlisten] WiredTiger error (1) [1586546237:788283][29:0x7fe9f284fb00], connection: __posix_open_file, 667: /data/db/WiredTiger.wt: handle-open: open: Operation not permitted Raw: [1586546237:788283][29:0x7fe9f284fb00], connection: __posix_open_file, 667: /data/db/WiredTiger.wt: handle-open: open: Operation not permitted
2020-04-10T19:17:17.799+0000 E STORAGE [initandlisten] WiredTiger error (17) [1586546237:799215][29:0x7fe9f284fb00], connection: __posix_open_file, 667: /data/db/WiredTiger.wt: handle-open: open: File exists Raw: [1586546237:799215][29:0x7fe9f284fb00], connection: __posix_open_file, 667: /data/db/WiredTiger.wt: handle-open: open: File exists
2020-04-10T19:17:17.801+0000 I STORAGE [initandlisten] WiredTiger message unexpected file WiredTiger.wt found, renamed to WiredTiger.wt.2
2020-04-10T19:17:17.803+0000 E STORAGE [initandlisten] WiredTiger error (1) [1586546237:803211][29:0x7fe9f284fb00], connection: __posix_open_file, 667: /data/db/WiredTiger.wt: handle-open: open: Operation not permitted Raw: [1586546237:803211][29:0x7fe9f284fb00], connection: __posix_open_file, 667: /data/db/WiredTiger.wt: handle-open: open: Operation not permitted
2020-04-10T19:17:17.805+0000 W STORAGE [initandlisten] Failed to start up WiredTiger under any compatibility version.
2020-04-10T19:17:17.806+0000 F STORAGE [initandlisten] Reason: 1: Operation not permitted
2020-04-10T19:17:17.806+0000 F - [initandlisten] Fatal Assertion 28595 at src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp 860
我该如何解决这个问题?我想要一个 mongo 卷,它可以在容器出现故障时保留我的数据。
编辑:作为参考,我在 Windows 10 Pro
机器上 运行ning docker desktop 2.2.0.3
。
我通过在我的 docker-compose
文件中添加 volume
并在撰写文件的 mongo 部分引用它来解决这个问题,如下所示:
db:
image: mongo
container_name: mongo
volumes:
- mongodata:/data/db
ports:
- "27018:27017"
environment:
MONGO_INITDB_ROOT_USERNAME: admin
MONGO_INITDB_ROOT_PASSWORD: admin
MONGO_INITDB_DATABASE: golfStats
volumes:
mongodata:
我在使用 windows 10 时遇到了一些问题。
第一次成功。
docker run -d -p 27017:27017 -v /c/mongo_data:/data/db --name=container-mongodb mongo
停止容器 container-mongodb 后,当我尝试在 2nd 中启动容器 container-mongodb 时失败。
docker stop container-mongodb
docker start container-mongodb
docker logs container-mongodb
{"t":{"$date":"2021-10-09T09:40:38.082+00:00"},"s":"E", "c":"STORAGE", "id":22435, "ctx":"initandlisten","msg":"WiredTiger error","attr":{"error":1,"message":"[1633772438:82174][1:0x7f9b65426c80], file:WiredTiger.wt, connection: __posix_open_file, 805: /data/db/WiredTiger.wt: handle-open: open: Operation not permitted"}}
{"t":{"$date":"2021-10-09T09:40:38.098+00:00"},"s":"E", "c":"STORAGE", "id":22435, "ctx":"initandlisten","msg":"WiredTiger error","attr":{"error":1,"message":"[1633772438:98526][1:0x7f9b65426c80], file:WiredTiger.wt, connection: __posix_open_file, 805: /data/db/WiredTiger.wt: handle-open: open: Operation not permitted"}}
{"t":{"$date":"2021-10-09T09:40:38.115+00:00"},"s":"E", "c":"STORAGE", "id":22435, "ctx":"initandlisten","msg":"WiredTiger error","attr":{"error":1,"message":"[1633772438:115018][1:0x7f9b65426c80], file:WiredTiger.wt, connection: __posix_open_file, 805: /data/db/WiredTiger.wt: handle-open: open: Operation not permitted"}}
解决方案很相似,需要定义一个docker卷。并使用卷 mongodata 替换路径 /c/mongo_data。它在我想要第二个 docker 开始时起作用。
docker volume create --name=mongodata
docker run -d -p 27017:27017 -v mongodata:/data/db --name=container-mongodb mongo
更多详情参考Windows mount /data/db
没有更深入地了解为什么我的试验有效,但遵循 tutorial 并且我的 docker-compose 文件有:
mongo:
image: mongo:4.2.8
运行 docker image inspect <existing_mongo_image_id>
我的版本是最新的,即 "MONGO_VERSION=5.0.6"
.
更改我的撰写文件以反映此版本解决了我的问题,即
mongo:
image: mongo:5.0.6
我有以下 docker-compose
文件:
version: "3"
services:
#
# APIs
#----------------------------------------------
pokerstats:
image: pokerstats
container_name: pokerstats
ports:
- 8080:8080
depends_on:
- db
#
# Utilities
#----------------------------------------------
db:
image: mongo
container_name: mongo
volumes:
- ./data/db:/data/db
ports:
- "27018:27017"
environment:
MONGO_INITDB_ROOT_USERNAME: admin
MONGO_INITDB_ROOT_PASSWORD: admin
MONGO_INITDB_DATABASE: pokerStats
这在我添加 volumes
之前工作正常。但是,当我 运行: docker-compose up -d
时,mongo 容器会立即停止,并且在日志中我会看到错误:
2020-04-10T19:17:17.313+0000 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=1457M,cache_overflow=(file_max=0M),session_max=33000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000,close_scan_interval=10,close_handle_minimum=250),statistics_log=(wait=0),verbose=[recovery_progress,checkpoint_progress],
2020-04-10T19:17:17.772+0000 E STORAGE [initandlisten] WiredTiger error (1) [1586546237:772524][29:0x7fe9f284fb00], connection: __posix_open_file, 667: /data/db/WiredTiger.wt: handle-open: open: Operation not permitted Raw: [1586546237:772524][29:0x7fe9f284fb00], connection: __posix_open_file, 667: /data/db/WiredTiger.wt: handle-open: open: Operation not permitted
2020-04-10T19:17:17.784+0000 E STORAGE [initandlisten] WiredTiger error (17) [1586546237:784001][29:0x7fe9f284fb00], connection: __posix_open_file, 667: /data/db/WiredTiger.wt: handle-open: open: File exists Raw: [1586546237:784001][29:0x7fe9f284fb00], connection: __posix_open_file, 667: /data/db/WiredTiger.wt: handle-open: open: File exists
2020-04-10T19:17:17.785+0000 I STORAGE [initandlisten] WiredTiger message unexpected file WiredTiger.wt found, renamed to WiredTiger.wt.1
2020-04-10T19:17:17.788+0000 E STORAGE [initandlisten] WiredTiger error (1) [1586546237:788283][29:0x7fe9f284fb00], connection: __posix_open_file, 667: /data/db/WiredTiger.wt: handle-open: open: Operation not permitted Raw: [1586546237:788283][29:0x7fe9f284fb00], connection: __posix_open_file, 667: /data/db/WiredTiger.wt: handle-open: open: Operation not permitted
2020-04-10T19:17:17.799+0000 E STORAGE [initandlisten] WiredTiger error (17) [1586546237:799215][29:0x7fe9f284fb00], connection: __posix_open_file, 667: /data/db/WiredTiger.wt: handle-open: open: File exists Raw: [1586546237:799215][29:0x7fe9f284fb00], connection: __posix_open_file, 667: /data/db/WiredTiger.wt: handle-open: open: File exists
2020-04-10T19:17:17.801+0000 I STORAGE [initandlisten] WiredTiger message unexpected file WiredTiger.wt found, renamed to WiredTiger.wt.2
2020-04-10T19:17:17.803+0000 E STORAGE [initandlisten] WiredTiger error (1) [1586546237:803211][29:0x7fe9f284fb00], connection: __posix_open_file, 667: /data/db/WiredTiger.wt: handle-open: open: Operation not permitted Raw: [1586546237:803211][29:0x7fe9f284fb00], connection: __posix_open_file, 667: /data/db/WiredTiger.wt: handle-open: open: Operation not permitted
2020-04-10T19:17:17.805+0000 W STORAGE [initandlisten] Failed to start up WiredTiger under any compatibility version.
2020-04-10T19:17:17.806+0000 F STORAGE [initandlisten] Reason: 1: Operation not permitted
2020-04-10T19:17:17.806+0000 F - [initandlisten] Fatal Assertion 28595 at src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp 860
我该如何解决这个问题?我想要一个 mongo 卷,它可以在容器出现故障时保留我的数据。
编辑:作为参考,我在 Windows 10 Pro
机器上 运行ning docker desktop 2.2.0.3
。
我通过在我的 docker-compose
文件中添加 volume
并在撰写文件的 mongo 部分引用它来解决这个问题,如下所示:
db:
image: mongo
container_name: mongo
volumes:
- mongodata:/data/db
ports:
- "27018:27017"
environment:
MONGO_INITDB_ROOT_USERNAME: admin
MONGO_INITDB_ROOT_PASSWORD: admin
MONGO_INITDB_DATABASE: golfStats
volumes:
mongodata:
我在使用 windows 10 时遇到了一些问题。 第一次成功。
docker run -d -p 27017:27017 -v /c/mongo_data:/data/db --name=container-mongodb mongo
停止容器 container-mongodb 后,当我尝试在 2nd 中启动容器 container-mongodb 时失败。
docker stop container-mongodb
docker start container-mongodb
docker logs container-mongodb
{"t":{"$date":"2021-10-09T09:40:38.082+00:00"},"s":"E", "c":"STORAGE", "id":22435, "ctx":"initandlisten","msg":"WiredTiger error","attr":{"error":1,"message":"[1633772438:82174][1:0x7f9b65426c80], file:WiredTiger.wt, connection: __posix_open_file, 805: /data/db/WiredTiger.wt: handle-open: open: Operation not permitted"}}
{"t":{"$date":"2021-10-09T09:40:38.098+00:00"},"s":"E", "c":"STORAGE", "id":22435, "ctx":"initandlisten","msg":"WiredTiger error","attr":{"error":1,"message":"[1633772438:98526][1:0x7f9b65426c80], file:WiredTiger.wt, connection: __posix_open_file, 805: /data/db/WiredTiger.wt: handle-open: open: Operation not permitted"}}
{"t":{"$date":"2021-10-09T09:40:38.115+00:00"},"s":"E", "c":"STORAGE", "id":22435, "ctx":"initandlisten","msg":"WiredTiger error","attr":{"error":1,"message":"[1633772438:115018][1:0x7f9b65426c80], file:WiredTiger.wt, connection: __posix_open_file, 805: /data/db/WiredTiger.wt: handle-open: open: Operation not permitted"}}
解决方案很相似,需要定义一个docker卷。并使用卷 mongodata 替换路径 /c/mongo_data。它在我想要第二个 docker 开始时起作用。
docker volume create --name=mongodata
docker run -d -p 27017:27017 -v mongodata:/data/db --name=container-mongodb mongo
更多详情参考Windows mount /data/db
没有更深入地了解为什么我的试验有效,但遵循 tutorial 并且我的 docker-compose 文件有:
mongo:
image: mongo:4.2.8
运行 docker image inspect <existing_mongo_image_id>
我的版本是最新的,即 "MONGO_VERSION=5.0.6"
.
更改我的撰写文件以反映此版本解决了我的问题,即
mongo:
image: mongo:5.0.6