centos 7 mongodb4.0 安裝配置
1、下載安裝
wget https://repo.mongodb.org/yum/redhat/7/mongodb-org/4.0/x86_64/RPMS/mongodb-org-server-4.0.4-1.el7.x86_64.rpm
rpm -Uvh mongodb-org-server-4.0.4-1.el7.x86_64.rpm
2、基礎配置
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
storage:
dbPath: /var/lib/mongo
journal:
enabled: true
processManagement:
fork: true # fork and run in background
pidFilePath: /var/run/mongodb/mongod.pid # location of pidfile
timeZoneInfo: /usr/share/zoneinfo
net:
port: 27017
bindIp: 0.0.0.0
3、權限配置
第一步:創建test數據庫
use test
第二步:在test用戶中新建test用戶
db.createUser({ user: "test", pwd: "testPwd", roles: [{ role: "dbOwner", db: "test" }] })
第三步:修改MongoDB安裝目錄中的配置文件 /etc/mongod.conf
將#security:的註釋去掉,然後添加authorization: enabled #註意authorization前面要有兩個空格
security:
authorization: enabled
第四步:重啟MongoDB服務
service mongod restart
第五步:測試
mongo 127.0.0.1:27017/test -u test -p testPwd
centos 7 mongodb4.0 安裝配置