就像在 linux 下在/etc/init.d/下面放置一个脚本文件,设为开机自启动一样,mac 有没有类似的方式呢,据我所知,mac 是没有 win 的 service 这个概念的
MongoDb 用 Homebrew 安装好以后会这么一段
➜ ~ brew install mongodb
mongodb 2.0.0-x86_64
http://www.mongodb.org/
/usr/local/Cellar/mongodb/2.0.0-x86_64 (17 files, 120M)
If this is your first install, automatically load on login with (这段就是用来设置 MongoDB for Mac 的服务的,会开机自启动):
mkdir -p ~/Library/LaunchAgents
cp /usr/local/Cellar/mongodb/2.0.0-x86_64/org.mongodb.mongod.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/org.mongodb.mongod.plist
If this is an upgrade and you already have the org.mongodb.mongod.plist loaded:
launchctl unload -w ~/Library/LaunchAgents/org.mongodb.mongod.plist
cp /usr/local/Cellar/mongodb/2.0.0-x86_64/org.mongodb.mongod.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/org.mongodb.mongod.plist
Or start it manually:
mongod run --config /usr/local/Cellar/mongodb/2.0.0-x86_64/mongod.conf
MongoDB 1.8+ includes a feature for Write Ahead Logging (Journaling), which has been enabled by default.
To disable journaling, use --nojournal.
http://github.com/mxcl/homebrew/commits/master/Library/Formula/mongodb.rb
#8 楼 @sundevilyang 是最新的 mongodb 信息。
你在/usr/local/Cellar/mongodb
里面看到两个老版本的 Mongodb,说明你先后安装了两个 Mongodb,而这两个都不是最新版。你可以用下面几个命令升级并清理掉旧版本。
# 升级brew的版本库
brew update
# 查看outdated的库和应用
brew outdated
# 升级outdated的库和应用
brew upgrade
# 清理调过期的库和应用
brew cleanup