在OpenShift上的MongoDB:/data/db/mongod.lock资源暂时不可用。

4
每次在OpenShift上部署MongoDB时,我都会收到如下错误信息:exception in initAndListen: 98 Unable to lock file: /data/db/mongod.lock Resource temporarily unavailable. Is a mongod instance already running?, terminating。 容器基于mongo:3.4,并将/data/db挂载为卷。
我尝试按照What is the use of the mongo.lock file?建议删除 /data/db/mongod.lock文件,但这没有起作用-现在我遇到了关于WiredTiger的错误。
有什么想法可以使它正常工作吗?
编辑:
以下是删除/data/db/mongod.lock后出现问题的日志。
2019-03-15T12:34:48.948+0000 I -        [initandlisten] Detected data files in /data/db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2019-03-15T12:34:48.949+0000 I STORAGE  [initandlisten] Detected WT journal files.  Running recovery from last checkpoint.
2019-03-15T12:34:48.950+0000 I STORAGE  [initandlisten] journal to nojournal transition config: create,cache_size=31644M,session_max=20000,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),checkpoint=(wait=60,log_size=2GB),statistics_log=(wait=0),verbose=(recovery_progress),
2019-03-15T12:34:48.955+0000 E STORAGE  [initandlisten] WiredTiger error (11) [1552653288:955084][8:0x7f91ef9a9d40], wiredtiger_open: /data/db/WiredTiger.lock: handle-lock: fcntl: Resource temporarily unavailable
2019-03-15T12:34:48.955+0000 E STORAGE  [initandlisten] WiredTiger error (16) [1552653288:955157][8:0x7f91ef9a9d40], wiredtiger_open: WiredTiger database is already being managed by another process: Device or resource busy
2019-03-15T12:34:48.957+0000 I -        [initandlisten] Assertion: 28718:16: Device or resource busy src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp 254
2019-03-15T12:34:48.971+0000 I STORAGE  [initandlisten] exception in initAndListen: 28718 16: Device or resource busy, terminating
2019-03-15T12:34:48.971+0000 I NETWORK  [initandlisten] shutdown: going to close listening sockets...
2019-03-15T12:34:48.971+0000 I NETWORK  [initandlisten] removing socket file: /tmp/mongodb-27017.sock
2019-03-15T12:34:48.971+0000 I NETWORK  [initandlisten] shutdown: going to flush diaglog...
2019-03-15T12:34:48.971+0000 I CONTROL  [initandlisten] now exiting
2019-03-15T12:34:48.971+0000 I CONTROL  [initandlisten] shutting down with code:100

这是 MongoDB 容器的配置

- image: 'mongo:3.4'
  command:
    - sh
  args:
    - '-c'
    - rm -f /data/db/mongod.lock; mongod --dbpath /data/db --repair; mongod --dbpath /data/db
  volumeMounts:
    - mountPath: /data/db

编辑2

首先,阅读此文以了解OpenShift如何终止容器:https://pracucci.com/graceful-shutdown-of-kubernetes-pods.html

我已删除了/data/db中的所有内容,然后更新了容器配置。

- image: 'mongo:3.4'
  command:
    - /bin/bash
  args:
    - '-c'
    - rm -f /data/db/mongod.lock /data/db/WiredTiger.lock; mongod
  volumeMounts:
    - mountPath: /data/db

之前的一系列测试部署都成功了。但在之后的几次部署中又开始出现问题,这一次是带有以下错误信息:
2019-03-15T14:25:05.657+0000 I CONTROL  [initandlisten] MongoDB starting : pid=8 port=27017 dbpath=/data/db 64-bit host=kx-api-staging-105-tbbh2
2019-03-15T14:25:05.657+0000 I CONTROL  [initandlisten] db version v3.4.19
2019-03-15T14:25:05.657+0000 I CONTROL  [initandlisten] git version: a2d97db8fe449d15eb8e275bbf318491781472bf
2019-03-15T14:25:05.657+0000 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.0.1t  3 May 2016
2019-03-15T14:25:05.657+0000 I CONTROL  [initandlisten] allocator: tcmalloc
2019-03-15T14:25:05.657+0000 I CONTROL  [initandlisten] modules: none
2019-03-15T14:25:05.657+0000 I CONTROL  [initandlisten] build environment:
2019-03-15T14:25:05.657+0000 I CONTROL  [initandlisten]     distmod: debian81
2019-03-15T14:25:05.657+0000 I CONTROL  [initandlisten]     distarch: x86_64
2019-03-15T14:25:05.657+0000 I CONTROL  [initandlisten]     target_arch: x86_64
2019-03-15T14:25:05.657+0000 I CONTROL  [initandlisten] options: {}
2019-03-15T14:25:05.726+0000 I -        [initandlisten] Detected data files in /data/db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2019-03-15T14:25:05.727+0000 I STORAGE  [initandlisten] wiredtiger_open config: create,cache_size=31644M,session_max=20000,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),checkpoint=(wait=60,log_size=2GB),statistics_log=(wait=0),verbose=(recovery_progress),
2019-03-15T14:25:05.785+0000 E STORAGE  [initandlisten] WiredTiger error (-31802) [1552659905:785255][8:0x7f1fb8b33d40], file:WiredTiger.wt, connection: unable to read root page from file:WiredTiger.wt: WT_ERROR: non-specific WiredTiger error
2019-03-15T14:25:05.785+0000 E STORAGE  [initandlisten] WiredTiger error (0) [1552659905:785313][8:0x7f1fb8b33d40], file:WiredTiger.wt, connection: WiredTiger has failed to open its metadata
2019-03-15T14:25:05.785+0000 E STORAGE  [initandlisten] WiredTiger error (0) [1552659905:785324][8:0x7f1fb8b33d40], file:WiredTiger.wt, connection: This may be due to the database files being encrypted, being from an older version or due to corruption on disk
2019-03-15T14:25:05.785+0000 E STORAGE  [initandlisten] WiredTiger error (0) [1552659905:785336][8:0x7f1fb8b33d40], file:WiredTiger.wt, connection: You should confirm that you have opened the database with the correct options including all encryption and compression options
2019-03-15T14:25:05.789+0000 I -        [initandlisten] Assertion: 28595:-31802: WT_ERROR: non-specific WiredTiger error src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp 277
2019-03-15T14:25:05.805+0000 I STORAGE  [initandlisten] exception in initAndListen: 28595 -31802: WT_ERROR: non-specific WiredTiger error, terminating
2019-03-15T14:25:05.805+0000 I NETWORK  [initandlisten] shutdown: going to close listening sockets...
2019-03-15T14:25:05.805+0000 I NETWORK  [initandlisten] removing socket file: /tmp/mongodb-27017.sock
2019-03-15T14:25:05.805+0000 I NETWORK  [initandlisten] shutdown: going to flush diaglog...
2019-03-15T14:25:05.805+0000 I CONTROL  [initandlisten] now exiting
2019-03-15T14:25:05.805+0000 I CONTROL  [initandlisten] shutting down with code:100

请参考 https://jira.mongodb.org/browse/SERVER-31124。 - Mani
1个回答

0
在我的情况下,它会出现以下错误信息: IllegalOperation: 尝试在只读目录 /data/db 上创建锁文件。

错误日志: {"t":{"$date":"2020-10-22T14:37:32.346+00:00"},"s":"I", "c":"CONTROL", "id":23285, "ctx":"main","msg":"自动禁用TLS 1.0,如果要强制启用TLS 1.0,请指定--sslDisabledProtocols 'none'"} {"t":{"$date":"2020-10-22T14:37:32.349+00:00"},"s":"W", "c":"ASIO", "id":22601, "ctx":"main","msg":"在NetworkInterface启动期间未配置TransportLayer"} {"t":{"$date":"2020-10-22T14:37:32.349+00:00"},"s":"I", "c":"NETWORK", "id":4648601, "ctx":"main","msg":"隐式TCP FastOpen不可用。如果需要TCP FastOpen,请设置tcpFastOpenServer、tcpFastOpenClient和tcpFastOpenQueueSize。"} {"t":{"$date":"2020-10-22T14:37:32.349+00:00"},"s":"I", "c":"STORAGE", "id":4615611, "ctx":"initandlisten","msg":"MongoDB启动中","attr":{"pid":1,"port":27017,"dbPath":"/data/db","architecture":"64位","host":"my-AppMgr-mongo-6c8c84d5d9-n52nt"}} {"t":{"$date":"2020-10-22T14:37:32.349+00:00"},"s":"I", "c":"CONTROL", "id":23403, "ctx":"initandlisten","msg":"构建信息","attr":{"buildInfo":{"version":"4.4.1","gitVersion":"ad91a93a5a31e175f5cbf8c69561e788bbc55ce1","openSSLVersion":"OpenSSL 1.1.1 11 Sep 2018","modules":[],"allocator":"tcmalloc","environment":{"distmod":"ubuntu1804","distarch":"x86_64","target_arch":"x86_64"}}}} {"t":{"$date":"2020-10-22T14:37:32.349+00:00"},"s":"I", "c":"CONTROL", "id":51765, "ctx":"initandlisten","msg":"操作系统","attr":{"os":{"name":"Ubuntu","version":"18.04"}}} {"t":{"$date":"2020-10-22T14:37:32.350+00:00"},"s":"I", "c":"CONTROL", "id":21951, "ctx":"initandlisten","msg":"命令行设置的选项","attr":{"options":{"net":{"bindIp":""}}}} {"t":{"$date":"2020-10-22T14:37:32.351+00:00"},"s":"E", "c":"STORAGE", "id":20557, "ctx":"initandlisten","msg":"在initAndListen中发生DBException,终止","attr":{"error":"IllegalOperation: 尝试在只读目录/data/db上创建锁文件"}}* {"t":{"$date":"2020-10-22T14:37:32.351+00:00"},"s":"I", "c":"REPL", "id":4784900, "ctx":"initandlisten","msg":"为关闭而降级ReplicationCoordinator","attr":{"waitTimeMillis":10000}} {"t":{"$date":"2020-10-22T14:37:32.351+00:00"},"s":"I", "c":"COMMAND", "id":4784901, "ctx":"initandlisten","msg":"关闭MirrorMaestro"} {"t":{"$date":"2020-10-22T14:37:32.352+00:00"},"s":"I", "c":"SHARDING", "id":4784902, "ctx":"initandlisten","msg":"关闭WaitForMajorityService"} {"t":{"$date":"2020-10-22T14:37:32.352+00:00"},"s":"I", "c":"NETWORK", "id":20562, "ctx":"initandlisten","msg":"关闭:即将关闭监听套接字"} {"t":{"$date":"2020-10-


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接