[iyunv@slayer ~]# mongod --config /etc/mongodb.conf
can't open [/var/log/mongodb/mongod.log] for log file: errno:2 No such file or directory
log文件不存在?建立一下再启动
[iyunv@slayer ~]# mongo
MongoDB shell version: 2.2.3
connecting to: test
Thu Dec 13 11:29:13 Error: couldn't connect to server 127.0.0.1:27017 src/mongo/shell/mongo.js:91
exception: connect failed
连接失败,看看log文件是什么问题 cat /var/log/mongodb/mongod.log
[iyunv@slayer ~]# cat /var/log/mongodb/mongod.log
Thu Dec 13 11:26:34 [initandlisten] MongoDB starting : pid=27030 port=27017 dbpath=/data/db 64-bit host=postgresql
Thu Dec 13 11:26:34 [initandlisten] db version v2.2.3, pdfile version 4.5
Thu Dec 13 11:26:34 [initandlisten] git version: f570771a5d8a3846eb7586eaffcf4c2f4a96bf08
Thu Dec 13 11:26:34 [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
Thu Dec 13 11:26:34 [initandlisten] options: { bind_ip: "127.0.0.1", config: "/etc/mongodb.conf", dbpath: "/data/db", fork: "true", journal: "true", logappend: "true", logpath: "/var/log/mongodb/mongod.log", port: 27017, quiet: "true" }
Thu Dec 13 11:26:34 [initandlisten] journal dir=/data/db/journal
Thu Dec 13 11:26:34 [initandlisten] recover : no journal files present, no recovery needed
Thu Dec 13 11:26:34 [initandlisten] Thu Dec 13 11:26:34 [initandlisten] ERROR: Insufficient free space for journal files
Thu Dec 13 11:26:34 [initandlisten] Please make at least 3379MB available in /data/db/journal or use --smallfiles
Thu Dec 13 11:26:34 [initandlisten]
Thu Dec 13 11:26:34 [initandlisten] exception in initAndListen: 15926 Insufficient free space for journals, terminating
Thu Dec 13 11:26:34 dbexit:
Thu Dec 13 11:26:34 [initandlisten] shutdown: going to close listening sockets...
Thu Dec 13 11:26:34 [initandlisten] shutdown: going to flush diaglog...
Thu Dec 13 11:26:34 [initandlisten] shutdown: going to close sockets...
Thu Dec 13 11:26:34 [initandlisten] shutdown: waiting for fs preallocator...
Thu Dec 13 11:26:34 [initandlisten] shutdown: lock for final commit...
Thu Dec 13 11:26:34 [initandlisten] shutdown: final commit...
Thu Dec 13 11:26:34 [initandlisten] shutdown: closing all files...
Thu Dec 13 11:26:34 [initandlisten] closeAllFiles() finished
Thu Dec 13 11:26:34 [initandlisten] journalCleanup...
Thu Dec 13 11:26:34 [initandlisten] removeJournalFiles
Thu Dec 13 11:26:34 [initandlisten] shutdown: removing fs lock...
Thu Dec 13 11:26:34 dbexit: really exiting now
可用控件不足。。照log提示加--smallfiles再启试试
[iyunv@slayer ~]# mongod --config /etc/mongodb.conf --smallfiles
all output going to: /var/log/mongodb/mongod.log
forked process: 27054
child process started successfully, parent exiting
[iyunv@slayer ~]# mongo
MongoDB shell version: 2.2.3
connecting to: test
>
成功进入MongoDB shell