官網地址https://www.mongodb.com/download-center?jmp=tutorials#communitylinux
tar -zxvf mongodb-linux-x86_64-rhel70-4.0.1.tgz
移動到 /usr/local/mongodbweb
mv mongodb-linux-x86_64-rhel70-4.0.1 /usr/local/mongodb/
1.新建data/db 目錄mongodb
cd /usr/local/mongodb/ mkdir data/db
2.新建logs目錄shell
mkdir logs
3.在bin目錄下新建mongodb.conf數據庫
#mongodb config file port=27017 #端口 rt=27017 #端口 bind_ip=0.0.0.0 #默認是127.0.0.1 dbpath=/usr/local/mongodb/data/db #數據庫存放 logpath=/usr/local/mongodb/logs/mongodb.log #日誌文件 fork=true #設置後臺運行 #auth=true #開啓認證
1.SElinux 容許27017端口tcp
semanage port -a -t mongod_port_t -p tcp 27017
2.設置環境變量,在/etc/profile最底下添加this
export MONGODB_HOME=/usr/local/mongodb export PATH=$PATH:${MONGODB_HOME}/bin
使之生效 spa
source /etc/profile
3.運行mongdrest
mongod --config mongodb.conf
4.運行mongo日誌
[root@localhost mongodb]# mongo MongoDB shell version v4.0.1 connecting to: mongodb://127.0.0.1:27017 MongoDB server version: 4.0.1 Server has startup warnings: 2018-08-22T11:44:02.369-0400 I CONTROL [initandlisten] 2018-08-22T11:44:02.369-0400 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database. 2018-08-22T11:44:02.369-0400 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted. 2018-08-22T11:44:02.369-0400 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended. 2018-08-22T11:44:02.369-0400 I CONTROL [initandlisten] 2018-08-22T11:44:02.370-0400 I CONTROL [initandlisten] 2018-08-22T11:44:02.370-0400 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'. 2018-08-22T11:44:02.370-0400 I CONTROL [initandlisten] ** We suggest setting it to 'never' 2018-08-22T11:44:02.370-0400 I CONTROL [initandlisten] 2018-08-22T11:44:02.370-0400 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'. 2018-08-22T11:44:02.370-0400 I CONTROL [initandlisten] ** We suggest setting it to 'never' 2018-08-22T11:44:02.370-0400 I CONTROL [initandlisten] --- Enable MongoDB's free cloud-based monitoring service, which will then receive and display metrics about your deployment (disk utilization, CPU, operation statistics, etc). The monitoring data will be available on a MongoDB website with a unique URL accessible to you and anyone you share the URL with. MongoDB may use this information to make product improvements and to suggest MongoDB products and deployment options to you. To enable free monitoring, run the following command: db.enableFreeMonitoring() To permanently disable this reminder, run the following command: db.disableFreeMonitoring() --- >