在opensuse12 sp1上使用shell脚本自动安装部署Mongodb副本集,集群一共三个虚拟机节点
Deploy Mongodb Replica Set
代码语言:javascript复制mongo# chmod x deployinstance.sh initreplicaset.sh
# 三个节点上分别运行该脚本
mongo# ./deployinstance.sh
# ip1 和ip2 是mongodb中作为secondary的节点ip,然后在Primary节点上运行该脚本
mongo# ./initreplicaset.sh ip1 ip2
deployinstance.sh
代码语言:javascript复制#!/bin/bash
# Deploy mongodb,node-exporter,mongodb-exporter in suse 12 sp1
cronfile="/var/spool/cron/tabs/root"
mongocmd="/usr/bin/mongod"if [ `ifconfig | grep -c bond` -ne 0 ]; then
iface=bond
else
iface=eth
if [ `ifconfig | grep -c eth1` -eq 0 ]; then
iface_local_flag=1
else
iface_local_flag=0
fi
fi
vm_private_ip=`ifconfig ${iface}0 | grep "inet addr" | cut -d ":" -f 2 | cut -d " " -f 1`if [ $iface_local_flag -eq 1 ]; then
vm_public_ip=${vm_private_ip}else
vm_public_ip=`ifconfig ${iface}1 | grep "inet addr" | cut -d ":" -f 2 | cut -d " " -f 1`
fi
# echo -e "