上传位置:/usr/local/软件安装位置:/usr/local/mongodb数据存放位置:/var/mongodb/data日志存放位置:/var/mongodb/logs
安装[root@localhost /]# cd usr/local/[root@localhost /]# groupadd mongodb[root@localhost /]# useradd mongodb -g mongodb[root@localhost /]# cd /usr/local[root@localhost local]# tar -zxv -f mongodb-linux-x86_64-2.2.2.tgz[root@localhost local]# mv mongodb-linux-x86_64-2.2.2 mongodb[root@localhost local]# chown -R mongodb: mongodb mongodb[root@localhost local]# cd mongodb[root@localhost mongodb]# mkdir /var/mongodb[root@localhost mongodb]# mkdir /var/mongodb/data[root@localhost mongodb]# mkdir /var/mongodb/logs[root@localhost mongodb]# vi /etc/sysconfig/iptables // 将27017端口加入防火墙 [root@localhost mongodb]# service iptables restart // 重启防火墙
添加CentOS开机启动项 [root@localhost mongodb]# vi + /etc/rc.d/rc.local将mongodb启动命令追加到本文件中: /usr/local/mongodb/bin/mongod --dbpath=/var/mongodb/data --logpath /var/mongodb/logs/log.log -fork启动mongodb[root@localhost mongodb]# /usr/local/mongodb/bin/mongod --dbpath=/var/mongodb/data --logpath /var/mongodb/logs/log.log -fork