mongodb 启动和停止脚步

启动脚步

#!/bin/bash
if [ $# != 0 ];then
    port=$1;
else
    port=27017
fi
mkdir -p /opt/mongodb/data_$port
/opt/mongodb/bin/mongod --auth --dbpath=/opt/mongodb/data_$port --logpath=/opt/mongodb/mongodb_$port.log --logappend --port=$port > /dev/null 2>&1 &

停止脚本

#!/bin/bash
if [ $# != 0 ];then
    port=$1;
else
    port=27017
fi
pid=`ps -o pid,command ax | grep mongod | grep $port | awk '!/awk/ && !/grep/ {print $1}'`;
if [ "${pid}" != "" ]; then
        kill -2 ${pid};
fi
echo "stop mongodb port:$port"
发布日期:
分类:Nosql