创建安装目录
<code>[root@192 ~]# cd /usr/local [root@192 local]# mkdir mongo [root@192 local]# cd mongo//<code>
官网下载mongo
<code>[root@192 mongo]# wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-3.4.7.tgz/<code>
解压文件
<code>[root@192 mongo]# ls mongodb-linux-x86_64-rhel70-3.4.7.tgz [root@192 mongo]# tar -zxvf mongodb-linux-x86_64-rhel70-3.4.7.tgz [root@192 mongo]# ls mongodb-linux-x86_64-rhel70-3.4.7 mongodb-linux-x86_64-rhel70-3.4.7.tgz/<code>
添加到PATH路径
<code>[root@192 mongo]# export PATH=/usr/local/mongo/mongodb-linux-x86_64-rhel70-3.4.7/bin:$PATH/<code>
新建目录db和logs存放数据和日志
<code>[root@192 mongo]# mkdir datas [root@192 mongo]# cd datas/ [root@192 datas]# mkdir db [root@192 datas]# mkdir logs [root@192 datas]# ls db logs/<code>
授权安装目录
<code>[root@192 datas]# cd ../../ [root@192 local]# chmod 777 -R ./mongo//<code>
创建并编辑mongodb.conf
<code>[root@192 local]# cd mongo/datas/ [root@192 datas]# vi mongodb.conf/<code>
Insert
输入以下内容
<code>#数据目录 dbpath=/usr/local/mongo/datas/db #日志所在目录 logpath=/usr/local/mongo/datas/logs/mongodb.log #端口号 port=27017 #开启用户认证 auth=true #以追加的方式记录日志 logappend=true #以守护进程的方式运行 fork=true/<code>
Esc
:x
启动mongodb
<code>[root@192 datas]# /usr/local/mongo/mongodb-linux-x86_64-rhel70-3.4.7/bin/mongod -f /usr/local/mongo/datas/mongodb.conf/<code>
查看进程
验证连接
ok,以上就是【Linux】MongoDB下载安装配置教程,看完记得转发、点赞和收藏。想了解更多内容,请关注本小编,如果有错误,欢迎批评指正,感谢支持。
(云渺书斋)