1. 发现公司的一个数据服务器,mongodb 无法qidong

运行 service mongod start 出现如下错误

[root@CNSHAS-JD05 mongo]# service mongod start
Starting mongod: about to fork child process, waiting until server is ready for connections.
forked process: 2484
all output going to: /var/log/mongo/mongod.log
ERROR: child process failed, exited with error number 100
                                                           [FAILED]
  1. 删除了 /var/lib/mongo/mongod.lock后,尝试启动,依旧无法启动
[root@CNSHAS-JD05 lib]# service mongod start
Starting mongod: about to fork child process, waiting until server is ready for connections.
forked process: 2336
all output going to: /var/log/mongo/mongod.log
ERROR: child process failed, exited with error number 45
                                                           [FAILED]
  1. 以repair 模式启动
mongod -f /etc/mongod.conf --repair

/etc/mongod.conf 是mongo的配置文件

[root@CNSHAS-JD05 mongo]# mongod -f /etc/mongod.conf --repair
about to fork child process, waiting until server is ready for connections.
forked process: 2515
all output going to: /var/log/mongo/mongod.log
child process started successfully, parent exiting

其实此处可以看到运行状态已经是start状态

  1. 然后使用命令
mongod -f /etc/mongod.conf

再次启动一次

[root@CNSHAS-JD05 mongo]# mongod -f /etc/mongod.conf
about to fork child process, waiting until server is ready for connections.
forked process: 2527
all output going to: /var/log/mongo/mongod.log
child process started successfully, parent exiting
  1. 然后查看mongo的运行情况
[root@CNSHAS-JD05 mongo]# ps -ef|grep mongo*
root      2527     1  0 17:34 ?        00:00:00 mongod -f /etc/mongod.conf
root      2549  1985  0 17:35 pts/0    00:00:00 grep mongo*
  1. 此次出错的参考日志:
***** SERVER RESTARTED *****


Wed Jul 13 17:13:02.739 versionArrayTest passed
Wed Jul 13 17:13:02.741 shardKeyTest passed
Wed Jul 13 17:13:02.741 isInRangeTest passed
Wed Jul 13 17:13:02.741 shardObjTest passed
Wed Jul 13 17:13:02.742 BackgroundJob starting: DataFileSync
Wed Jul 13 17:13:02.754 [initandlisten] MongoDB starting : pid=2248 port=27017 dbpath=/var/lib/mongo 64-bit host=CNSHAS-JD05
Wed Jul 13 17:13:02.754 [initandlisten] db version v2.4.8
Wed Jul 13 17:13:02.754 [initandlisten] git version: a350fc38922fbda2cec8d5dd842237b904eafc14
Wed Jul 13 17:13:02.754 [initandlisten] build info: Linux ip-10-2-29-40 2.6.21.7-2.ec2.v1.2.fc8xen #1 SMP Fri Nov 20 17:48:28 EST 2009 x86_64 BOOST_LIB_VERSION=1_49
Wed Jul 13 17:13:02.754 [initandlisten] allocator: tcmalloc
Wed Jul 13 17:13:02.754 [initandlisten] options: { config: "/etc/mongod.conf", dbpath: "/var/lib/mongo", fork: "true", journal: true, logappend: "true", logpath: "/var/log/mongo/mongod.log", pidfilepath: "/var/run/mongodb/mongod.pid", verbose: "true" }
Wed Jul 13 17:13:02.786 [initandlisten] User Assertion: 10309:Unable to create/open lock file: /var/lib/mongo/mongod.lock errno:13 Permission denied Is a mongod instance already running?
Wed Jul 13 17:13:02.842 [initandlisten] exception in initAndListen: 10309 Unable to create/open lock file: /var/lib/mongo/mongod.lock errno:13 Permission denied Is a mongod instance already running?, terminating
Wed Jul 13 17:13:02.843 dbexit:
Wed Jul 13 17:13:02.843 [initandlisten] shutdown: going to close listening sockets...
Wed Jul 13 17:13:02.843 [initandlisten] shutdown: going to flush diaglog...
Wed Jul 13 17:13:02.843 [initandlisten] shutdown: going to close sockets...
Wed Jul 13 17:13:02.843 [initandlisten] shutdown: waiting for fs preallocator...
Wed Jul 13 17:13:02.843 [initandlisten] shutdown: lock for final commit...
Wed Jul 13 17:13:02.843 [initandlisten] shutdown: final commit...
Wed Jul 13 17:13:02.843 [initandlisten] shutdown: closing all files...
Wed Jul 13 17:13:02.843 [initandlisten] closeAllFiles() finished
Wed Jul 13 17:13:02.843 [initandlisten] shutdown: removing fs lock...
Wed Jul 13 17:13:02.843 [initandlisten] couldn't remove fs lock errno:9 Bad file descriptor
Wed Jul 13 17:13:02.843 dbexit: really exiting now


***** SERVER RESTARTED *****


Wed Jul 13 17:13:55.434 versionArrayTest passed
Wed Jul 13 17:13:55.435 BackgroundJob starting: DataFileSync
Wed Jul 13 17:13:55.436 shardKeyTest passed
Wed Jul 13 17:13:55.436 isInRangeTest passed
Wed Jul 13 17:13:55.436 shardObjTest passed
Wed Jul 13 17:13:55.447 [initandlisten] MongoDB starting : pid=2274 port=27017 dbpath=/var/lib/mongo 64-bit host=CNSHAS-JD05
Wed Jul 13 17:13:55.448 [initandlisten] db version v2.4.8
Wed Jul 13 17:13:55.448 [initandlisten] git version: a350fc38922fbda2cec8d5dd842237b904eafc14
Wed Jul 13 17:13:55.448 [initandlisten] build info: Linux ip-10-2-29-40 2.6.21.7-2.ec2.v1.2.fc8xen #1 SMP Fri Nov 20 17:48:28 EST 2009 x86_64 BOOST_LIB_VERSION=1_49
Wed Jul 13 17:13:55.448 [initandlisten] allocator: tcmalloc
Wed Jul 13 17:13:55.448 [initandlisten] options: { config: "/etc/mongod.conf", dbpath: "/var/lib/mongo", fork: "true", journal: true, logappend: "true", logpath: "/var/log/mongo/mongod.log", pidfilepath: "/var/run/mongodb/mongod.pid", verbose: "true" }
Wed Jul 13 17:13:55.459 [initandlisten] flushing directory /var/lib/mongo
Wed Jul 13 17:13:55.470 [initandlisten] journal dir=/var/lib/mongo/journal
Wed Jul 13 17:13:55.470 [initandlisten] recover : no journal files present, no recovery needed
Wed Jul 13 17:13:55.470 [initandlisten] flushing directory /var/lib/mongo/journal
Wed Jul 13 17:13:55.537 [initandlisten] flushing directory /var/lib/mongo/journal
Wed Jul 13 17:13:55.544 [initandlisten] flushing directory /var/lib/mongo/journal
Wed Jul 13 17:13:55.550 [initandlisten] opening db:  local
Wed Jul 13 17:13:55.551 [initandlisten] couldn't open /var/lib/mongo/local.ns errno:13 Permission denied
Wed Jul 13 17:13:55.551 [initandlisten] error couldn't open file /var/lib/mongo/local.ns terminating
Wed Jul 13 17:13:55.551 dbexit:
Wed Jul 13 17:13:55.551 [initandlisten] shutdown: going to close listening sockets...
Wed Jul 13 17:13:55.551 [initandlisten] shutdown: going to flush diaglog...
Wed Jul 13 17:13:55.551 [initandlisten] shutdown: going to close sockets...
Wed Jul 13 17:13:55.551 [initandlisten] shutdown: waiting for fs preallocator...
Wed Jul 13 17:13:55.551 [initandlisten] shutdown: lock for final commit...
Wed Jul 13 17:13:55.551 [initandlisten] shutdown: final commit...
Wed Jul 13 17:13:55.551 [initandlisten] shutdown: closing all files...
Wed Jul 13 17:13:55.551 [initandlisten] closeAllFiles() finished
Wed Jul 13 17:13:55.551 [initandlisten] journalCleanup...
Wed Jul 13 17:13:55.551 [initandlisten] removeJournalFiles
Wed Jul 13 17:13:55.551 [initandlisten] flushing directory /var/lib/mongo/journal
Wed Jul 13 17:13:55.553 [initandlisten] removeJournalFiles end
Wed Jul 13 17:13:55.553 [initandlisten] shutdown: removing fs lock...
Wed Jul 13 17:13:55.553 dbexit: really exiting now


***** SERVER RESTARTED *****


Wed Jul 13 17:14:32.073 versionArrayTest passed
Wed Jul 13 17:14:32.075 shardKeyTest passed
Wed Jul 13 17:14:32.075 isInRangeTest passed
Wed Jul 13 17:14:32.075 shardObjTest passed
Wed Jul 13 17:14:32.076 BackgroundJob starting: DataFileSync
Wed Jul 13 17:14:32.087 [initandlisten] MongoDB starting : pid=2298 port=27017 dbpath=/var/lib/mongo 64-bit host=CNSHAS-JD05
Wed Jul 13 17:14:32.087 [initandlisten] db version v2.4.8
Wed Jul 13 17:14:32.087 [initandlisten] git version: a350fc38922fbda2cec8d5dd842237b904eafc14
Wed Jul 13 17:14:32.087 [initandlisten] build info: Linux ip-10-2-29-40 2.6.21.7-2.ec2.v1.2.fc8xen #1 SMP Fri Nov 20 17:48:28 EST 2009 x86_64 BOOST_LIB_VERSION=1_49
Wed Jul 13 17:14:32.087 [initandlisten] allocator: tcmalloc
Wed Jul 13 17:14:32.087 [initandlisten] options: { config: "/etc/mongod.conf", dbpath: "/var/lib/mongo", fork: "true", journal: true, logappend: "true", logpath: "/var/log/mongo/mongod.log", pidfilepath: "/var/run/mongodb/mongod.pid", verbose: "true" }
Wed Jul 13 17:14:32.090 [initandlisten] flushing directory /var/lib/mongo
Wed Jul 13 17:14:32.094 [initandlisten] journal dir=/var/lib/mongo/journal
Wed Jul 13 17:14:32.094 [initandlisten] recover : no journal files present, no recovery needed
Wed Jul 13 17:14:32.095 [initandlisten] flushing directory /var/lib/mongo/journal
Wed Jul 13 17:14:32.178 [initandlisten] flushing directory /var/lib/mongo/journal
Wed Jul 13 17:14:32.186 [initandlisten] flushing directory /var/lib/mongo/journal
Wed Jul 13 17:14:32.192 [initandlisten] opening db:  local
Wed Jul 13 17:14:32.192 [initandlisten] couldn't open /var/lib/mongo/local.ns errno:13 Permission denied
Wed Jul 13 17:14:32.192 [initandlisten] error couldn't open file /var/lib/mongo/local.ns terminating
Wed Jul 13 17:14:32.192 dbexit:
Wed Jul 13 17:14:32.192 [initandlisten] shutdown: going to close listening sockets...
Wed Jul 13 17:14:32.192 [initandlisten] shutdown: going to flush diaglog...
Wed Jul 13 17:14:32.192 [initandlisten] shutdown: going to close sockets...
Wed Jul 13 17:14:32.192 [initandlisten] shutdown: waiting for fs preallocator...
Wed Jul 13 17:14:32.193 [initandlisten] shutdown: lock for final commit...
Wed Jul 13 17:14:32.193 [initandlisten] shutdown: final commit...
Wed Jul 13 17:14:32.193 [initandlisten] shutdown: closing all files...
Wed Jul 13 17:14:32.193 [initandlisten] closeAllFiles() finished
Wed Jul 13 17:14:32.193 [initandlisten] journalCleanup...
Wed Jul 13 17:14:32.193 [initandlisten] removeJournalFiles
Wed Jul 13 17:14:32.193 [initandlisten] flushing directory /var/lib/mongo/journal
Wed Jul 13 17:14:32.194 [initandlisten] removeJournalFiles end
Wed Jul 13 17:14:32.194 [initandlisten] shutdown: removing fs lock...
Wed Jul 13 17:14:32.194 dbexit: really exiting now