MongoDB安装

#建立数据目录
$ mkdir -p /data/db
#下载压缩包
#定位安装目录 $ cd /home/apps/
$ curl -O http://downloads.mongodb.org/linux/mongodb-linux-i686-1.3.3.tgz
#解压缩文件
$ tar xzf mongodb-linux-i686-1.3.3.tgz
#启动服务
$ ./mongodb-linux-i686-1.3.3/bin/mongod &
#运行 mongo shell
$ ./mongodb-linux-i686-1.3.3/bin/mongo
>db.foo.save({ a : 1 } )
>db.foo.findOne()

#关闭防火墙

 1) 重启后生效 

开启: chkconfig iptables on 
关闭: chkconfig iptables off 

2) 即时生效,重启后失效 
开启: service iptables start 
关闭: service iptables stop 

#检查端口

netstat -an -t|grep 27017
netstat -an -t|grep 28017 

另外:

#把mongodb/bin添加到PATH里,这样就可以在任意位置运行mongod和mongo了

$ export PATH="/home/apps/mongodb-linux-i686-1.3.3/bin:$PATH"

相关文档 

原文地址:https://www.cnblogs.com/chenjunbiao/p/1760295.html