服務(wù)近2000家企業(yè),依托一系列實(shí)踐中打磨過的技術(shù)和產(chǎn)品,根據(jù)企業(yè)的具體業(yè)務(wù)問題和需求,針對性的提供各行業(yè)大數(shù)據(jù)解決方案。
Centos系統(tǒng)安裝配置MongoDB4x
來源:未知 時間:2019-24-10 瀏覽次數(shù):207次
MongoDB 是一個基于分布式文件存儲的數(shù)據(jù)庫。由 C++ 語言編寫。旨在為 WEB 應(yīng)用提供可擴(kuò)展的高性能數(shù)據(jù)存儲解決方案。MongoDB 是一個介于關(guān)系數(shù)據(jù)庫和非關(guān)系數(shù)據(jù)庫之間的產(chǎn)品,是非關(guān)系數(shù)據(jù)庫當(dāng)中功能最豐富,最像關(guān)系數(shù)據(jù)庫的。
1、下載并解壓mongodb
cd /data/
curl -O https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-4.0.4.tgz
tar zxvf mongodb-linux-x86_64-4.0.4.tgz
2、創(chuàng)建mongodb相關(guān)目錄
mv mongodb-linux-x86_64-4.0.4 mongodb
mkdir -p mongodb/{data/db,log}
mkdir -p /etc/mongodb
3、創(chuàng)建mongodb配置文件
vim /etc/mongodb/mgdb.conf
加入
加入
dbpath=/data/mongodb/data/db #數(shù)據(jù)文件存放目錄
logpath=/data/mongodb/log/mongodb.log #日志文件存放目錄
port=37485 #端口,默認(rèn)27017,可以自定義
logappend=true #開啟日志追加添加日志
fork=true #以守護(hù)程序的方式啟用,即在后臺運(yùn)行
bind_ip=0.0.0.0 #本地監(jiān)聽IP,0.0.0.0表示本地所有IP
auth=true #是否需要驗(yàn)證權(quán)限登錄(用戶名和密碼)
4、添加環(huán)境變量
vim /etc/profile
export MONGODB_HOME=/data/mongodb
export PATH=$PATH:$MONGODB_HOME/bin
使環(huán)境變量立即生效
source /etc/profile
5、創(chuàng)建mongodb啟動配置文件
vim /usr/lib/systemd/system/mongodb.service
[Unit]
Description=mongodb
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
RuntimeDirectory=mongodb
PIDFile=/data/mongodb/data/db/mongod.lock
ExecStart=/data/mongodb/bin/mongod --config /etc/mongodb/mgdb.conf
ExecStop=/data/mongodb/bin/mongod --shutdown --config /etc/mongodb/mgdb.conf
PrivateTmp=true
[Install]
WantedBy=multi-user.target
6、啟動mongodb并加入開機(jī)啟動
systemctl daemon-reload
systemctl start mongodb
systemctl enable mongodb
7、配置firewalld防火墻策略
firewall-cmd --permanent --add-port=37485/tcp
firewall-cmd --reload
8、測試
(1)創(chuàng)建管理用戶
mongo --port 37485
> use admin
> db.createUser({user:"admin",pwd:"xuad830818",roles:[{role:"userAdminAnyDatabase",db: "admin"}]})
> db.auth('admin','xuad830818')
(2)創(chuàng)建測試用戶
> use test
> db.createUser({user:"xuad",pwd:"123456",roles:[{role:"readWrite",db:"securitydata"}]})
> db.auth('xuad','123456')
> exit

(3)用測試用戶登陸
mongo --port 37485 -u xuad -p 123456


(3)用測試用戶登陸
mongo --port 37485 -u xuad -p 123456

- 上一篇: spark hive整合安裝
- 下一篇: centos python安裝或升級到python3.x