单机mongodb部署脚本
单机MongoDB部署脚本,第一次接触mongodb,公司做日志分析需要mongodb的环境。内部先安装一台供开发人员使用,后续会根据业务情况,逐步完善mongodb的部署维护文档。脚本如下:
网站建设哪家好,找创新互联!专注于网页设计、网站建设、微信开发、小程序制作、集团企业网站建设等服务项目。为回馈新老客户创新互联还提供了定襄免费建站欢迎大家使用!
#!/bin/bash # install mongodb # mongodb src path: http://www.mongodb.org/dr//fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.4.11.tgz/download DataPath2=/data/mongodb/db DataPath3=/data/mongodb/logs if [ ! -d "$DataPath2" ] then mkdir -p $DataPath2 fi if [ ! -d "$DataPath3" ] then mkdir -p $DataPath3 fi cd /usr/src/ mongodb_pid=`ps aux | grep mongodb | grep -v grep | awk '{print $2}'` if [ -z "$mongodb_pid" ] then tar -zxvf mongodb-linux-x86_64-2.4.11.tgz -C /usr/local/ mv mongodb-linux-x86_64-2.4.11 /usr/local/mongodb cd /usr/local/mongodb/bin cat > /usr/local/mongodb/bin/mongodb.conf << EOF dbpath = /data/mongodb/db logpath = /data/mongodb/logs/mongodb.log port = 27017 fork = true nohttpinterface = true EOF /usr/local/mongodb/bin/mongod --bind_ip localhost -f /usr/local/mongodb/bin/mongodb.conf else kill -9 "$mongodb_pid" tar -zxvf mongodb-linux-x86_64-2.4.11.tgz mv mongodb-linux-x86_64-2.4.11 /usr/local/mongodb cd /usr/local/mongodb/bin cat > /usr/local/mongodb/bin/mongodb.conf << EOF dbpath = /data/mongodb/db logpath = /data/mongodb/logs/mongodb.log port = 27017 fork = true nohttpinterface = true EOF /usr/local/mongodb/bin/mongod --bind_ip localhost -f /usr/local/mongodb/bin/mongodb.conf echo "Mongodb installed log" echo "###############################" ps -aux | grep mongodb | grep -v grep fi |
本文题目:单机mongodb部署脚本
分享URL:http://azwzsj.com/article/jhseoc.html