Mac 下安装 mongodb
安装supervisor
brew install supervisor
修改配置
[inet_http_server] ; inet (TCP) server disabled by default
port=127.0.0.1:9001 ; ip_address:port specifier, *:port for all iface
启动脚本
#!/bin/bash
case $1 in
start)
supervisord -c /usr/local/etc/supervisord.ini
PID=$(ps aux | grep superv | grep -v grep | awk '{print $2}')
if [[ -n $PID ]]; then
echo "Running..."
else
echo "Stopped..."
fi
;;
stop)
PID=$(ps aux | grep superv | grep -v grep | awk '{print $2}')
if [[ -n $PID ]]; then
kill $PID
echo "Running..."
else
echo "Stopped..."
fi
;;
status)
PID=$(ps aux | grep superv | grep -v grep | awk '{print $2}')
if [[ -n $PID ]]; then
echo "Running..."
else
echo "Stopped..."
fi
;;
esac
下载
https://fastdl.mongodb.org/osx/mongodb-macos-x86_64-4.4.1.tgz
配置文件 supervisor
[program:mongodb]
directory=/Users/yang/bin/
command=/Users/yang/bin/mongod --bind_ip 127.0.0.1 --port 27017 --dbpath /Users/yang/var/data --logpath /Users/yang/var/log/mongo.log
process_name=%(program_name)s
创建目录和修改权限
sudo mkdir -p /Users/yang/var/data /Users/yang/var/log/
chown -R yang /Users/yang/var/data /Users/yang/var/log/
启动
supervisorctl update