暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

开关一台服务器上所有的oracle侦听

原创 --聽海之乐-- 2020-10-17
560

#!/usr/bin/sh
#+++++++++++++++++++++++++++++++++++++++++++++

stop and start all oracle database listener in a server

Param 1 : -stop |start

#+++++++++++++++++++++++++++++++++++++++++++++
#############################################

Start the tnslistener

#############################################
start_tnslstnr()
{
echo $(date) “Start TNSLISTENER name $oralistner for Database $oraid”
su - $oraid -c “lsnrctl start $oralistner ; wait” >/dev/null 2>&1 0</dev/null;
su - $oraid -c "lsnrctl status oralistner" 2>&1 0 if [ $RC -eq 0 ]
then
echo $(date) “DONE : Start TNSLISTENER $oralistner”;
else
echo “=";
echo “”
echo “”
echo $(date) "WARNING: Start TNSLISTENER oraidRC="oraid RC="RC;
echo "
=”;
echo “”
echo “”
echo “”
fi
}

#############################################

stop the tnslistener

#############################################
stop_tnslstnr()
{
echo $(date) “Start TNSLISTENER name $oralistner for Database $oraid”
su - $oraid -c “lsnrctl stop $oralistner ; wait” >/dev/null 2>&1 0</dev/null;
su - $oraid -c "lsnrctl status oralistner" 2>&1 0 if [ $RC -eq 0 ]
then
echo $(date) “DONE : Stop TNSLISTENER $oralistner”;
else
echo “##################################################################”;
echo “”
echo “”
echo $(date) "WARNING: Stop TNSLISTENER oraidRC="oraid RC="RC;
echo “##################################################################”;
echo “”
echo “”
echo “”
fi
}

#############################################

Start the tnslistener

#############################################
read_listener()
{
oralistners=(cat/tmp/(cat /tmp/oraid |grep -v “^#” |grep -v “SID_LIST”|grep -v “DESC” |grep -v “)”|grep -v “ADDRESS”)
oralistners=$(echo $oralistners|tr “=” " ")
for oralistner in $oralistners
do
case $action in
-start) start_tnslstnr
;;
-stop) stop_tnslstnr
;;
esac
done

if [ $RC -le 1 ]
then
case $action in
-start) echo “all the database listener on this server is started!!!”
;;
-stop) echo “all the database listener on this server is stopped!!!”
;;
esac
fi
}
#############################################

Main

#############################################
if [ $# -lt 1 ]
then
echo “##########################################################################################”
echo “”
echo "Syntax : stop oracle database listener listener <-start|-stop> " 1>&2
echo “”
echo “##########################################################################################”
exit 8
fi
action=$1

oraids=(cat/etc/groupgrepidbacutd:f4)oraids=(cat /etc/group|grep -i dba|cut -d ':' -f 4) oraids=(echo $oraids |tr “,” " ")
for oraid in $oraids
do
echo "oracle databse oraidisfoundandtryingtofoundlistenerfile";oraidlitener=oraid is found and trying to found listener file"; oraidlitener=(find / -name listener.ora|grep -v sample|grep -i $oraid);
echo $oraidlitener;
if [ -f oraidlitener]thenif[f/tmp/oraidlitener ] then if [ -f /tmp/oraid ]
then
rm -rf /tmp/$oraid
cat oraidlitener>/tmp/oraidlitener > /tmp/oraid
else
cat oraidlitener>/tmp/oraidlitener > /tmp/oraid
fi
read_listener;
fi
done

最后修改时间:2020-10-17 12:16:44
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论

目录
  • stop and start all oracle database listener in a server
  • Param 1 : -stop |start
  • Start the tnslistener
  • stop the tnslistener
  • Start the tnslistener
  • Main