官网地址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() --- >