脚本出处已忘了,目前大多数已是Oracle11g以上的版本了,该脚本使用也不多了,留着参考吧,就当扩展思路
del_arch_rman_primary.sh
#!/bin/bash or #!/bin/ksh
source ~/.bash_profile
####################################
# At primary host rac1
####################################
#------------Get max sequence from maxsequence.txt-----------------
SEQUENCE=`awk '{if (NR==1) print $1}' /home/oracle/script/orcl_max_sequence_non_th1.txt`
thread=`awk '{if (NR==1) print $2}' /home/oracle/script/orcl_max_sequence_non_th1.txt`
let "SEQUENCE_DEL=SEQUENCE - 10"
export ORACLE_SID=orcl1
echo "connect target /" > /home/oracle/script/del_arch_rman_primary.rcv
echo "run {" >> /home/oracle/script/del_arch_rman_primary.rcv
echo "allocate channel d1 type disk;" >> /home/oracle/script/del_arch_rman_primary.rcv
echo "delete archivelog until sequence $SEQUENCE_DEL thread $thread;" >> /home/oracle/script/del_arch_rman_primary.rcv
echo "crosscheck archivelog all;" >> /home/oracle/script/del_arch_rman_primary.rcv
echo "delete expired archivelog all;" >> /home/oracle/script/del_arch_rman_primary.rcv
echo "release channel d1; " >> /home/oracle/script/del_arch_rman_primary.rcv
echo "} " >> /home/oracle/script/del_arch_rman_primary.rcv
echo "run {" >> /home/oracle/script/del_arch_rman_primary.rcv
echo "crosscheck archivelog all;" >> /home/oracle/script/del_arch_rman_primary.rcv
echo "delete noprompt expired archivelog all;" >> /home/oracle/script/del_arch_rman_primary.rcv
echo "} " >> /home/oracle/script/del_arch_rman_primary.rcv
echo "exit " >> /home/oracle/script/del_arch_rman_primary.rcv
#----------------exec the del_arc_rman_primary.rcv scripts-------------------------
source ~/.bash_profile
export ORACLE_SID=orcl1
DATE=`date +%Y-%m-%d`
rman cmdfile=/home/oracle/script/del_arch_rman_primary.rcv log=/home/oracle/script/log/del_arch_rman_primary$DATE.log
[oracle@rac2 script]$ vi del_arch_rman_primary.sh
#!/bin/bash or #!/bin/ksh
source ~/.bash_profile
####################################
# At primary host rac2
####################################
#------------Get max sequence from maxsequence.txt-----------------
SEQUENCE=`awk '{if (NR==1) print $1}' /home/oracle/script/orcl_max_sequence_non_th2.txt`
thread=`awk '{if (NR==1) print $2}' /home/oracle/script/orcl_max_sequence_non_th2.txt`
let "SEQUENCE_DEL=SEQUENCE - 10"
export ORACLE_SID=orcl1
echo "connect target /" > /home/oracle/script/del_arch_rman_primary.rcv
echo "run {" >> /home/oracle/script/del_arch_rman_primary.rcv
echo "allocate channel d1 type disk;" >> /home/oracle/script/del_arch_rman_primary.rcv
echo "delete archivelog until sequence $SEQUENCE_DEL thread $thread;" >> /home/oracle/script/del_arch_rman_primary.rcv
echo "crosscheck archivelog all;" >> /home/oracle/script/del_arch_rman_primary.rcv
echo "delete expired archivelog all;" >> /home/oracle/script/del_arch_rman_primary.rcv
echo "release channel d1; " >> /home/oracle/script/del_arch_rman_primary.rcv
echo "} " >> /home/oracle/script/del_arch_rman_primary.rcv
echo "run {" >> /home/oracle/script/del_arch_rman_primary.rcv
echo "crosscheck archivelog all;" >> /home/oracle/script/del_arch_rman_primary.rcv
echo "delete noprompt expired archivelog all;" >> /home/oracle/script/del_arch_rman_primary.rcv
echo "} " >> /home/oracle/script/del_arch_rman_primary.rcv
echo "exit " >> /home/oracle/script/del_arch_rman_primary.rcv
#----------------exec the del_arc_rman_primary.rcv scripts-------------------------
source ~/.bash_profile
export ORACLE_SID=orcl2
DATE=`date +%Y-%m-%d`
rman cmdfile=/home/oracle/script/del_arch_rman_primary.rcv log=/home/oracle/script/log/del_arch_rman_primary$DATE.log
crontab -l
30 1 * * 3,6 sh /home/oracle/script/del_arch_rman_primary.sh
=====================================================================================
dataguard-standby!!!!!
config ssh authorized key!!!!!!!!!!!!!!!!!
[oracle@rac1 script]$ scp /home/oracle/script/orcl_max_sequence_non_th1.txt 192.168.8.16:/home/oracle/script/
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
7f:6a:b6:4b:f1:81:89:3f:04:61:a1:bb:40:1e:9f:e7.
Please contact your system administrator.
Add correct host key in /home/oracle/.ssh/known_hosts to get rid of trac message.
Offending key in /home/oracle/.ssh/known_hosts:5
RSA host key for 192.168.8.16 has changed and you have requested strict checking.
Host key verification failed.
lost connection
[oracle@rac1 script]$
need delete local (/home/oracle/.ssh/known_hosts) 192.168.8.16 rsa info!!!!!!!!!!!!!!!!!!!!
1
192.168.8.17
$ ssh oracle@192.168.8.16 cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
$ ssh oracle@192.168.8.16 cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
192.168.8.16
$ ssh oracle@192.168.8.17 cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
$ ssh oracle@192.168.8.17 cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
2
192.168.8.17
$ ssh oracle@212.7.8.4 cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
212.7.8.4
$ ssh oracle@192.168.8.17 cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
get_last_sequence_dg.sh
#!/bin/bash or #!/bin/ksh
####################################
# At standby host rac1
####################################
#---get orcl instance's sequence which is already applied---
source ~/.bash_profile
export ORACLE_SID=orcl1
sqlplus -s /nolog< /home/oracle/script/orcl_max_sequence_non_th1.txt
host sed /^$/d /home/oracle/script/orcl_max_sequence_thread2.txt > /home/oracle/script/orcl_max_sequence_non_th2.txt
host rm -rf /home/oracle/script/orcl_max_sequence_thread1.txt
host rm -rf /home/oracle/script/orcl_max_sequence_thread2.txt
host scp /home/oracle/script/orcl_max_sequence_non_th1.txt 192.168.8.16:/home/oracle/script/
host scp /home/oracle/script/orcl_max_sequence_non_th2.txt 192.168.8.17:/home/oracle/script/
exit
EOF
crontab -l
10 1 * * 3,6 sh /home/oracle/script/get_lastest_sequenct_dg.sh
==========================
del_arch_rman_standby.sh
#!/bin/bash or #!/bin/ksh
DATE=`date +%Y-%m-%d-H`
source ~/.bash_profile
export ORACLE_SID=orcl1
rman log=/home/oracle/script/log/del_arch_rman$DATE.log append <