創建安裝目錄
<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下載安裝配置教程,看完記得轉發、點贊和收藏。想了解更多內容,請關注本小編,如果有錯誤,歡迎批評指正,感謝支持。
(雲渺書齋)