Reference post: https://www.jianshu.com/p/ccdd3e884b86
First, installation Preparation
1. Modify the System configuration
#关闭selinux, Firewall
#修改/etc/security/limits.conf Add the following:
- Soft Nofile 65536
- Hard Nofile 65536
- Soft Nproc 65536
- Hard Nproc 65536
#修改/etc/security/limits.d/20-nproc.conf
- Soft Nproc 65536
3. Create account, Directory
Groupadd-g MONGO
Useradd-u 600-g MONGO MONGO
Second, installation steps
1. Unzip the file
Tar xvf mongodb-linux-x86_64-enterprise-rhel70-3.6.2.tgz-c/usr/local/
Cd/usr/local
MV Mongodb-linux-x86_64-enterprise-rhel70-3.6.2/mongodb
CD MongoDB
Mkdir-p data/db
mkdir Log
Touch Log/mongod.log
mkdir etc
Touch etc/mongod.conf
Chown-r Mongo.mongo/usr/local/mongodb
2. Create configuration file/usr/local/mongodb/data/mongodb/config/mongod.conf
Systemlog:
Destination:file
Path:/usr/local/mongodb/data/mongodb/log/mongod.log
Logappend:true
Storage
Journal
Enabled:true
DbPath:/usr/local/mongodb/data/db/
Directoryperdb:true
Engine:wiredtiger
Wiredtiger:
Engineconfig:
Cachesizegb:4
Directoryforindexes:true
Collectionconfig:
Blockcompressor:none
Indexconfig:
Prefixcompression:true
Processmanagement:
Fork:true
Pidfilepath:/usr/local/mongodb/data/mongodb/mongod.pid
Net
port:27017
bindip:192.168.1.213
3, clear large pages in/etc/rc.d/rc.local add the following:
If Test-f/sys/kernel/mm/transparent_hugepage/enabled; Then
echo Never >/sys/kernel/mm/transparent_hugepage/enabled
Fi
If Test-f/sys/kernel/mm/transparent_hugepage/defrag; Then
echo Never >/sys/kernel/mm/transparent_hugepage/defrag
Fi
chmod +x/etc/rc.d/rc.local
4, modify the environment variables. Bash_profile
Java_home=/usr/local/jdk
Classpath= $JAVA _home/lib
Path= $JAVA _home/bin: $PATH: $HOME/bin:/usr/local/mongodb/bin
Export PATH java_home CLASSPATH
#重新加载. Bash_profile
. . bash_profile
5. Start MongoDB
Yum install-y net-snmp* gcc-c++
Nohup mongod-f/usr/local/mongodb/data/mongodb/config/mongod.conf >/dev/null 2>&1 &
6. Login Test
MONGO 192.168.1.213:27017
7. Mongodb C Drive Installation
Tar xvf mongo-c-driver-1.6.1.tar.gz
CD MONGO-C-DRIVER-1.6.1/
./configure-disable-automatic-init-and-cleanup
Make
Make install
Installing MongoDB on CentOS 7