在MacOSX用launchctl来管理mongodb

创建org.mongo.mongod.plist文件 ```xml /Library/LaunchDaemons/org.mongo.mongod.plist <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> Label org.mongo.mongod RunAtLoad ProgramArguments /usr/local/bin/mongod --dbpath /var/lib/mongodb/ --logpath /var/log/mongodb.log


接下来我们来创建data与log路径

```bash Terminal
sudo touch /var/log/mongodb.log
sudo mkdir /var/lib/mongodb

```bash Terminal sudo chown root:wheel /Library/LaunchDaemons/org.mongo.mongod.plist sudo launchctl load /Library/LaunchDaemons/org.mongo.mongod.plist sudo launchctl start org.mongo.mongod



参考 [MongoDB Startup Item for Mac OS X Snow Leopard](http://hunterford.me/mongodb-startup-item/)

Comments