System environment: CENTOS-7 64-bit
: https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-3.2.5.tgz
Upload location:/usr/local/src
Software Installation Location:/usr/local/mongodb
Data storage location:/usr/local/mongodb/data
Log storage location:/usr/local/mongodb/logs
Installation
Extract
[Email protected]/]# CD/USR/LOCAL/SRC
[Email protected] src]# tar-zxv-f mongodb-linux-x86_64-rhel70-3.2.5.tgz
[Email protected] src]# MV Mongodb-linux-x86_64-rhel70-3.2.5.tgz/usr/local/mongodb
[Email protected] src]# Cd/usr/local/mongodb
Create a database directory and log directory
[[email protected] MongoDB] #mkdir-P/usr/local/mongodb/data
[[email protected] MongoDB] #mkdir-P/usr/local/mongodb/logs
Configuring firewalls
# Vi/etc/sysconfig/iptables
Insert
-A input-p tcp-m state--state new-m TCP--dport 27017-j ACCEPT
# Service Iptables Restart
Start MongoDB
MongoDB default database directory is/data/db, changing directory needs to add path configuration at startup
[Email protected]/]# Cd/usr/local/mongodb
[Email protected] mongodb]#/bin/mongod--dbpath=/usr/local/mongodb/data--logpath/usr/local/mongodb/logs/log.txt --logappend--fork
See the following information stating that the installation has completed and started successfully:
35828 ChildProcess started successfully, parent exiting
Stop MongoDB
[Email protected]/]# Cd/usr/local/mongodb
[Email protected] mongodb]#/bin/mongod--shutdown--dbpath/usr/local/mongodb/data/
Add CentOS Start-up entry
[Email protected] src]# VI +/etc/rc.d/rc.local
Append the MongoDB Start command to this file:
/usr/local/mongodb/bin/mongod--dbpath=/usr/local/mongodb/data–logpath/usr/local/mongodb/logs/log.txt-- Logappend--fork
MongoDB Source Installation