Operating system: CentOS 5.X 64-bit
IP Address: 192.168.21.130
Install Configuration MongoDB Database
First, close the SELinux, configure the firewall
#SELINUXTYPE =targeted #注释掉
2, Vi/etc/sysconfig/iptables #编辑
-A rh-firewall-1-input-m state--state new-m tcp-p TCP--dport 27017-j ACCEPT #允许27017端口通过防火墙
/etc/init.d/iptables Restart #重启防火墙使配置生效
MongoDB Download Address: https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.6.0.tgz #目前最新版
Upload mongodb-linux-x86_64-2.6.0.tgz to/usr/local/src directory
CD/USR/LOCAL/SRC #进入软件存放目录
Tar zxvf mongodb-linux-x86_64-2.6.0.tgz #解压
MV Mongodb-linux-x86_64-2.6.0/usr/local/mongodb #移动解压文件夹到MongoDB安装目录
Mkdir-p/home/data/mongodb/mongodb_data/#创建MongoDB Database storage path
Mkdir-p/home/data/mongodb/mongodb_log/#创建MongoDB数据库 log storage path
/usr/local/mongodb/bin/mongod--port 27017--fork--dbpath=/home/data/mongodb/mongodb_data/--logpath=/home/data/ Mongodb/mongodb_log/mongodb.log--logappend
NETSTAT-LANP | grep "27017" #查看MongoDB是否启动
cd/usr/local/mongodb/bin/
Db.shutdownserver () #关闭MongoDB数据库
Third, set up MongoDB database
1, cd/usr/local/mongodb/#进入MongoDB安装目录
Vi/usr/local/mongodb/mongodb.conf #编辑
dbpath=/home/data/mongodb/mongodb_data/#数据库路径
Logpath=/home/data/mongodb/mongodb_log/mongodb.log #日志输出文件路径
Pidfilepath=/usr/local/mongodb/mongo.pid
2, cd/usr/local/mongodb/bin/
./mongod--config/usr/local/mongodb/mongodb.conf #启动MongoDB
./mongo 127.0.0.1:27017/admin--eval "Db.shutdownserver ()" #关闭MongoDB
Vi/etc/rc.d/init.d/mongod #设置开机启动MongoDB
/usr/local/mongodb/bin/mongod--config/usr/local/mongodb/mongodb.conf
/usr/local/mongodb/bin/mongo 127.0.0.1:27017/admin--eval "Db.shutdownserver ()"
/usr/local/mongodb/bin/mongo 127.0.0.1:27017/admin--eval "db.stats ()"
chmod +x/etc/rc.d/init.d/mongod #添加脚本执行权限
Chkconfig Mongod on #设置开机启动
Service Mongod Start #启动MongoDB
3, Vi/etc/profile #添加环境变量, edit, add the following code on the last line
Export path= $PATH:/usr/local/mongodb/bin
Source/etc/profile #使配置立即生效
At this point, the MongoDB database installation configuration is complete.