Environment CentOS6.8
andmongodb4.0.1
1 Download MongoDB Package website address
Switch to/USR/LOCAL/SRC directory
[[email protected] src]# wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel62-4.0.1.tgz
2 Unpacking the MongoDB package
[[email protected] src]# tar -zxvf mongodb-linux-x86_64-rhel62-4.0.1.tgz// 重命名[[email protected] src]# mv mongodb-linux-x86_64-rhel62-4.0.1 mongodb
3 Configuration Files
Enter the MongoDB directory, first create the Data/db,data/logs folder
[[email protected] mongodb]# mkdir data/db[[email protected] mongodb]# mkdir data/logs
Enter the bin directory to create the mongodb.conf file
// mongodb.conf不存在就新建文件,存在就打开编辑[[email protected] bin]# vi mongodb.conf
The edit mongodb.conf file is saved as follows
dbpath = /usr/local/src/mongodb/data/dblogpath = /usr/local/src/mongodb/data/logs/mongodb.logport=27017fork=true
4 Testing
Execute start MongoDB in the bin directory ./mongod --config mongodb.conf
Input ./mongo
into MongoDB console
5 Boot, edit /etc/rc.d/rc.local
the file, and then restart the system
// 最后添加/usr/local/src/mongodb/bin/mongod --config mongodb.conf
6 environment variables, editing the current user .bash_profile
file,
// 最后添加export MONGODB_HOME=/usr/local/src/mongodb/binexport PATH=$MONGODB_HOME:$PATH
CentOS 6.8 Installation MongoDB Database