我在调试为什么我的MongoDB不能作为一项服务启动时遇到了一些麻烦。正常启动(只是运行" mongod")似乎工作正常。但是,当我将其作为服务运行时,会生成以下日志。我已经尝试从谷歌搜索中删除fslock和更改几个目录的所有权,但我被卡住了。
/ data / db的所有权如下:
root@debian:/home/sjohnson# ls -ld /data/db
drwxr-xr-x 4 mongodb mongodb 4096 Sep 26 17:18 /data/db
同样,这是/ var / lib / mongod:
root@debian:/home/sjohnson# ls -ld /var/lib/mongodb
drwxr-xr-x 3 mongodb mongodb 4096 Sep 26 16:54 /var/lib/mongodb
这是日志文件:
root@debian:/home/sjohnson# sudo -u mongodb mongod --dbpath /var/lib/mongodb/
Sat Sep 26 17:27:11 [initandlisten] MongoDB starting : pid=5615 port=27017 dbpath=/var/lib/mongodb/ 64-bit host=debian
Sat Sep 26 17:27:11 [initandlisten] db version v2.0.6, pdfile version 4.5
Sat Sep 26 17:27:11 [initandlisten] git version: nogitversion
Sat Sep 26 17:27:11 [initandlisten] build info: Linux z6 3.8-trunk-amd64 #1 SMP Debian 3.8.3-1~experimental.1 x86_64 BOOST_LIB_VERSION=1_49
Sat Sep 26 17:27:11 [initandlisten] options: { dbpath: "/var/lib/mongodb/" }
Sat Sep 26 17:27:11 [initandlisten] journal dir=/var/lib/mongodb/journal
Sat Sep 26 17:27:11 [initandlisten] recover : no journal files present, no recovery needed
Sat Sep 26 17:27:11 [initandlisten] ****
Sat Sep 26 17:27:11 [initandlisten] ****
Sat Sep 26 17:27:11 [initandlisten] need to upgrade database SteveIsAwesome with pdfile version 4.22, new version: 4.5
Sat Sep 26 17:27:11 [initandlisten] Not upgrading, exiting
Sat Sep 26 17:27:11 [initandlisten] run --upgrade to upgrade dbs, then start again
Sat Sep 26 17:27:11 [initandlisten] ****
Sat Sep 26 17:27:11 dbexit:
Sat Sep 26 17:27:11 [initandlisten] shutdown: going to close listening sockets...
Sat Sep 26 17:27:11 [initandlisten] shutdown: going to flush diaglog...
Sat Sep 26 17:27:11 [initandlisten] shutdown: going to close sockets...
Sat Sep 26 17:27:11 [initandlisten] shutdown: waiting for fs preallocator...
Sat Sep 26 17:27:11 [initandlisten] shutdown: lock for final commit...
Sat Sep 26 17:27:11 [initandlisten] shutdown: final commit...
Sat Sep 26 17:27:11 [initandlisten] shutdown: closing all files...
Sat Sep 26 17:27:11 [initandlisten] closeAllFiles() finished
Sat Sep 26 17:27:11 [initandlisten] journalCleanup...
Sat Sep 26 17:27:11 [initandlisten] removeJournalFiles
Sat Sep 26 17:27:11 [initandlisten] shutdown: removing fs lock...
Sat Sep 26 17:27:11 dbexit: really exiting now
Logstream::get called in uninitialized state
Sat Sep 26 17:27:11 [initandlisten] ERROR: Client::~Client _context should be null but is not; client:initandlisten
root@debian:/home/sjohnson# tail -f -n50 /var/log/mongodb/mongodb.log
Sat Sep 26 17:25:00 [initandlisten] MongoDB starting : pid=5318 port=27017 dbpath=/var/lib/mongodb 64-bit host=debian
Sat Sep 26 17:25:00 [initandlisten] db version v2.0.6, pdfile version 4.5
Sat Sep 26 17:25:00 [initandlisten] git version: nogitversion
Sat Sep 26 17:25:00 [initandlisten] build info: Linux z6 3.8-trunk-amd64 #1 SMP Debian 3.8.3-1~experimental.1 x86_64 BOOST_LIB_VERSION=1_49
Sat Sep 26 17:25:00 [initandlisten] options: { bind_ip: "127.0.0.1", command: [ "run" ], config: "/etc/mongodb.conf", dbpath: "/var/lib/mongodb", journal: "true", logappend: "true", logpath: "/var/log/mongodb/mongodb.log", unixSocketPrefix: "/var/run/mongodb" }
Sat Sep 26 17:25:00 [initandlisten] journal dir=/var/lib/mongodb/journal
Sat Sep 26 17:25:00 [initandlisten] recover : no journal files present, no recovery needed
Sat Sep 26 17:25:00 [initandlisten] ****
Sat Sep 26 17:25:00 [initandlisten] ****
Sat Sep 26 17:25:00 [initandlisten] need to upgrade database SteveIsAwesome with pdfile version 4.22, new version: 4.5
Sat Sep 26 17:25:00 [initandlisten] Not upgrading, exiting
Sat Sep 26 17:25:00 [initandlisten] run --upgrade to upgrade dbs, then start again
Sat Sep 26 17:25:00 [initandlisten] ****
Sat Sep 26 17:25:00 dbexit:
Sat Sep 26 17:25:00 [initandlisten] shutdown: going to close listening sockets...
Sat Sep 26 17:25:00 [initandlisten] shutdown: going to flush diaglog...
Sat Sep 26 17:25:00 [initandlisten] shutdown: going to close sockets...
Sat Sep 26 17:25:00 [initandlisten] shutdown: waiting for fs preallocator...
Sat Sep 26 17:25:00 [initandlisten] shutdown: lock for final commit...
Sat Sep 26 17:25:00 [initandlisten] shutdown: final commit...
Sat Sep 26 17:25:00 [initandlisten] shutdown: closing all files...
Sat Sep 26 17:25:00 [initandlisten] closeAllFiles() finished
Sat Sep 26 17:25:00 [initandlisten] journalCleanup...
Sat Sep 26 17:25:00 [initandlisten] removeJournalFiles
Sat Sep 26 17:25:00 [initandlisten] shutdown: removing fs lock...
Sat Sep 26 17:25:00 dbexit: really exiting now
Logstream::get called in uninitialized state
Sat Sep 26 17:25:00 [initandlisten] ERROR: Client::~Client _context should be null but is not; client:initandlisten
编辑:
更新:使用mongod升级每个评论的数据库--upgrade。没有显示错误:
root@debian:/var/lib/mongodb# tail -f -n50 /var/log/mongodb/mongodb.log
Sat Sep 26 17:25:00 [initandlisten] run --upgrade to upgrade dbs, then start again
Sat Sep 26 17:25:00 [initandlisten] ****
Sat Sep 26 17:25:00 dbexit:
Sat Sep 26 17:25:00 [initandlisten] shutdown: going to close listening sockets...
Sat Sep 26 17:25:00 [initandlisten] shutdown: going to flush diaglog...
Sat Sep 26 17:25:00 [initandlisten] shutdown: going to close sockets...
Sat Sep 26 17:25:00 [initandlisten] shutdown: waiting for fs preallocator...
Sat Sep 26 17:25:00 [initandlisten] shutdown: lock for final commit...
Sat Sep 26 17:25:00 [initandlisten] shutdown: final commit...
Sat Sep 26 17:25:00 [initandlisten] shutdown: closing all files...
Sat Sep 26 17:25:00 [initandlisten] closeAllFiles() finished
Sat Sep 26 17:25:00 [initandlisten] journalCleanup...
Sat Sep 26 17:25:00 [initandlisten] removeJournalFiles
Sat Sep 26 17:25:00 [initandlisten] shutdown: removing fs lock...
Sat Sep 26 17:25:00 dbexit: really exiting now
Logstream::get called in uninitialized state
Sat Sep 26 17:25:00 [initandlisten] ERROR: Client::~Client _context should be null but is not; client:initandlisten
但服务仍无法启动。尾巴表演:
root@debian:/var/lib/mongodb# tail -f -n50 /var/log/mongodb/mongodb.log
Sat Sep 26 17:49:52 [initandlisten] run --upgrade to upgrade dbs, then start again
Sat Sep 26 17:49:52 [initandlisten] ****
Sat Sep 26 17:49:52 dbexit:
Sat Sep 26 17:49:52 [initandlisten] shutdown: going to close listening sockets...
Sat Sep 26 17:49:52 [initandlisten] shutdown: going to flush diaglog...
Sat Sep 26 17:49:52 [initandlisten] shutdown: going to close sockets...
Sat Sep 26 17:49:52 [initandlisten] shutdown: waiting for fs preallocator...
Sat Sep 26 17:49:52 [initandlisten] shutdown: lock for final commit...
Sat Sep 26 17:49:52 [initandlisten] shutdown: final commit...
Sat Sep 26 17:49:52 [initandlisten] shutdown: closing all files...
Sat Sep 26 17:49:52 [initandlisten] closeAllFiles() finished
Sat Sep 26 17:49:52 [initandlisten] journalCleanup...
Sat Sep 26 17:49:52 [initandlisten] removeJournalFiles
Sat Sep 26 17:49:52 [initandlisten] shutdown: removing fs lock...
Sat Sep 26 17:49:52 dbexit: really exiting now
Logstream::get called in uninitialized state
Sat Sep 26 17:49:52 [initandlisten] ERROR: Client::~Client _context should be null but is not; client:initandlisten
***** SERVER RESTARTED *****
Sat Sep 26 17:50:30 [initandlisten] MongoDB starting : pid=9104 port=27017 dbpath=/var/lib/mongodb 64-bit host=debian
Sat Sep 26 17:50:30 [initandlisten] db version v2.0.6, pdfile version 4.5
Sat Sep 26 17:50:30 [initandlisten] git version: nogitversion
Sat Sep 26 17:50:30 [initandlisten] build info: Linux z6 3.8-trunk-amd64 #1 SMP Debian 3.8.3-1~experimental.1 x86_64 BOOST_LIB_VERSION=1_49
Sat Sep 26 17:50:30 [initandlisten] options: { bind_ip: "127.0.0.1", command: [ "run" ], config: "/etc/mongodb.conf", dbpath: "/var/lib/mongodb", journal: "true", logappend: "true", logpath: "/var/log/mongodb/mongodb.log", unixSocketPrefix: "/var/run/mongodb" }
Sat Sep 26 17:50:30 [initandlisten] journal dir=/var/lib/mongodb/journal
Sat Sep 26 17:50:30 [initandlisten] recover : no journal files present, no recovery needed
Sat Sep 26 17:50:30 [initandlisten] ****
Sat Sep 26 17:50:30 [initandlisten] ****
Sat Sep 26 17:50:30 [initandlisten] need to upgrade database local with pdfile version 4.22, new version: 4.5
Sat Sep 26 17:50:30 [initandlisten] Not upgrading, exiting
Sat Sep 26 17:50:30 [initandlisten] run --upgrade to upgrade dbs, then start again
Sat Sep 26 17:50:30 [initandlisten] ****
Sat Sep 26 17:50:30 dbexit:
Sat Sep 26 17:50:30 [initandlisten] shutdown: going to close listening sockets...
Sat Sep 26 17:50:30 [initandlisten] shutdown: going to flush diaglog...
Sat Sep 26 17:50:30 [initandlisten] shutdown: going to close sockets...
Sat Sep 26 17:50:30 [initandlisten] shutdown: waiting for fs preallocator...
Sat Sep 26 17:50:30 [initandlisten] shutdown: lock for final commit...
Sat Sep 26 17:50:30 [initandlisten] shutdown: final commit...
Sat Sep 26 17:50:30 [initandlisten] shutdown: closing all files...
Sat Sep 26 17:50:30 [initandlisten] closeAllFiles() finished
Sat Sep 26 17:50:30 [initandlisten] journalCleanup...
Sat Sep 26 17:50:30 [initandlisten] removeJournalFiles
Sat Sep 26 17:50:30 [initandlisten] shutdown: removing fs lock...
Sat Sep 26 17:50:30 dbexit: really exiting now
Logstream::get called in uninitialized state
Sat Sep 26 17:50:30 [initandlisten] ERROR: Client::~Client _context should be null but is not; client:initandlisten
答案 0 :(得分:3)
Sat Sep 26 17:27:11 [initandlisten] need to upgrade database SteveIsAwesome with pdfile version 4.22, new version: 4.5
Sat Sep 26 17:27:11 [initandlisten] Not upgrading, exiting
Sat Sep 26 17:27:11 [initandlisten] run --upgrade to upgrade dbs, then start again
Sat Sep 26 17:27:11 [initandlisten] ****
您是否尝试使用--upgrade运行它?
<强>已更新强>
Sat Sep 26 17:50:30 [initandlisten] need to upgrade database local with pdfile version 4.22, new version: 4.5
Sat Sep 26 17:50:30 [initandlisten] Not upgrading, exiting
Sat Sep 26 17:50:30 [initandlisten] run --upgrade to upgrade dbs, then start again
Sat Sep 26 17:50:30 [initandlisten] ****
Db改变?也许它每次运行时都会升级一次。