Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does the SHELL script check whether the Oracle DG repository has applied archiving?

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you how the SHELL script to check whether the Oracle DG library has been used for archiving, I believe most people do not know much about it, so share this article for your reference, I hope you will learn a lot after reading this article, let's go to know it!

Automatically check whether the archived shell script has been applied to the Oracle DG repository:

PS: this script needs to create table:ARC_NOT_REPLY_LOG first. This table is used to store records. If you do not need to store records, you can delete the insert of the shell script.

ARC_NOT_REPLY_LOG creation script:

CREATE TABLE ORAM.ARC_NOT_REPLY_LOG (HOSTNAME VARCHAR2 (50 BYTE), NAME VARCHAR2 (100 BYTE), SEQUENCE NUMBER, APPLIED VARCHAR2 (3 BYTE), COMPLETION_TIME VARCHAR2 (50 BYTE), ADD_TIME DATE DEFAULT SYSDATE)

The content of the shell script:

#! / bin/bash#by Dbabc.net 2012/02/02#User specific environment and startup programs#if [- f ~ / .bash_profile]; then. ~ / .bash_profilefiexport DBAEMAIL=dbabc@dbabc.netexport ORACLE_SID=dbabcexport IP='10.8.8.1'export SMTP='smtp.dbabc.net'export FRUSER='dba@dbabc.net'export BCCUSER='dba@dbabc.net'export USERPWD='pwd'VALUE= `$ ORACLE_HOME/bin/sqlplus-S / nolog < < EOFset heading off feedback off pagesize 0 verify off echo off numwidth 4connect / as sysdbaselect count (*) from v\\ $archived_log where applied='NO'; exitEOF`if ["$VALUE"-gt 0] Then$ORACLE_HOME/bin/sqlplus-S / nolog > arc_not_reply.log < < EOFset heading off feedback off pagesize 0 verify off echo offset lines 200col name format a60connect / as sysdbaalter session set nls_date_format='YYYY-MM-DDHH24:MI:SS';select'$IP',name,sequence#,applied,completion_time from v\ $archived_log where applied='NO' ExitEOFcat arc_not_reply.log | rev | awk {'print $1 "$2" $3 "$4"$5'} | rev | awk {' print" insert into ARC_NOT_REPLY_LOG (hostname,name,SEQUENCE,applied,COMPLETION_TIME) values (# "$1" #, # "$2" #, "$3", # "$4" #, # "$5" #) "'} | grep-v'# #'| grep-v'# on#' | sed" sqqqpxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx "| sed" s/ip/ "${v_hostip}" / g "> ARC_NOT_REPLY_LOG.sql # echo "insert into ARC_NOT_REPLY_LOG (hostname,name,SEQUENCE#,applied,COMPLETION_TIME) values ('${INTV1}','${INTV2}','${INTV3}','${INTV4}','${INTV5}');" > ARC_NOT_REPLY_LOG.sql;$ORACLE_HOME/bin/sqlplus / nolog < < EOFconnect oram/oram@10.8.8.4:1521/yqpt@ARC_NOT_REPLY_LOG.sqlcommit;exit " EOF/usr/local/bin/sendEmail-f $FRUSER-t ${DBAEMAIL}-bcc $BCCUSER-s $SMTP-u "$IP arclog not reply"-o message-file=arc_not_reply.log-xu "$FRUSER"-xp "$USERPWD" exitelseecho `date +'% T'` "All the archive log have replyed" > arc_replyok.txt/usr/local/bin/sendEmail-f $FRUSER-t ${DBAEMAIL}-bcc $BCCUSER-s $SMTP-u "$IP arc_replyok"-o message-file=arc_replyok. Txt-xu "$FRUSER"-xp "$USERPWD" fiexit

Just modify the variables, < < to half-width format, wordpress will automatically convert half-width < <.

Then run the script regularly through crontab to achieve Email early warning.

In fact, the areas that need to be modified are as follows:

#! / bin/bash

# by Dbabc.net 2012-02-02

# User specific environment and startup programs

#

If [- f ~ / .bash_profile]; then

. ~ / .bash_profile

Fi

Export DBAEMAIL=dbabc@dbabc.net

Export ORACLE_SID=dbabc

Export IP='10.8.8.1'

Export SMTP='smtp.dbabc.net'

Export FRUSER='dba@dbabc.net'

Export BCCUSER='dba@dbabc.net'

Export USERPWD='pwd'

VALUE= `$ ORACLE_HOME/bin/sqlplus-S / nolog < < EOF

Set heading off feedback off pagesize 0 verify off echo off numwidth 4

Connect / as sysdba

Select count (*) from v\\ $archived_log where applied='NO'

Exit

EOF`

If ["$VALUE"-gt 0]; then

$ORACLE_HOME/bin/sqlplus-S / nolog > arc_not_reply.log < < EOF

Set heading off feedback off pagesize 0 verify off echo off

Set lines 200

Col name format a60

Connect / as sysdba

Alter session set nls_date_format='YYYY-MM-DDHH24:MI:SS'

Select'$IP',name,sequence#,applied,completion_time from v\ $archived_log where applied='NO'

Exit

EOF

Cat arc_not_reply.log | rev | awk {'print $1 "$2" $3 "$4"$5'} | rev | awk {' print" insert into ARC_NOT_REPLY_LOG (hostname,name,SEQUENCE,applied,COMPLETION_TIME) values (# "$1" #, # "$2" #, "$3", # "$4" #, # "$5" #) "'} | grep-v'# #'| grep-v'# on#' | sed" sqqqpxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx "| sed" s/ip/ "${v_hostip}" / g "> ARC_NOT_REPLY_LOG.sql

# echo "insert into ARC_NOT_REPLY_LOG (hostname,name,SEQUENCE#,applied,COMPLETION_TIME) values ('${INTV1}','${INTV2}','${INTV3}','${INTV4}','${INTV5}');" > ARC_NOT_REPLY_LOG.sql

$ORACLE_HOME/bin/sqlplus / nolog < < EOF

Connect oram/oram@10.8.8.4:1521/yqpt

@ ARC_NOT_REPLY_LOG.sql

Commit

Exit

EOF

/ usr/local/bin/sendEmail-f $FRUSER-t ${DBAEMAIL}-bcc $BCCUSER-s $SMTP-u "$IP arclog not reply"-o message-file=arc_not_reply.log-xu "$FRUSER"-xp "$USERPWD"

Exit

Else

Echo `date +'% F% T'` "All the archive log have replyed" > arc_replyok.txt

/ usr/local/bin/sendEmail-f $FRUSER-t ${DBAEMAIL}-bcc $BCCUSER-s $SMTP-u "$IP arc_replyok"-o message-file=arc_replyok.txt-xu "$FRUSER"-xp "$USERPWD"

Fi

Exit

Also, / usr/local/bin/sendEmail is a command, so you need to install sendEmail in order to execute successfully

The installation steps are as follows:

SendEmail download address: http://caspian.dotconf.net/menu/Software/SendEmail/

# wget http://caspian.dotconf.net/menu/Software/SendEmail/sendEmail-v1.56.tar.gz / / download version 1.56

# tar-xzvf sendEmail-v1.56.tar.gz / / can be used after decompression

# mv sendEmail / usr/local/bin/

The above is all the contents of the article "how to check whether the Oracle DG repository has been archived by SHELL scripts". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report