1.MongoDB的最新版官方下载地址:
[MongoDB Community Download | MongoDB](https://www.mongodb.com/try/download)
使用wget命令下载安装包
[root@localhost ~]# wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-4.4.13.tgz
2.解压压缩包,并配置相关文件
[root@localhost ~]# tar -zxvf mongodb-linux-x86_64-rhel70-4.4.13.tgz
[root@localhost ~]# mv mongodb-linux-x86_64-rhel70-4.4.13 mongodb
[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
#添加以下几行代码
port=27017
dbpath=/mnt/data/odc/mongodb/db
logappend=true
fork=true
logpath=/mnt/data/odc/mongodb/logs/mongodb.log
#nohttpinterface=true # mongodb4.0添加这个配置会报错,需要用下面的 bind_ip=0.0.0.0
bind_ip=0.0.0.0 #可用win10进行连接,加上这个属性 nohttpinterface=true 这个属性就不要再进行添加了
[root@localhost ~]# cd /mnt/data/odc/mongodb/logs touch mongodb.log
3.启动mongodb
[root@localhost ~]# cd /mnt/data/odc/mongodb/bin
[root@localhost bin]# ./mongod -f mongodb.conf
4.开机自动启动mongodb
[root@localhost ~]# vi /etc/rc.d/rc.local
添加下面一行
/mnt/data/odc/mongodb/bin/mongod --config /mnt/data/odc/mongodb/bin/mongodb.conf
5.关闭mongodb
kill -2 pid
service mongod stop
网友评论