1. Download
wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-amazon-3.6.3.tgz
2. Decompression
Tar zxvf mongodb-linux-x86_64-amazon-3.6. 3. tgz
3. Mobile
MV mongodb-linux-x86_64-amazon-3.6. 3 /usr/local/mongodb
Note: Do not compile, itself is compiled binary execution file
4. Adding configuration Files
Vim/usr/local/mongodb/bin/mongodb.conf
Copy the following code
# Database file path DBPath=/usr/local/mongodb/data/db/# log file path LogPath=/usr/local/mongodb/data/log/ mongodb.log# whether to append log logappend=true# ports Port=27017# Whether the daemon starts fork=true # Whether to start authorization authentication auth=true
Note: You need to create a database, log directory
5. Configure MongoDB Service
Vim/lib/systemd/system/mongodb.service
Copy the following code
[Unit]description=mongodbafter=network.target remote-fs.target nss-Lookup.target[service] Type=forkingexecstart=/usr/local/mongodb/bin/mongod--config/usr/local/mongodb/bin/ Mongodb.confexecreload=/bin/kill-s HUP $MAINPIDExecStop=/usr/local/mongodb/bin/mongod--shutdown-- config/usr/local/mongodb/bin/mongodb.confprivatetmp=true[Install]wantedby= Multi-user.target
6. Boot start
# boot Systemctl enable mongodb.service# start service Systemctl start mongodb.service# stop service Systemctl stop Mongodb.service
Installing MongoDB under CENTOS7 environment