服务器关闭后无法连接到mongo

时间:2017-09-28 08:31:12

标签: linux mongodb

我在远程Ubuntu服务器上运行mongo集群(v 3.4.1)。该服务器昨天意外关闭。从那以后,我无法连接到mongo。

我通过ssh连接到服务器以检查mongo是否正在运行。似乎是这种情况,因为如果我使用mongo命令,我会得到以下输出:

MongoDB shell version v3.4.2
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.4.1
Server has startup warnings: 
2017-09-28T08:01:43.906+0000 I STORAGE  [initandlisten] 
2017-09-28T08:01:43.906+0000 I STORAGE  [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2017-09-28T08:01:43.906+0000 I STORAGE  [initandlisten] **          See http://dochub.mongodb.org/core/prodnotes-filesystem
2017-09-28T08:01:44.204+0000 I CONTROL  [initandlisten] 
2017-09-28T08:01:44.204+0000 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2017-09-28T08:01:44.204+0000 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2017-09-28T08:01:44.204+0000 I CONTROL  [initandlisten] 

现在,如果我运行“mongod”,我会得到例外:

...
2017-09-28T10:10:26.065+0200 I STORAGE  [initandlisten] exception in initAndListen: 20 Attempted to create a lock file on a read-only directory: /data/db, terminating
2017-09-28T10:10:26.065+0200 I NETWORK  [initandlisten] shutdown: going to close listening sockets...
...

我尝试了sudo模式,我得到了:

...
2017-09-28T10:12:21.857+0200 E NETWORK  [initandlisten] listen(): bind() failed Address already in use for socket: 0.0.0.0:27017
2017-09-28T10:12:21.857+0200 E NETWORK  [initandlisten]   addr already in use
2017-09-28T10:12:21.857+0200 E NETWORK  [initandlisten] Failed to set up sockets during startup.
2017-09-28T10:12:21.857+0200 E STORAGE  [initandlisten] Failed to set up listener: InternalError: Failed to set up sockets
2017-09-28T10:12:21.857+0200 I NETWORK  [initandlisten] shutdown: going to close listening sockets...
...

这意味着mongo的一个实例已经在运行......

然后,在列出sudo service mongod stop进程后,我尝试使用sudo pkill mongodsudo kill <PID>ps -ef | grep mongo杀死mongo进程。但是这个过程并没有从列表中消失(似乎它立即重新启动)。

因此,如果我尝试运行sudo mongod --dbpath /data/db --repair(目录中有一个mongod.lock文件),我仍然会收到错误“地址已在使用中”。

任何帮助都会非常感激!

0 个答案:

没有答案