安装
cd /opt
wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-3.6.8.tgz
tar -zxvf mongodb-linux-x86_64-rhel70-3.6.8.tgz .
ln -s mongodb-linux-x86_64-rhel70-3.6.8 mongodb
配置
fork = true
port = 27017
bind_ip = {server_ip}
dbpath = /opt/mongodb/data
logpath = /data/log/mongodb/mongodb.log
logappend = true
新建对应目录
mkdir -p /opt/mongodb/data
mkdir -p /data/log/mongodb/
启动
cd /opt/mongodb
./bin/mongod --config mongodb.conf
开机自启(自定义)
cd /etc/init.d
vi mongodb
#!/bin/sh
#
#chkconfig: 2345 80 90
#description: mongodb
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
start() {
/opt/mongodb/bin/mongod -f /opt/mongodb/mongodb.conf
}
stop() {
/opt/mongodb/bin/mongod -f /opt/mongodb/mongodb.conf --shutdown
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
esac
chmod +x mongodb
chkconfig --add mongodb
chkconfig mongodb on
service mongodb start
end