1)、下载MongoDB
http://fastdl.mongodb.org/linux/mongodb-linux-i686-2.0.4.tgz

2)、设置MongoDB目录

将其解压到/usr/local/,再重命名为mongodb,路径为/usr/local/mongodb

3)、设置数据文件路径

建立/data/db的目录, mkdir p /data/db

4)、启动MongoDB服务

1.  cd /usr/local/mongodb

2.  ./bin/mongod --dbpath=/data/db   

3.  Mon Apr 16 09:29:38

4.  Mon Apr 16 09:29:38 warning: 32-bit servers don't have journaling enabled by default. Please use --journal if you want durability.

5.  Mon Apr 16 09:29:38

6.  Mon Apr 16 09:29:38 [initandlisten] MongoDB starting : pid=3007 port=27017 dbpath=/data/db 32-bit host=CRM.158.net

7.  Mon Apr 16 09:29:38 [initandlisten]

8.  Mon Apr 16 09:29:38 [initandlisten] ** NOTE: when using MongoDB 32 bit, you are limited to about 2 gigabytes of data

9.  Mon Apr 16 09:29:38 [initandlisten] **       see http://blog.mongodb.org/post/137788967/32-bit-limitations

10. Mon Apr 16 09:29:38 [initandlisten] **       with --journal, the limit is lower

11. Mon Apr 16 09:29:38 [initandlisten]

12. Mon Apr 16 09:29:38 [initandlisten] db version v2.0.4, pdfile version 4.5

13. Mon Apr 16 09:29:38 [initandlisten] git version: 329f3c47fe8136c03392c8f0e548506cb21f8ebf

14. Mon Apr 16 09:29:38 [initandlisten] build info: Linux domU-12-31-39-01-70-B4 2.6.21.7-2.fc8xen #1 SMP Fri Feb 15 12:39:36 EST 2008 i686 BOOST_LIB_VERSION=1_41

15. Mon Apr 16 09:29:38 [initandlisten] options: { dbpath: "/data/db" }

16. Mon Apr 16 09:29:38 [initandlisten] waiting for connections on port 27017

17. Mon Apr 16 09:29:38 [websvr] admin web console waiting for connections on port 28017

MongoDB 服务端的默认连接端口:27017

5)、将MongoDB作为 Linux 服务随机启动

先创建/usr/local/mongodb/logs/mongodb.log文件,用于存储MongoDB的日志文件
vi /etc/rc.local
/usr/local/mongodb/bin/mongod --dbpath=/data/db --logpath=/usr/local/mongodb/logs/mongodb.log 

6)、客户端连接验证

1.  cd /usr/local/mongodb 

2.  ./bin/mongo

3.  MongoDB shell version: 2.0.4  

4.  connecting to: test  

5.  > 

7)、查看MongoDB日志

查看/usr/local/mongodb/logs/mongodb.log文件,即可对MongoDB的运行情况进行查看或排错了