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

时间:2019-03-15 12:32:13

标签: mongodb openshift

在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作为卷安装。

我尝试删除/data/db/mongod.lock,建议由 What is the use of the mongo.lock file?。无济于事-现在我遇到关于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

1 个答案:

答案 0 :(得分:0)

在我的情况下,tt失败并显示以下消息: IllegalOperation:尝试在只读目录/ data / db

上创建锁定文件

elrrorLog: {“ 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”,“体系结构”:“ 64位“,”主机“:” my-AppMgr-mongo-6c8c84d5d9-n52nt“}} {“ t”:{“ $ date”:“ 2020-10-22T14:37:32.349 + 00:00”},“ s”:“ I”,“ c”:“ CONTROL”,“ id”:23403, “ ctx”:“ initandlisten”,“ msg”:“ Build Info”,“ attr”:{“ buildInfo”:{“ version”:“ 4.4.1”,“ gitVersion”:“ ad91a93a5a31e175f5cbf8c69561e788bbc55ce1”,“ openSSLVersion”:“ OpenSSL 1.1.1 2018年9月11日“,”模块“:[],”分配器“:” tcmalloc“,”环境“:{” 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-22T14:37:32.352 + 00:00”},“ s”:“ I”,“ c”:“ NETWORK”,“ id”:4784905, “ ctx”:“ initandlisten”,“ msg”:“关闭全局连接池”} {“ t”:{“ $ date”:“ 2020-10-22T14:37:32.352 + 00:00”},“ s”:“ I”,“ c”:“ STORAGE”,“ id”:4784906, “ ctx”:“ initandlisten”,“ msg”:“关闭FlowControlTicketholder”} {“ t”:{“ $ date”:“ 2020-10-22T14:37:32.352 + 00:00”},“ s”:“ I”,“ c”:“-”,“ id”:20520, “ ctx”:“ initandlisten”,“ msg”:“停止进一步的Flow Control票证获取。”} {“ t”:{“ $ date”:“ 2020-10-22T14:37:32.352 + 00:00”},“ s”:“ I”,“ c”:“ NETWORK”,“ id”:4784918, “ ctx”:“ initandlisten”,“ msg”:“关闭ReplicaSetMonitor”} {“ t”:{“ $ date”:“ 2020-10-22T14:37:32.352 + 00:00”},“ s”:“ I”,“ c”:“ SHARDING”,“ id”:4784921, “ ctx”:“ initandlisten”,“ msg”:“关闭MigrationUtilExecutor”} {“ t”:{“ $ date”:“ 2020-10-22T14:37:32.352 + 00:00”},“ s”:“ I”,“ c”:“ CONTROL”,“ id”:4784925, “ ctx”:“ initandlisten”,“ msg”:“关闭免费监视”} {“ t”:{“ $ date”:“ 2020-10-22T14:37:32.352 + 00:00”},“ s”:“ I”,“ c”:“ FTDC”,“ id”:4784926, “ ctx”:“ initandlisten”,“ msg”:“关闭全时数据捕获”} {“ t”:{“ $ date”:“ 2020-10-22T14:37:32.352 + 00:00”},“ s”:“ I”,“ c”:“ STORAGE”,“ id”:4784927, “ ctx”:“ initandlisten”,“ msg”:“关闭HealthLog”} {“ t”:{“ $ date”:“ 2020-10-22T14:37:32.352 + 00:00”},“ s”:“ I”,“ c”:“ STORAGE”,“ id”:4784929, “ ctx”:“ initandlisten”,“ msg”:“获取用于关闭的全局锁”} {“ t”:{“ $ date”:“ 2020-10-22T14:37:32.352 + 00:00”},“ s”:“ I”,“ c”:“-”,“ id”:4784931, “ ctx”:“ initandlisten”,“ msg”:“删除范围缓存以进行关闭”} {“ t”:{“ $ date”:“ 2020-10-22T14:37:32.352 + 00:00”},“ s”:“ I”,“ c”:“ CONTROL”,“ id”:20565, “ ctx”:“ initandlisten”,“ msg”:“现在退出”} {“ t”:{“ $ date”:“ 2020-10-22T14:37:32.352 + 00:00”},“ s”:“ I”,“ c”:“ CONTROL”,“ id”:23138, “ ctx”:“ initandlisten”,“ msg”:“关机”,“ attr”:{“ exitCode”:100}}