What's a clean way to stop mongod on Mac OS X?

后端 未结 9 1322
逝去的感伤
逝去的感伤 2020-12-12 09:28

i\'m running mongo 1.8.2 and trying to see how to cleanly shut it down on Mac.

on our ubuntu servers i can shutdown mongo cleanly from the mongo shell with:

9条回答
  •  有刺的猬
    2020-12-12 10:06

    It's probably because launchctl is managing your mongod instance. If you want to start and shutdown mongod instance, unload that first:

    launchctl unload -w ~/Library/LaunchAgents/org.mongodb.mongod.plist
    

    Then start mongod manually:

    mongod -f path/to/mongod.conf --fork
    

    You can find your mongod.conf location from ~/Library/LaunchAgents/org.mongodb.mongod.plist.

    After that, db.shutdownServer() would work just fine.

    Added Feb 22 2014:

    If you have mongodb installed via homebrew, homebrew actually has a handy brew services command. To show current running services:

    brew services list

    To start mongodb:

    brew services stop mongodb-community

    To stop mongodb if it's already running:

    brew services stop mongodb-community

    Update

    As edufinn pointed out in the comment, brew services is now available as user-defined command and can be installed with following command: brew tap gapple/services.

提交回复
热议问题