MongoDB в OpenShift: /data/db/mongod.lock Ресурс временно недоступен - PullRequest
3 голосов
/ 15 марта 2019

Я продолжаю получать exception in initAndListen: 98 Unable to lock file: /data/db/mongod.lock Resource temporarily unavailable. Is a mongod instance already running?, terminating после нового развертывания MongoDB в OpenShift.Контейнер основан на mongo:3.4, а /data/db смонтирован как том.

Я пытался удалить /data/db/mongod.lock, как предложено Для чего нужен файл mongo.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
...