Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2342983
  • 博文数量: 535
  • 博客积分: 8689
  • 博客等级: 中将
  • 技术积分: 7066
  • 用 户 组: 普通用户
  • 注册时间: 2010-11-26 10:00
文章分类

全部博文(535)

文章存档

2024年(4)

2023年(4)

2022年(16)

2014年(90)

2013年(76)

2012年(125)

2011年(184)

2010年(37)

分类: LINUX

2014-09-05 14:45:44





cat ora_admin.sh
shutdown_ora()
{
ps -ef|grep lsnr|grep -v grep|awk -v ora_user="$USER" '$1==ora_user{print $(NF-1)}' >~/lsnr.$USER
ps -ef|grep pmon|grep -v grep|awk -v ora_user="$USER" '$1==ora_user{print $NF}'|awk -F _ '{print $NF}' >~/sid.$USER
cat ~/sid.$USER|while read sid
do
export ORACLE_SID=$sid
sqlplus /nolog< conn /as sysdba
shutdown immediate
exit
!
done
}

startup_ora()
{
cat ~/lsnr.$USER|while read lsnr
do
lsnrctl start $lsnr
done

cat ~/sid.$USER|while read sid
do
export ORACLE_SID=$sid
sqlplus /nolog< conn /as sysdba
startup
exit
!
done
}

case $1 in
stop)
  shutdown_ora;;
start)
  startup_ora;;
esac





 cat start_lp.sh
cat list | while read line
echo $line -----------------------------------------------------------------
do
sshpass -p root8cat scp -o "StrictHostKeyChecking=no" /opt/start_ora.sh root@${line}:/
sshpass -p root8cat ssh -o "StrictHostKeyChecking=no" root@${line} < su - oracle -c sh /start_ora.sh
mv /start_ora.sh /start_ora.sh.last
!
done







 cat  ora_admin.sh
shutdown_ora()
{
ps -ef|grep lsnr|grep -v grep|awk -v ora_user="$USER" '$1==ora_user{print $(NF-1)}' >~/lsnr.$USER
ps -ef|grep pmon|grep -v grep|awk -v ora_user="$USER" '$1==ora_user{print $NF}'|awk -F _ '{print $NF}' >~/sid.$USER
cat ~/sid.$USER|while read sid
do
export ORACLE_SID=$sid
sqlplus /nolog< conn /as sysdba
shutdown immediate
exit
!
done
}

startup_ora()
{
cat ~/lsnr.$USER|while read lsnr
do
lsnrctl start $lsnr
done

cat ~/sid.$USER|while read sid
do
export ORACLE_SID=$sid
sqlplus /nolog< conn /as sysdba
startup
exit
!
done
}

case $1 in
stop)
  shutdown_ora;;
start)
  startup_ora;;
esac






cat lp.sh
export chose=$1
cat lp.list | while read line
do
  echo $line ---------------------------------------------------------
  for i in root root8cat
  do
    sshpass -p $i scp -o "StrictHostKeyChecking=no" *_admin.sh root@${line}:/tmp/
    if [ $? = 0 ];then
    sshpass -p $i ssh -o "StrictHostKeyChecking=no" root@${line} "/tmp/lp_admin.sh $chose"
    break
    fi
  done
done











cat  lp_admin.sh
df -k > /tmp/df.txt
ps -ef|grep java >/tmp/java.txt
shutdown_os()
{
ps -ef|grep pmon |grep -v grep |awk '{print $1}' >/tmp/ora_user.txt
cat /tmp/ora_user.txt|while read ora_user
do
  su - $ora_user -c "/tmp/ora_admin.sh stop"
done

count=`ps -ef|grep pmon |grep -v grep |awk '{print $1}'|wc -l`
if [ $count = 0 ];then
   nohup shutdown -F >/dev/null &
else
  echo "oracle still running."
fi
}

open_os()
{
if [ -s /tmp/ora_user.txt ];then
  cat /tmp/ora_user.txt|while read ora_user
  do
    su - $ora_user -c "/tmp/ora_admin.sh start"
  done
else
  echo "not fund oracle users ,can not startup instance"
fi
if [ -e  /websphere/IBM/WebSphere/AppServer/profiles/Dmgr01/bin/startManager.sh ];then
  chown -R wasadmin:wasadmg  /websphere
  su - wasadmin -c "/websphere/IBM/WebSphere/AppServer/profiles/Dmgr01/bin/startManager.sh"
  su - wasadmin -c "/websphere/IBM/WebSphere/AppServer/profiles/AppSrv01/bin/startNode.sh"
fi
}

case $1 in
start)
  open_os;;
stop)
  shutdown_os;;
esac











 cat  shut_lp.sh
cat list | while read line
do
echo $line ---------------------------------------------------------
sshpass -p root8cat scp -o "StrictHostKeyChecking=no" /opt/shut_ora.sh root@${line}:/
sshpass -p root8cat ssh -o "StrictHostKeyChecking=no" root@${line} < df -g >>/opt/df.txt
ps -ef|grep pmon|grep -v grep  |awk '{print $1,$9}'>>/sid.txt
ps -ef|grep lsnr|awk -F   "tnslsnr " '{print $2}'|awk '{print $1}' >/lsnr.txt
ps -ef|grep java >>/ps.txt
cat /sid.txt|while read sid
do
user=`echo $sid|awk '{print $1}'`
ora_sid=`echo $sid|awk -F _ '{print $2}'`
su - $user -c sh /shut_ora.sh
done
if [ $? = 0 ];then
nohup shutdown -F >/dev/null &
fi
mv /shut_ora.sh /shut_ora.sh.last
exit
!
done
















cat  shut_lp.sh
cat list | while read line
do
echo $line ---------------------------------------------------------
sshpass -p root8cat scp -o "StrictHostKeyChecking=no" /opt/shut_ora.sh root@${line}:/
sshpass -p root8cat ssh -o "StrictHostKeyChecking=no" root@${line} < df -g >>/opt/df.txt
ps -ef|grep pmon|grep -v grep  |awk '{print $1,$9}'>>/sid.txt
ps -ef|grep lsnr|awk -F   "tnslsnr " '{print $2}'|awk '{print $1}' >/lsnr.txt
ps -ef|grep java >>/ps.txt
cat /sid.txt|while read sid
do
user=`echo $sid|awk '{print $1}'`
ora_sid=`echo $sid|awk -F _ '{print $2}'`
su - $user -c sh /shut_ora.sh
done
if [ $? = 0 ];then
nohup shutdown -F >/dev/null &
fi
mv /shut_ora.sh /shut_ora.sh.last
exit
!
done
[root@localhost opt]# cat shut_ora.sh
export ORACLE_SID=$ora_sid
sqlplus /nolog < conn /as sysdba
shutdown immediate
exit
!


















cat ora_admin.sh
shutdown_ora()
{
ps -ef|grep lsnr|grep -v grep|awk -v ora_user="$USER" '$1==ora_user{print $(NF-1)}' >~/lsnr.$USER
ps -ef|grep pmon|grep -v grep|awk -v ora_user="$USER" '$1==ora_user{print $NF}'|awk -F _ '{print $NF}' >~/sid.$USER
cat ~/sid.$USER|while read sid
do
export ORACLE_SID=$sid
sqlplus /nolog< conn /as sysdba
shutdown immediate
exit
!
done
}

startup_ora()
{
cat ~/lsnr.$USER|while read lsnr
do
lsnrctl start $lsnr
done

cat ~/sid.$USER|while read sid
do
export ORACLE_SID=$sid
sqlplus /nolog< conn /as sysdba
startup
exit
!
done
}

case $1 in
stop)
  shutdown_ora;;
start)
  startup_ora;;
esac





10.14.58.136/opt 目录下
lp.sh
lp_admin.sh
ora_admin.sh
lp.list

关闭操作执行./lp.sh stop
启动./lp.sh start

需要把ip清单放进lp.list文件里,尝试登陆密码root root8cat ,如果还有其他密码,修改lp.sh,在for循环添加,空格分隔,例如添加密码p1、p2

cat lp.list | while read line
do
  echo $line ---------------------------------------------------------
  for i in root root8cat p1 p2
  do

脚本除了启动oracle,还可以启动标志安装的was的dmgr和nodeagent { /websphere/IBM/WebSphere/AppServer/profiles/ }。



阅读(3594) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~