Невозможно заблокировать файл: /var/lib/mongodb/mongod.lock Ресурс временно недоступен
Я установил Mongod на машину с Ubuntu 16.04 и могу запустить / остановить, используя следующие команды
service mongod start
service mongod stop
Теперь я хочу запустить mongod при перезапуске Ubuntu VM и использую следующее
systemctl enable mongod
/etc/systemd/system/mongodb.service
[Unit]
Description=High-performance, schema-free document-oriented database
After=network.target
[Service]
User=mongodb
ExecStart=/usr/bin/mongod --config /etc/mongod.conf
[Install]
WantedBy=multi-user.target
Когда я перезагружаю Ubuntu VM, я вижу следующую ошибку в /var/log/mongodb/mongod.log
2017-11-24T10:10:42.324+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2g 1 Mar 2016
2017-11-24T10:10:42.324+0000 I CONTROL [initandlisten] allocator: tcmalloc
2017-11-24T10:10:42.324+0000 I CONTROL [initandlisten] modules: none
2017-11-24T10:10:42.324+0000 I CONTROL [initandlisten] build environment:
2017-11-24T10:10:42.324+0000 I CONTROL [initandlisten] distmod: ubuntu1604
2017-11-24T10:10:42.324+0000 I CONTROL [initandlisten] distarch: x86_64
2017-11-24T10:10:42.324+0000 I CONTROL [initandlisten] target_arch: x86_64
2017-11-24T10:10:42.324+0000 I CONTROL [initandlisten] options: { config: "/etc/mongod.conf", net: { bindIp: "127.0.0.1", port: 27017 }, storage: { dbPath: "/var/lib/mongodb", engine: "wiredTiger", journal: { enabled: true }, wiredTiger: { engineConfig: { cacheSizeGB: 2.0 } } }, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongod.log" } }
2017-11-24T10:10:42.328+0000 I STORAGE [initandlisten] exception in initAndListen: 98 Unable to lock file: /var/lib/mongodb/mongod.lock Resource temporarily unavailable. Is a mongod instance already running?, terminating
2017-11-24T10:10:42.328+0000 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2017-11-24T10:10:42.328+0000 I NETWORK [initandlisten] shutdown: going to flush diaglog...
2017-11-24T10:10:42.328+0000 I CONTROL [initandlisten] now exiting
2017-11-24T10:10:42.328+0000 I CONTROL [initandlisten] shutting down with code:100
2017-11-24T10:10:43.110+0000 I CONTROL [initandlisten]
2017-11-24T10:10:43.110+0000 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2017-11-24T10:10:43.110+0000 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2017-11-24T10:10:43.110+0000 I CONTROL [initandlisten]
2017-11-24T10:10:43.111+0000 I CONTROL [initandlisten]
2017-11-24T10:10:43.111+0000 I CONTROL [initandlisten] ** WARNING: You are running on a NUMA machine.
2017-11-24T10:10:43.111+0000 I CONTROL [initandlisten] ** We suggest launching mongod like this to avoid performance problems:
2017-11-24T10:10:43.111+0000 I CONTROL [initandlisten] ** numactl --interleave=all mongod [other options]
2017-11-24T10:10:43.111+0000 I CONTROL [initandlisten]
2017-11-24T10:10:43.141+0000 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/var/lib/mongodb/diagnostic.data'
2017-11-24T10:10:43.142+0000 I NETWORK [thread1] waiting for connections on port 27017
2017-11-24T10:10:48.088+0000 I NETWORK [thread1] connection accepted from 127.0.0.1:41828 #1 (1 connection now open)
2017-11-24T10:10:48.101+0000 I NETWORK [conn1] received client metadata from 127.0.0.1:41828 conn1: { driver: { name: "mongo-java-driver", version: "3.4.1" }, os: { type: "Linux", name: "Linux", architecture: "amd64", version: "4.4.0-98-generic" }, platform: "Java/Oracle Corporation/1.8.0_151-b12" }
2017-11-24T10:10:48.187+0000 I NETWORK [thread1] connection accepted from 127.0.0.1:41830 #2 (2 connections now open)
2017-11-24T10:10:48.188+0000 I NETWORK [conn2] received client metadata from 127.0.0.1:41830 conn2: { driver: { name: "mongo-java-driver", version: "3.4.1" }, os: { type: "Linux", name: "Linux", architecture: "amd64", version: "4.4.0-98-generic" }, platform: "Java/Oracle Corporation/1.8.0_151-b12" }
2017-11-24T10:26:04.334+0000 I NETWORK [thread1] connection accepted from 127.0.0.1:43938 #3 (3 connections now open)
2017-11-24T10:26:04.335+0000 I NETWORK [conn3] received client metadata from 127.0.0.1:43938 conn3: { driver: { name: "mongo-java-driver", version: "3.4.1" }, os: { type: "Linux", name: "Linux", architecture: "amd64", version: "4.4.0-98-generic" }, platform: "Java/Oracle Corporation/1.8.0_151-b12" }
Как это решить?