1.MongoDB的最新版官方下载地址:
https://www.mongodb.com/download-center#community
使用wget命令下载安装包
[root@localhost ~]# wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel62-3.4.4.tgz
2.解压压缩包,并配置相关文件
[root@localhost ~]# tar zxvf mongodb-linux-x86_64-3.2.6.tgz
[root@localhost ~]# mv mongodb-linux-x86_64-3.2.6.tgz mongodb
[root@localhost ~]# mv mogodb /usr/local/
[root@localhost local]# cd mongodb
[root@localhost local]# mkdir db
[root@localhost local]# mkdir logs
[root@localhost local]# cd bin
[root@localhost bin]# vi mongodb.conf 备注:mongodb数据库的配置文件
#添加以下几行代码
port=27017
dbpath=/usr/local/mongodb/db
logappend=true
fork=true
logpath=/usr/local/mongodb/logs/mongpdb.log
nohttpinterface=true
3.启动mongodb
[root@localhost ~]# cd /usr/local/mongodb/bin
[root@localhost bin]# ./mongod -f mongodb.conf
4.开机自动启动mongodb
[root@localhost ~]# vi /etc/rc.d/rc.local
添加下面一行
/usr/local/mongodb/bin/mongod --config /usr/local/mongodb/bin/mongodb.conf