您好,登录后才能下订单哦!
单机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 |
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。