{"id":345,"date":"2013-09-13T13:25:17","date_gmt":"2013-09-13T13:25:17","guid":{"rendered":"d81f9c1be2e08964bf9f24b15f0e4900"},"modified":"2013-09-13T13:25:17","modified_gmt":"2013-09-13T13:25:17","slug":"","status":"publish","type":"post","link":"https:\/\/www.xiaobo.li\/notes\/archives\/345","title":{"rendered":"mongod"},"content":{"rendered":"<pre class=\"brush:perl; toolbar: true; auto-links: true;\">#!\/bin\/bash\r\n\r\n# mongod - Startup script for mongod\r\n\r\n# chkconfig: 35 85 15\r\n# description: Mongo is a scalable, document-oriented database.\r\n# processname: mongod\r\n# config: \/etc\/mongod.conf\r\n# pidfile: \/var\/run\/mongo\/mongod.pid\r\n\r\n. \/etc\/rc.d\/init.d\/functions\r\n\r\n# things from mongod.conf get there by mongod reading it\r\n\r\n\r\n# NOTE: if you change any OPTIONS here, you get what you pay for:\r\n# this script assumes all options are in the config file.\r\nCONFIGFILE=\"\/etc\/mongod.conf\"\r\nOPTIONS=\" -f $CONFIGFILE\"\r\nSYSCONFIG=\"\/etc\/sysconfig\/mongod\"\r\n\r\n# FIXME: 1.9.x has a --shutdown flag that parses the config file and\r\n# shuts down the correct running pid, but that's unavailable in 1.8\r\n# for now.  This can go away when this script stops supporting 1.8.\r\nDBPATH=`awk -F= '\/^dbpath=\/{print $2}' \"$CONFIGFILE\"`\r\nPIDFILE=`awk -F= '\/^dbpath\\s=\\s\/{print $2}' \"$CONFIGFILE\"`\r\nmongod=${MONGOD-\/usr\/bin\/mongod}\r\n\r\nMONGO_USER=mongod\r\nMONGO_GROUP=mongod\r\n\r\nif [ -f \"$SYSCONFIG\" ]; then\r\n    . \"$SYSCONFIG\"\r\nfi\r\n\r\n# Handle NUMA access to CPUs (SERVER-3574)\r\n# This verifies the existence of numactl as well as testing that the command works\r\nNUMACTL_ARGS=\"--interleave=all\"\r\nif which numactl &gt;\/dev\/null 2&gt;\/dev\/null &amp;&amp; numactl $NUMACTL_ARGS ls \/ &gt;\/dev\/null 2&gt;\/dev\/null\r\nthen\r\n    NUMACTL=\"numactl $NUMACTL_ARGS\"\r\nelse\r\n    NUMACTL=\"\"\r\nfi\r\n\r\nstart()\r\n{\r\n  echo -n $\"Starting mongod: \"\r\n  daemon --user \"$MONGO_USER\" $NUMACTL $mongod $OPTIONS\r\n  RETVAL=$?\r\n  echo\r\n  [ $RETVAL -eq 0 ] &amp;&amp; touch \/var\/lock\/subsys\/mongod\r\n}\r\n\r\nstop()\r\n{\r\n  echo -n $\"Stopping mongod: \"\r\n  killproc -p \"$PIDFILE\" -d 300 \/usr\/bin\/mongod\r\n  RETVAL=$?\r\n  echo\r\n  [ $RETVAL -eq 0 ] &amp;&amp; rm -f \/var\/lock\/subsys\/mongod\r\n}\r\n\r\nrestart () {\r\n\tstop\r\n\tstart\r\n}\r\n\r\nulimit -n 12000\r\nRETVAL=0\r\n\r\ncase \"$1\" in\r\n  start)\r\n    start\r\n    ;;\r\n  stop)\r\n    stop\r\n    ;;\r\n  restart|reload|force-reload)\r\n    restart\r\n    ;;\r\n  condrestart)\r\n    [ -f \/var\/lock\/subsys\/mongod ] &amp;&amp; restart || :\r\n    ;;\r\n  status)\r\n    status $mongod\r\n    RETVAL=$?\r\n    ;;\r\n  *)\r\n    echo \"Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart}\"\r\n    RETVAL=1\r\nesac\r\n\r\nexit $RETVAL<\/pre>\n","protected":false},"excerpt":{"rendered":"<pre class=\"brush:perl; toolbar: true; auto-links: true;\">#!\/bin\/bash\r\n\r\n# mongod - Startup script for mongod\r\n\r\n# chkconfig: 35 85 15\r\n# description: Mongo is a scalable, document-oriented database.\r\n# processname: mongod\r\n# config: \/etc\/mongod.conf\r\n# pidfile: \/var\/run\/mongo\/mongod.pid\r\n\r\n. \/etc\/rc.d\/init.d\/functions\r\n\r\n# things from mongod.conf get ther...<\/pre>\n<p> <a href=\"https:\/\/www.xiaobo.li\/notes\/archives\/345\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[288],"tags":[73],"class_list":["post-345","post","type-post","status-publish","format-standard","hentry","category-db","tag-mongo"],"_links":{"self":[{"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/posts\/345","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/comments?post=345"}],"version-history":[{"count":0,"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/posts\/345\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/media?parent=345"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/categories?post=345"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/tags?post=345"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}