下载安装mongodb
wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-3.4.4.tgz
tarzxvf mongodb-linux-x86_64-rhel70-3.4.4.tgz
mvmongodb-linux-x86_64-rhel70-3.4.4 mongodb344
配置mongodb
cdmongodb344/
mkdirdata
mkdirlogs
vim/opt/mongodb344/mongodb.conf
port=27017
dbpath=/opt/mongodb344/data/
rest=true
logpath=/opt/mongodb344/logs/mongodb.log
pidfilepath=/opt/mongodb344/mongo.pid
fork=true
logappend=true
shardsvr=true
#directoryperdb=true
#auth=true
vim/etc/rc.d/init.d/mongod
limit -SHn 655350
#!/bin/bash
# chkconfig: – 64 36
# description:mongod
case$1in
start)
mongod –maxConns 20000 –config/opt/mongodb344/mongodb.conf
;;
stop)
/opt/mongodb344/bin/mongo127.0.0.1:27017/admin–eval”db.shutdownServer()”
;;
status)
/opt/mongodb344/bin/mongo127.0.0.1:27017/admin–eval”db.stats()”
;;
esac
设置开机自启
chmod+x/etc/rc.d/init.d/mongod
chkconfig mongod on
echonever >/sys/kernel/mm/transparent_hugepage/enabled
echonever >/sys/kernel/mm/transparent_hugepage/defrag
/etc/init.d/mongodstart
/etc/init.d/mongodstop
/etc/init.d/mongodstatus