Redhat 5.5下安装MongoDB

      在前面的文章里,我写了MongoDB开发入门,并且谈了如何在windows下安装MongoDB数据库,那么本篇文章我将介绍如何在Linux操作系统中安装MongoDB数据库。

      首先,下载MongoDB数据库,地址:http://fastdl.mongodb.org/linux/mongodb-linux-i686-1.8.1.tgz 。下载无论你采用什么方式吧,你可以wget,你也可以在浏览器上下载。下载完毕以后就是解压压缩文件了:tar -xvf  mongodb-linux-i686-1.8.1.tgz 。在/usr/local/目录下创建mongodb目录,在mongodb目录下创建data和log目录。把解压的压缩文件中bin目录下的东东全部拷贝到/usr/local/mongodb目录下(还是那句话这些步骤你可以通过命令完成或者手动)。

     然后,运行MongoDB数据库服务端。

[root@localhost mongodb]# mongod --dbpath data
bash: mongod: command not found
[root@localhost mongodb]# ./mongod --dbpath data
Wed Jan 18 11:06:41 [initandlisten] MongoDB starting : pid=8859 port=27017 dbpath=data 32-bit 

** NOTE: when using MongoDB 32 bit, you are limited to about 2 gigabytes of data
**       see http://blog.mongodb.org/post/137788967/32-bit-limitations
**       with --dur, the limit is lower

Wed Jan 18 11:06:41 [initandlisten] db version v1.8.1, pdfile version 4.5
Wed Jan 18 11:06:41 [initandlisten] git version: a429cd4f535b2499cc4130b06ff7c26f41c00f04
Wed Jan 18 11:06:41 [initandlisten] build sys info: Linux bs-linux32.10gen.cc 2.6.21.7-2.fc8xen #1 SMP Fri Feb 15 12:39:36 EST 2008 i686 BOOST_LIB_VERSION=1_37
Wed Jan 18 11:06:41 [initandlisten] waiting for connections on port 27017
Wed Jan 18 11:06:41 [websvr] web admin interface listening on port 28017
Wed Jan 18 11:06:59 [initandlisten] connection accepted from 127.0.0.1:55098 #1
Wed Jan 18 11:11:05 [initandlisten] connection accepted from 127.0.0.1:40233 #2
Wed Jan 18 11:11:05 [conn2] end connection 127.0.0.1:40233
Wed Jan 18 11:11:05 [initandlisten] connection accepted from 127.0.0.1:40234 #3
Wed Jan 18 11:11:05 [conn3] end connection 127.0.0.1:40234

     接着,运行MongoDB数据库客户端(可以使用javascript shell的那玩意儿)。

[root@localhost mongodb]# ls
bsondump      mongo        mongofiles    mongosniff
data          mongod       mongoimport   mongostat
GNU-AGPL-3.0  mongodump    mongorestore  README
log           mongoexport  mongos        THIRD-PARTY-NOTICES
[root@localhost mongodb]# ./mongo
MongoDB shell version: 1.8.1
connecting to: test
> show dbs
admin   (empty)
local   (empty)

      最后,我们还是在浏览器上玩玩  http://localhost:27017/ 

 You are trying to access MongoDB on the native driver port. For http diagnostic access, add 1000 to the port number。

      好了就是这些了!

    

原文地址:https://www.cnblogs.com/likehua/p/2325343.html