mongodb3.4.4源码安装

超简单就那么两步

完事了  看效果

chmod +x /etc/init.d/mongod &&  /etc/init.d/mongod start 

启动脚本内容如下 直接复制粘贴即可

#!/bin/bash
#
#chkconfig: 2345 85 88
#https://wuguiyunwei.com 
start() {
sudo -u mongod /usr/local/mongodb/bin/mongod --dbpath=/data/db --fork --logpath=/data/db/wuguiyunwei.com-log --pidfilepath=/data/db/wuguiyunwei.com-pid
}

stop() {
  /usr/local/mongodb/bin/mongod  --shutdown
}

status() { 
netstat -anpt | grep mongod
if [ $? -eq 0 ]
    then
    echo -e "\033[32m mongodb Already run..... \033[0m" 
else
    echo -e "\033[31m mongodb not run..... \033[0m"

fi
}

case "$1" in
  start)
 start
 ;;
  stop)
 stop
 ;;
  restart)
 stop
 start
 ;;
 status)
 status
 ;;

  *)
 echo $"Usage: $0 {start|stop|restart|status}"
 exit 1
esac