If we have multiple instances running on one servers and some script we need to run on all db's, then its good we use below script to set ORACLE_SID and login and run the script.
This specially used for below scenario:
for i in `ps -aef | grep pmon |awk '{print $8}' | egrep -i -v 'grep|asm' | cut -d "_" -f3`
do
echo "ORACLE_SID $i : `hostname`"
export ORACLE_SID=$i
sqlplus -s / as sysdba <<EOF
set lin 180
select instance_name,host_name from v\$instance;
srvctl status database -d $i
exit
EOF
done
awk index = oracle instr
[oracle@node1 ~]$ cat /etc/oratab | egrep node | grep -v '#B' | awk -F ':' '{print substr($1,1,index($1,"1")-1)}'
node
[oracle@node1 ~]$
Filter blank lines
cat /etc/oratab | grep -v '^$'
This specially used for below scenario:
- DB level patching in one go.
- While patching take snap of before and after patch.
- Some DB level script for reporting.
for i in `ps -aef | grep pmon |awk '{print $8}' | egrep -i -v 'grep|asm' | cut -d "_" -f3`
do
echo "ORACLE_SID $i : `hostname`"
export ORACLE_SID=$i
sqlplus -s / as sysdba <<EOF
set lin 180
select instance_name,host_name from v\$instance;
srvctl status database -d $i
exit
EOF
done
awk index = oracle instr
[oracle@node1 ~]$ cat /etc/oratab | egrep node | grep -v '#B' | awk -F ':' '{print substr($1,1,index($1,"1")-1)}'
node
[oracle@node1 ~]$
Filter blank lines
cat /etc/oratab | grep -v '^$'
No comments:
Post a Comment