脚本样例
#!bin/bash
#判断是不是有一个传参
if [ $# != 1 ]; then
echo "执行错误"
echo "USAGE: $0 需要传入一个参数,参数必须是('手厅主库','仓库','活动','一证五号','CID')中任意一个"
echo "e.g.:sh $0 'CID' "
exit 1;
fi
#进行read选项操作
echo '请选择菜单:
11.检查集群当前DB binlog-format
22.设置集群当前DB binlog-format'
read Num
for info in `cat config.info | grep ${1}`
do
cluster_name=`echo ${info} | awk -F ',' '{print $1}'`;
db_name=`echo ${info} | awk -F ',' '{print $2}'`;
bus_ip=`echo ${info} | awk -F ',' '{print $3}'`;
port=`echo ${info} | awk -F ',' '{print $4}'`;
bearer_ip=`echo ${info} | awk -F ',' '{print $5}'`;
case $Num in
11)
##检查集群当前DB binlog-format
sh check_binlog_format.sh ${cluster_name} ${db_name} ${bus_ip} ${port} ${bearer_ip}
;;
22)
##设置集群当前DB binlog-format
sh change_binlog_format.sh ${cluster_name} ${db_name} ${bus_ip} ${port} ${bearer_ip}
;;
esac
done