下载安装mongodb

wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-3.4.4.tgz
tar zxvf mongodb-linux-x86_64-rhel70-3.4.4.tgz
mv mongodb-linux-x86_64-rhel70-3.4.4 mongodb344

配置mongodb

cd mongodb344/mkdir datamkdir logs
vim /opt/mongodb344/mongodb.confport=27017dbpath=/opt/mongodb344/data/rest=truelogpath=/opt/mongodb344/logs/mongodb.logpidfilepath=/opt/mongodb344/mongo.pidfork=truelogappend=trueshardsvr=true#directoryperdb=true#auth=true
vim  /etc/rc.d/init.d/mongodlimit -SHn 655350#!/bin/bash# chkconfig: - 64 36# description:mongodcase $1 instart)mongod  --maxConns 20000  --config /opt/mongodb344/mongodb.conf;;stop)/opt/mongodb344/bin/mongo 127.0.0.1:27017/admin --eval "db.shutdownServer()";;status)/opt/mongodb344/bin/mongo 127.0.0.1:27017/admin --eval "db.stats()";;esac

设置开机自启

chmod +x /etc/rc.d/init.d/mongodchkconfig mongod on
echo never > /sys/kernel/mm/transparent_hugepage/enabledecho never > /sys/kernel/mm/transparent_hugepage/defrag
/etc/init.d/mongod start/etc/init.d/mongod stop/etc/init.d/mongod status