Mongodb启动和关闭脚本化.md

2020-02-26  本文已影响0人  平凡的运维之路

Mongodb停止和启动脚本

#!/bin/bash

mongodstart(){
     numactl --interleave=all  /home/mongodb/mongodb_3.2.12/bin/mongod  -f    /home/mongodb/config/config*.conf 
     numactl --interleave=all  /home/mongodb/mongodb_3.2.12/bin/mongod  -f    /home/mongodb/config/shard1*.conf 
     numactl --interleave=all  /home/mongodb/mongodb_3.2.12/bin/mongod  -f    /home/mongodb/config/shard2*.conf 
     numactl --interleave=all /home/mongodb/mongodb_3.2.12/bin/mongod  -f    /home/mongodb/config/shard3*.conf 
}

mongostart(){
    /home/mongodb/mongodb_3.2.12/bin/mongos    -f /home/mongodb/config/mongos*.conf 
}

main(){
    mongodstart
    mongostart
}

main

#!/bin/bash

mongodstop(){
    /home/mongodb/mongodb_3.2.12/bin/mongod --shutdown -f    /home/mongodb/config/config*.conf 
    /home/mongodb/mongodb_3.2.12/bin/mongod --shutdown -f    /home/mongodb/config/shard1*.conf 
    /home/mongodb/mongodb_3.2.12/bin/mongod --shutdown -f    /home/mongodb/config/shard2*.conf 
    /home/mongodb/mongodb_3.2.12/bin/mongod --shutdown -f    /home/mongodb/config/shard3*.conf 
}

mongosstop(){
   #/home/mongodb/mongodb_3.2.12/bin/mongos  --shutdown  -f /home/mongodb/config/mongos*.conf 
   mongosPid=$(ps -ef|grep mongos|grep "\-f"|awk  '{print $2}')
   kill -15 $mongosPid
}

main(){
    mongodstop
    mongosstop
}

main


[mongodb@mongodb02 ~]$ vim .bashrc
alias mongostop='cd /home/mongodb/mongodb_3.2.12/bin && /bin/bash mongostop'
alias mongostart='cd /home/mongodb/mongodb_3.2.12/bin && /bin/bash mongostart'

上一篇下一篇

猜你喜欢

热点阅读