Anda di halaman 1dari 57

#!/bin/ksh # ############################################################################# ##### # Script Name: sqlall.

ksh # # Usage: This script is used to run the same SQL statement(s) on # More than one DB instance from a centralized server. # # Requirements: # - The centralized server should have all the tnsnames # for all the DB instances. # - This script uses a configuration file with the list of servers,DBS # and user/pwd to be used during the sql run (ALLSERVERS). See below. # # Syntax : sqlall.ksh sql_script.sql server_name(s)_pattern # # Auther: Laith Hussein ( Senior Oracle DBA) # DATE : March - 9 - 2003 # # To send the output logs to your email, please change the variable DBA_EMAIL # ############################################################################# #### # Oracle Env Parametes export ORACLE_SID=`grep -i "ORACLE_SID=" /home/oracle/.profile | awk -F'=' '{print $2}'` export ORACLE_BASE=/apps/opt/oracle export ORACLE_HOME=/apps/opt/oracle/product/8.1.7 export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib export PATH=$PATH:/usr/local/bin:/apps/opt/oracle/product/8.1.7/bin:$ORACLE_HOME/lib export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib export ORAENV_ASK=NO # Script Parameters export BASEDIR=/home/oracle/dba/deploy export LOGDIR=$BASEDIR/log export SQL_DIR=/home/oracle/dba/deploy/sql # Change before run export DBA_EMAIL=youremail@company.com # Usage Desc and Check USAGE="usage: $0 sql_script server_name_pattern \n" if [ $# -ne 2 ] then echo "$0: error: incorrect arguments...\n" echo $USAGE exit 1 fi if [ ! -f ${SQL_DIR}/$1 ] then

echo " ${SQL_DIR}/$1 file is not found ...\n" exit 1 fi SQL_SCRIPT=$1 SERVERS=$2 DICTFILE=${BASEDIR}/ALLSERVERS export LOG=${LOGDIR}/$SQL_SCRIPT.log >$LOG # Clear the screen and display the sql script clear scr echo ======================= echo Script : ${SQL_SCRIPT} echo contains ... echo head -1 ${SQL_DIR}/${SQL_SCRIPT} echo ======================= echo # Dsiplay the DB names affected. echo Databases affected are : for db in `grep -v "^#" $DICTFILE | grep "${SERVERS}" ` do ENVIR=`grep -i "${db}" $DICTFILE | awk -F':' '{print $1}'` HOSTNAME=`grep -i "${db}" $DICTFILE | awk -F':' '{print $2}'` IPADDRESS=`grep -i "${db}" $DICTFILE | awk -F':' '{print $3}'` DB_NAME=`grep -i "${db}" $DICTFILE | awk -F':' '{print $4}'` USERNAME=`grep -i "${db}" $DICTFILE | awk -F':' '{print $5}'` USERPWD=`grep -i "${db}" $DICTFILE | awk -F':' '{print $6}'` echo ${ENVIR} : $HOSTNAME : $IPADDRESS : $DB_NAME : $USERNAME done # Confirm if you need to run agains the above list of DBs echo ======================= echo "Continue [Y/N] [N]? \c" ANS=N read ANS if [ "${ANS}" = "N" ] then exit; fi # Run the sql script on all the confirmed list of DBs if [ "${ANS}" = "Y" ] || [ "${ANS}" = "y" ] then for db in `grep -v "^#" $DICTFILE | grep "${SERVERS}" ` do HOSTNAME=`grep -i "${db}" $DICTFILE | awk -F':' '{print $2}'`

IPADDRESS=`grep -i "${db}" $DICTFILE | awk -F':' '{print $3}'` DB_NAME=`grep -i "${db}" $DICTFILE | awk -F':' '{print $4}'` USERNAME=`grep -i "${db}" $DICTFILE | awk -F':' '{print $5}'` USERPWD=`grep -i "${db}" $DICTFILE | awk -F':' '{print $6}'` export DB_LOG=${LOGDIR}/${HOSTNAME}_${DB_NAME}.out echo ============================================================ > $DB_LOG echo RUN this script $SQL_SCRIPT on $HOSTNAME:$IPADDRESS : $DB_NAME >> $DB_LOG echo ============================================================ >> $DB_LOG echo $HOSTNAME : $DB_NAME : $USERNAME sqlplus -s ${USERNAME}/${USERPWD}@${DB_NAME} @${SQL_DIR}/${SQL_SCRIPT} >> $DB_LOG cat $DB_LOG >> $LOG done # Send email to DBA address. mailx -s "${SQL_SCRIPT}" < $LOG $DBA_EMAIL fi # EOF # --------------------------------------------------------------------# --------------------------------------------------------------------# config file: # DB Server info Config file for sqlall.ksh script # Format: # Environment:servername:ipaddress:dbnameintnsnames.ora:dbuser:dbuserpassword # #Auther: Laith Hussein # #:::: DEV DEV:servername1:ip_address:dbname:dbuser:passwd DEV:servername2:ip_address:dbname:dbuser:passwd DEV:servername3:ip_address:dbname:dbuser:passwd DEV:servername4:ip_address:dbname:dbuser:passwd DEV:servername5:ip_address:dbname:dbuser:passwd DEV:servername6:ip_address:dbname:dbuser:passwd DEV:servername7:ip_address:dbname:dbuser:passwd #:::: PROD PROD:servername1:ip_address:dbname:dbuser:passwd PROD:servername2:ip_address:dbname:dbuser:passwd PROD:servername3:ip_address:dbname:dbuser:passwd PROD:servername4:ip_address:dbname:dbuser:passwd PROD:servername5:ip_address:dbname:dbuser:passwd PROD:servername6:ip_address:dbname:dbuser:passwd PROD:servername7:ip_address:dbname:dbuser:passwd # EOF

#!/usr/bin/ksh #-----------------------------------------------------------------------------------------------

usage() #----------------------------------------------------------------------------------------------{ cat <<END Filename Version Summary : dba_alertlog.ksh : 1.0 : Print alertlog messages with date/time stamp on the same line. : Default alertlog entries have a date, and then the message on the next line. Parameters : Mandatory: : No parameters are mandatory. : If no parameters are supplied then the alert log for the current ORACLE_SID will : be displayed. : Optional: : Filename(s) of the alertlogs to be processed. Calls Date 20-Aug-04 : No other scripts Author ASBlack Version 1.0 Created. To get a program flow execute:

NOTES: 1) This script is self documented. grep "#-- " dba_alertlog.ksh

EXAMPLES: 1) dba_alertlog.ksh This will display the contents of the current alert log for the ORACLE_SID that is currently set 2) dba_alertlog.ksh alert_somesid.log.2004* This will display the contents of all alert logs that have are named alertsomesid.log.2004* which can be produced if automated housekeeping of the alertlogs has been implemented to "roll over" alertlogs daily or weekly ... END } #----------------------------------------------------------------------------------------------# MAIN PROGRAM STARTS HERE #----------------------------------------------------------------------------------------------#-- Display usage if requested if [[ ${1} = "help" ]]; then usage; exit 0; fi #-- Set variables PRG=`basename $0` LOGFILES="" CMD=""

#-- Get command line parameters if [ $# -ne 0 ]; then LOGFILES=$@; fi #-- Echo start time and command date +"%Y/%m/%d %H:%M:$S Started ${PRG} ${PARAMETERS}" echo #-- Determine the location of the alert log if not specified if [ -z "${LOGFILES}" ]; then #-- Determine the ORACLE_HOME ORAHOME="" ORAHOME=`grep -h "^${ORACLE_SID}:" /var/opt/oracle/oratab /etc/oratab 2>/dev/null |head -1 |awk -F":" '{print $2}'` if [[ -z "${ORAHOME}" ]]; then echo "ERROR: Cannot determine ORACLE_HOME for ${ORACLE_SID} ..." exit 10 fi #-- Determine if there is an spfile SPFILE=${ORAHOME}/dbs/spfile${ORACLE_SID}.ora #-- If there isn't an spfile then use the init.ora file if [[ ! -f ${SPFILE} ]]; then #-- Determine where the init.ora file is INITORA=${ORAHOME}/dbs/init${ORACLE_SID}.ora echo INITORA = ${INITORA} #-- Determine if there is an ifile IFILE=`egrep -i "ifile|spfile" ${INITORA} |grep -v "^#" |head -1 |awk F"=" '{print $2}' |sed -e 's/[ ]//g' -e "s/'//g"` echo IFILE = ${IFILE} fi #-- Determine what background_dump_dest is set to in the init.ora file # (It defaults to ?/rdbms/log within the database if it's not in the init.ora file) BACKGROUND_DUMP_DEST=`grep -i "background_dump_dest" ${SPFILE} ${INITORA} ${IFILE} 2>/dev/null |grep -v "^#" |head -1 |awk -F"=" '{print $2}' |sed -e 's/[ ][ ]*//g' -e "s/'//g"` if [ -z "${BACKGROUND_DUMP_DEST}" ]; then BACKGROUND_DUMP_DEST=${ORACLE_HOME}/rdbms/log fi #-- Ensure that $ORACLE_HOME is expanded out # This fixes a strange bug when running remotely, and # background_dump_dest contains string: $ORACLE_HOME eval BACKGROUND_DUMP_DEST=`echo ${BACKGROUND_DUMP_DEST} |sed -e "s+\$ORACLE_HOME+${ORAHOME}+"` #-- Determine where the alertlog file is LOGFILES=${BACKGROUND_DUMP_DEST}/alert_${ORACLE_SID}.log fi

#-- Check the log file(s) exist and are readable for FILE in ${LOGFILES} do #-- Check that the file exist and is readable if [ ! -r "${FILE}" ]; then echo date +"%Y/%m/%d %H:%M:%S ERROR: Log ${FILE} does not exist or is not readable" echo break fi #-- List alertlog for reference echo date +"%Y/%m/%d %H:%M:%S Processing alertlog ${FILE}" ls -l ${FILE} echo #-- Get the command to send the alertlog to stdout if [ `echo ${FILE} |grep -c ".gz$"` -eq 1 ]; then CMD="gzip -dc ${FILE}" elif [ `echo ${FILE} |grep -c ".Z$"` -eq 1 ]; then CMD="zcat ${FILE}" else CMD="cat ${FILE}" fi #-- Print out the alert log with time stamps at the start of each record #-- Note that date's in the alert log have the format: #-Fri Aug 16 12:52:55 2002 echo ${CMD} |ksh \ |awk '{ if($1=="Mon" || $1=="Tue" || $1=="Wed" || $1=="Thu" || $1=="Fri" || $1=="Sat" || $1=="Sun") { DAY=$1 TIME=$4 YEAR=$5 DATE=$3 if(length(DATE)==1){DATE="0"DATE} if($2=="Jan"){MONTH="01"} if($2=="Feb"){MONTH="02"} if($2=="Mar"){MONTH="03"} if($2=="Apr"){MONTH="04"} if($2=="May"){MONTH="05"} if($2=="Jun"){MONTH="06"} if($2=="Jul"){MONTH="07"} if($2=="Aug"){MONTH="08"} if($2=="Sep"){MONTH="09"} if($2=="Oct"){MONTH="10"} if($2=="Nov"){MONTH="11"} if($2=="Dec"){MONTH="12"}

} else { print YEAR"/"MONTH"/"DATE" "DAY" "TIME" "$0 } }' done # End of loop for FILE

#!/bin/ksh # #============================================================================ =================== # # ORACLE Trace File Management # # Checks for new Tracefiles and alerts DBA via mail # # Copyright (C) Alexander Venzke 2000 # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # #============================================================================ =================== # # A simple script that checks for tracefiles in udump/cdump destinations (OFA!) and # send DBA a mail with errocode, information or if that trace is just a SQL trace # renames that file # # if you're using that script - please feel free to send me some feedback or just # what you think about that programm. # # Author : Alexander Venzke (Alexander.Venzke@gmx.net / Alexander.Venzke@dab.com) # #============================================================================ =================== # # Variablen

# # your path env should include path to oraenv (/usr/local/bin or $ORACLE_HOME/bin) dba=yourmail@mail.host #============================================================================ =================== # # sendmail # #============================================================================ =================== send_mail () { mailx -s "OTFCheck from host $(hostname) ad $(date)" $dba < $1 rm -f $1 } #============================================================================ =================== # # file_delete # deletes old files (15 days) # #============================================================================ =================== file_check () { cd $1 find . -name \*.ut -mtime +15 -exec rm {} \; } #============================================================================ =================== # # check_trace # checking new tracefiles # #============================================================================ =================== check_trace () { cd $1 for tracefile in `ls -l *.trc 2>/dev/null | awk '{print $9}'` do datetime=` date +"%y%m%d_%H%M%S"` cat ${tracefile} | grep "PARSING IN CURSOR" > /dev/null

if [ $? = 0 ] ; then # Usertracefile mv ${tracefile} usertrace_${ORACLE_SID}_${datetime}.ut else cat ${tracefile} | grep "ORA-" > /dev/null if [ $? = 0 ] ; then # ORA error errorcode=`cat ${tracefile} | grep "ORA-"` echo "Found error in tracefile ${tracefile}_processed.${datetime}.error" >/tmp/$datetime.mail echo "=====================================" >>/tmp/$datetime.mail echo "${errorcode}" >>/tmp/$datetime.mail echo "=====================================" >>/tmp/$datetime.mail mv ${tracefile} ${tracefile}_processed.${datetime}.error else cat ${tracefile} | grep -i "deadlock" > /dev/null if [ $? = 0 ] ; then # deadlock echo "Found deadlock in tracefile ${tracefile}_processed.${datetime}.deadlock" >/tmp/$datetime.mail mv ${tracefile} ${tracefile}_processed.${datetime}.deadlock else # other error .. echo "Found unknown error in tracefile ${tracefile}_processed.${datetime}.unknownerror" >/tmp/$datetime.mail echo "Please check this file manually" >>/tmp/$datetime.mail mv ${tracefile} ${tracefile}_processed.${datetime}.unknownerror fi fi fi if [ -f /tmp/$datetime.mail ] ; then send_mail /tmp/$datetime.mail fi done } #============================================================================ =================== # # Main Procedure # #============================================================================ =================== # # # where is the oratab file

if [ -r /etc/oratab ] then ORATAB=/etc/oratab else if [ -r /var/opt/oracle/oratab ] then ORATAB=/var/opt/oracle/oratab else echo "Can't find any oratab file" exit 1 fi fi # # Process oratab file # cat $ORATAB | while read LINE do case $LINE in \#*) ;; '') ;; *) ORACLE_SID=`echo $LINE | awk -F: '{print $1}' -` if [ "$ORACLE_SID" != '*' ] then ORAENV_ASK=NO . oraenv # deleting old files (.ut) file_check $ORACLE_BASE/admin/$ORACLE_SID/udump # processing trace files check_trace $ORACLE_BASE/admin/$ORACLE_SID/bdump check_trace $ORACLE_BASE/admin/$ORACLE_SID/udump fi ;; esac done

#!/bin/ksh #***********************************************# # # # Name : alertswitch.ksh # # Created : 2000/03/20 # # Purpose : Program runs at 23:57 every day to # # rename day's alert log to file # # alert_$db.log$DAY. # # Program will check for alert.logs # # in $ORACLE_HOME/rdbms/log and the # # background_dump_dest directories. # # All sqlnet logs are also renamed. #

# All corefiles are cleaned up and # # DBA notified of new corefiles. # # # #***********************************************# FILENAME=`date '+%a'` WORKDIR=/usr1/app/oracle/product/8.0.5/home GENSQL=genswitch.sql SYSTEM_001PR=`cat /var/opt/oracle/SYSTEM_001P` ERRFILE=err.out SIDFILE=sidfile # ps -ef | grep pmon | grep -v grep | awk '{print $9}' | cut -c10-17 > $WORKDIR/$SIDFILE #-----------------------------------------------# # Logs in RDBMS/LOG : # #-----------------------------------------------# echo "Rename Alertlogs in RDBMS/LOG" echo "-----------------------------" HOMEDIR=$ORACLE_HOME/rdbms/log cd $HOMEDIR for i in `ls alert*.log` do echo ......Rename $i to $i$FILENAME cp $i $i$FILENAME > $i done # #-----------------------------------------------# # Logs in BDUMP : # #-----------------------------------------------# # echo "Rename Alertlogs in BDUMP" echo "-------------------------" cat $WORKDIR/$SIDFILE | while read siddie do export ORACLE_SID=$siddie echo " Renaming alertlogs for SID : $ORACLE_SID" echo " ---------------------------------" echo "set heading off" > $WORKDIR/$GENSQL echo "set pages 0" >> $WORKDIR/$GENSQL echo "set feed off " >> $WORKDIR/$GENSQL echo "set echo off" >> $WORKDIR/$GENSQL echo "select rtrim(value) from v\$parameter where name = 'background_dump_dest';" >> $WORKDIR/$GENSQL echo "exit;" >> $WORKDIR/$GENSQL BACKGROUNDDUMP=`sqlplus -s system/$SYSTEM_001PR @$WORKDIR/$GENSQL` rm $WORKDIR/$GENSQL cd $BACKGROUNDDUMP for i in `ls alert*.log`

do echo ......Rename $i to $i$FILENAME cp $i $i$FILENAME > $i done done # #-----------------------------------------------# # SQL*Net Logs in NETWORK/LOGS # #-----------------------------------------------# # echo "Rename all sqlnet logs in NETWORK/LOG" echo "-------------------------------------" cd $ORACLE_HOME/network/log for i in `ls *.log` do echo ......Rename $i to $i$FILENAME cp $i $i$FILENAME > $i done # #-----------------------------------------------# # SQL*Net Logs in $TNS_ADMIN # #-----------------------------------------------# # echo "Rename all sqlnet logs in $TNS_ADMIN" echo "----------------------------------------" cd $TNS_ADMIN for i in `ls *.log` do echo ......Rename $i to $i$FILENAME cp $i $i$FILENAME > $i done # #-----------------------------------------------# # corefiles in CDUMP #-----------------------------------------------# # echo "Checking corefiles in CDUMP" echo "---------------------------" > $WORKDIR/$ERRFILE cat $WORKDIR/$SIDFILE | while read siddie do export ORACLE_SID=$siddie echo " Checking corefiles for SID : $ORACLE_SID" echo " ---------------------------------" echo "set heading off" > $WORKDIR/$GENSQL echo "set pages 0" >> $WORKDIR/$GENSQL

echo "set feed off " >> $WORKDIR/$GENSQL echo "set echo off" >> $WORKDIR/$GENSQL echo "select rtrim(value) from v\$parameter where name = 'core_dump_dest';" >> $WORKDIR/$GENSQL echo "exit;" >> $WORKDIR/$GENSQL COREDUMPDEST=`sqlplus -s system/$SYSTEM_001PR @$WORKDIR/$GENSQL` rm $WORKDIR/$GENSQL cd $COREDUMPDEST find . -mtime +1 -name core_\* -exec rm -rf {} \; for i in `ls ../cdump` do echo "Corefilename : $i" >> $WORKDIR/$ERRFILE cd $i file core >> $WORKDIR/$ERRFILE cd .. done done if [ -s $WORKDIR/$ERRFILE ] then mailx -s "`uname -n`:$ORACLE_SID: New Corefiles" oradba < $WORKDIR/$ERRFILE echo "DBA mailed with new corefiles" fi; rm $WORKDIR/$SIDFILE

#!/bin/ksh #---------------------------------------------------------------# # Script generates online backup scripts and run the scripts # # ---------------------------------------------------------# # Date : 2000/08/11 # # ---# #---------------------------------------------------------------# # NOTES : For implementation of script: # # ------# # 1. Create a separate directory where the script resides # # because the program generates it's own scripts for # # the run of a backup. # # 2. Table ORA_ONLINE_BACKUP is created and maintained by # # this program to run the correct cycle for a specific day # # when this program is used to break the online backup of the# # database into more than 1 backup piece. # # Trigger is also required to ensure only 1 row resides in # # table. # # # # create table ORA_ONLINE_BACKUP # # ( cycle number(1)); # # # # create or replace trigger # # backup_trigger before insert on ORA_ONLINE_BACKUP # # for each row # # declare #

# num_rows number; # # begin # # select count(*) into num_rows from ORA_ONLINE_BACKUP; # # if num_rows > 0 # # then # # raise_application_error(-20000, 'Only 1 row allowed in table');# # end if; # # end; # # / # # 3. Table ORA_ONLINE_BACKUP_FILES is created and maintained # # for recordkeeping of when files was last backed up. # # # # create table ORA_ONLINE_BACKUP_FILES # # ( file_name varchar2(513), # # last_backup date ); # # # # create unique index ORA_ONLINE_BACKUP_KEY # # on ORA_ONLINE_BACKUP_FILES ( file_name ); # # 4. Procedure ORA_BACKUP_PROC1 for updating above table # # during run of backup. # # # # create or replace procedure ORA_BACKUP_PROC1 ( file1 varchar2 ) # # as # # begin # # insert into ora_online_backup_files # # values ( file1 , sysdate ); # # commit; # # exception # # when dup_val_on_index # # then update ora_online_backup_files # # set last_backup = sysdate # # where file_name = file1; # # commit; # # end; # #/ # # # # # #---------------------------------------------------------------# # # # # # # # Changes : # # --------# # # # # #---------------------------------------------------------------# # # # Working Environment # # ------------------# PROGNAME=onlinebackup.ksh DBUSER=ops\$backup DBPASS=backreco WORKDIR=/usr1/app/oracle/product/8.0.5/home/desibackup WORKFILE=workfile.in NEWWORKFILE=newworkfile.in

CONTROLFILE=controlfile.in UPDATEFILE=updatefile.in BACKUPCONTROLFILE=$ORACLE_SID''backupcontrolfile.control TRACECONTROLFILE=$ORACLE_SID''backupcontrolfile.trace ENDSQL=end.sql GENSQL=gen.sql BEGINSQL=begin.sql NETWORKER=backfile_networker BACKUPRUN=backfile_run BACKSUCCESS=success BACKUPLOGFILE=$ORACLE_SID''_backup.logfile SYSTEM_001PR=`cat /var/opt/oracle/SYSTEM_001P` INSTALLFLAG=nono integer DBCYCLE=0 integer counter1=1 integer counter2=0 integer NOFILES=0 integer DBLOGFILE=0 # # # # -------------------------------------------------------# # Check whether tables,triggers etc. are installed before# # run of script. # # # #--------------------------------------------------------# # echo "--------------------------------------" echo "STARTING INSTALL OR DATABASE UP CHECK " echo "--------------------------------------" echo "set heading off" > $WORKDIR/$GENSQL echo "set pages 0" >> $WORKDIR/$GENSQL echo "set feed off " >> $WORKDIR/$GENSQL echo "set echo off" >> $WORKDIR/$GENSQL echo "select '1' from ORA_ONLINE_BACKUP ;" >> $WORKDIR/$GENSQL echo "exit;" >> $WORKDIR/$GENSQL INSTALLFLAG=`sqlplus -s $DBUSER/$DBPASS @$WORKDIR/$GENSQL` rm $WORKDIR/$GENSQL if [ $INSTALLFLAG = 1 ] then echo " " else echo "------------------------------------------" echo "INSTALLFLAG value : $INSTALLFLAG " echo "------------------------------------------" echo "++++++++++++++++++++++++++++++++++++++++++++" > err.out echo "ERROR : Online backup of $ORACLE_SID " >> err.out echo "Table ORA_ONLINE_BACKUP does not exist or database down !!" >> err.out echo "++++++++++++++++++++++++++++++++++++++++++++" >> err.out echo "++++++++++++++++++++++++++++++++++++++++++++" echo "ERROR : Online backup of $ORACLE_SID " echo "Table ORA_ONLINE_BACKUP does not exist or database down !!" echo "++++++++++++++++++++++++++++++++++++++++++++"

mailx -s "`uname -n`:$ORACLE_SID: Online Backup" oradba < err.out rm err.out exit; fi; # # #------------------------------------------------------------# # Check input parameter for amount of backup pieces # #------------------------------------------------------------# # echo "--------------------------------------" echo "CHECKING INPUT PARAMETER............. " echo "--------------------------------------" echo "***************************************************" echo " Input parameter for no of files : $1" NOFILES=$1 echo " Run Cycles generated is : $NOFILES " echo "***************************************************" # if [ $NOFILES -eq 0 ] then echo "**************************************************" echo " Mandatory parameter for no of cycles to generate " echo " was not passed to program : Please restart " echo " I.E. PROGRAM PARAMETER1 " echo "**************************************************" exit fi; if [ $NOFILES -gt 9 ] then echo "**************************************************" echo " Parameter for cycles is out of range. Only use " echo " 1 - 9. " echo "**************************************************" exit fi; #------------------------------------------------------------# # Check for already running backup : # #------------------------------------------------------------# echo "--------------------------------------" echo "CHECKING FOR ALREADY RUNNING BACKUP.. " echo "--------------------------------------" signalle=yep integer counter=0 integer counter1=0 while [ $signalle = yep ] do counter=$counter+1 counter1=`ps -ef|grep "$PROGNAME" |grep -v grep|grep -v "sh -c" | wc -l` if [ counter1 -gt 1 ] then echo "Another Backup for $ORACLE_SID is busy" echo "Waiting 5 minutes..... "

sleep 300 else signalle=norunning fi; if [ $counter -gt 48 ] then signalle=nono fi; done if [ $signalle = nono ] then echo "++++++++++++++++++++++++++++++++++++++++++++" > err.out echo "ERROR : Online backup of $ORACLE_SID failed " >> err.out echo " due to waiting for more than " >> err.out echo " 4 hours for previous job " >> err.out echo "++++++++++++++++++++++++++++++++++++++++++++" >> err.out echo "++++++++++++++++++++++++++++++++++++++++++++" echo "ERROR : Online backup of $ORACLE_SID failed " echo " due to waiting for more than " echo " 4 hours for previous job " echo "++++++++++++++++++++++++++++++++++++++++++++" mailx -s "`uname -n`:$ORACLE_SID: Online Backup" oradba < err.out rm err.out exit fi; # # #------------------------------------------------------------# # S T A R T O F B A C K U P : # #------------------------------------------------------------# # # echo "--------------------------------------" echo "STARTING BACKUP...................... " echo "--------------------------------------" echo " ----------------------------------------------------- " >> $WORKDIR/$BACKUPLOGFILE echo " BACKUP STARTED :" >> $WORKDIR/$BACKUPLOGFILE date >> $WORKDIR/$BACKUPLOGFILE # # # # -------------------------------------------------------# # Check for day's cycle in table ORA_ONLINE_BACKUP # # # #--------------------------------------------------------# # echo "--------------------------------------" echo "GETTING CYCLE FOR BACKUP RUN......... " echo "--------------------------------------" echo "set heading off" > $WORKDIR/$GENSQL echo "set pages 0" >> $WORKDIR/$GENSQL echo "set feed off " >> $WORKDIR/$GENSQL echo "set echo off" >> $WORKDIR/$GENSQL echo "select cycle from ORA_ONLINE_BACKUP ;" >> $WORKDIR/$GENSQL

echo "exit;" >> $WORKDIR/$GENSQL DBCYCLE=`sqlplus -s $DBUSER/$DBPASS @$WORKDIR/$GENSQL` if [ $? -gt 0 ] then echo "++++++++++++++++++++++++++++++++++++++++++++" > err.out echo "ERROR : Online backup of $ORACLE_SID " >> err.out echo "Table ORA_ONLINE_BACKUP does not exist or database down !!" >> err.out echo "++++++++++++++++++++++++++++++++++++++++++++" >> err.out echo "++++++++++++++++++++++++++++++++++++++++++++" echo "ERROR : Online backup of $ORACLE_SID " echo "Table ORA_ONLINE_BACKUP does not exist or database down !!" echo "++++++++++++++++++++++++++++++++++++++++++++" mailx -s "`uname -n`:$ORACLE_SID: Online Backup" oradba < err.out rm err.out exit; fi; echo "-------------------" echo "DBCYCLE : $DBCYCLE " echo "-------------------" # if [ DBCYCLE -gt NOFILES ] then DBCYCLE=$NOFILES echo "-------------------" echo "NEW DBCYCLE : $DBCYCLE" echo "-------------------" fi; echo " BACKUP CYCLE : $DBCYCLE" >> $WORKDIR/$BACKUPLOGFILE # #------------------------------------------------------------# # Switch database logfile : # #------------------------------------------------------------# echo "--------------------------------------" echo "SWITCHING DATABASE LOGFILE........... " echo "--------------------------------------" # rm $WORKDIR/$GENSQL svrmgrl << EOF connect internal spool $WORKDIR/$GENSQL alter system switch logfile; spool off; EOF if [ $? -gt 0 ] then echo "++++++++++++++++++++++++++++++++++++++++++++" > err.out echo "ERROR : Online backup of $ORACLE_SID " >> err.out echo "ERROR : switch logfile failed " >> err.out echo "++++++++++++++++++++++++++++++++++++++++++++" >> err.out echo "++++++++++++++++++++++++++++++++++++++++++++" echo "ERROR : Online backup of $ORACLE_SID " echo "ERROR : switch logfile failed " echo "++++++++++++++++++++++++++++++++++++++++++++" mailx -s "`uname -n`:$ORACLE_SID: Online Backup" oradba < err.out rm err.out

fi; DBLOGFILE=`cat $WORKDIR/$GENSQL | grep -i ORA-09817 | wc -l` if [ $DBLOGFILE -gt 0 ] then echo "++++++++++++++++++++++++++++++++++++++++++++" > err.out echo "ERROR : Online backup of $ORACLE_SID " >> err.out echo "ERROR : Alert log file system is full!!!! " >> err.out echo "++++++++++++++++++++++++++++++++++++++++++++" >> err.out echo "++++++++++++++++++++++++++++++++++++++++++++" echo "ERROR : Online backup of $ORACLE_SID " echo "ERROR : Alert log file system is full!!!! " echo "++++++++++++++++++++++++++++++++++++++++++++" mailx -s "`uname -n`:$ORACLE_SID: Online Backup" oradba < err.out rm err.out exit fi; rm $WORKDIR/$GENSQL # # #------------------------------------------------------------# # Backup controlfiles to $WORKDIR # #------------------------------------------------------------# # echo "--------------------------------------" echo "BACKING UP CONTROLFILE TO DIRECTORY.. " echo "--------------------------------------" rm $WORKDIR/$BACKUPCONTROLFILE echo "-------------------------------------------------------" echo " Backing up controlfile : $BACKUPCONTROLFILE" echo "-------------------------------------------------------" # svrmgrl << EOF connect internal alter database backup controlfile to '$WORKDIR/$BACKUPCONTROLFILE'; EOF if [ $? -gt 0 ] then echo "++++++++++++++++++++++++++++++++++++++++++++" > err.out echo "ERROR : Online backup of $ORACLE_SID " >> err.out echo "ERROR : Backup of controlfile failed " >> err.out echo "++++++++++++++++++++++++++++++++++++++++++++" >> err.out echo "++++++++++++++++++++++++++++++++++++++++++++" echo "ERROR : Online backup of $ORACLE_SID " echo "ERROR : Backup of controlfile failed " echo "++++++++++++++++++++++++++++++++++++++++++++" mailx -s "`uname -n`:$ORACLE_SID: Online Backup" oradba < err.out rm err.out fi; # # # # # #------------------------------------------------------------# # Backup controlfiles to TRACE # #------------------------------------------------------------# # echo "--------------------------------------"

echo "BACKING UP CONTROLFILE TO TRACE...... " echo "--------------------------------------" rm $WORKDIR/$TRACECONTROLFILE echo "set heading off" > $WORKDIR/$GENSQL echo "set pages 0" >> $WORKDIR/$GENSQL echo "set feed off " >> $WORKDIR/$GENSQL echo "set echo off" >> $WORKDIR/$GENSQL echo "alter database backup controlfile to trace;" >> $WORKDIR/$GENSQL echo "select rtrim(spid) from v\$process , v\$session" >> $WORKDIR/$GENSQL echo " where paddr = addr and" >> $WORKDIR/$GENSQL echo "sid in ( select sid from v\$session where " >> $WORKDIR/$GENSQL echo " audsid = userenv('sessionid'));" >> $WORKDIR/$GENSQL echo "exit;" >> $WORKDIR/$GENSQL UPROCESSID=`sqlplus -s system/$SYSTEM_001PR @$WORKDIR/$GENSQL` rm $WORKDIR/$GENSQL echo "set heading off" > $WORKDIR/$GENSQL echo "set pages 0" >> $WORKDIR/$GENSQL echo "set feed off " >> $WORKDIR/$GENSQL echo "set echo off" >> $WORKDIR/$GENSQL echo "select rtrim(value) from v\$parameter where name = 'user_dump_dest';" >> $WORKDIR/$GENSQL echo "exit;" >> $WORKDIR/$GENSQL USERDUMPDEST=`sqlplus -s system/$SYSTEM_001PR @$WORKDIR/$GENSQL` rm $WORKDIR/$GENSQL cp $USERDUMPDEST"/"$ORACLE_SID""_ora_""$UPROCESSID.trc $WORKDIR/$TRACECONTROLFILE if [ $? -gt 0 ] then echo "++++++++++++++++++++++++++++++++++++++++++++" > err.out echo "ERROR : Online backup of $ORACLE_SID " >> err.out echo "ERROR : Copy of controlfile from trace to " >> err.out echo "ERROR : trace copy in workdir failed " >> err.out echo "++++++++++++++++++++++++++++++++++++++++++++" >> err.out echo "++++++++++++++++++++++++++++++++++++++++++++" echo "ERROR : Online backup of $ORACLE_SID " echo "ERROR : Copy of controlfile from trace to " echo "ERROR : trace copy in workdir failed " echo "++++++++++++++++++++++++++++++++++++++++++++" mailx -s "`uname -n`:$ORACLE_SID: Online Backup" oradba < err.out rm err.out fi; # #------------------------------------------------------------# # Generate workfiles and sql's for backup run # #------------------------------------------------------------# # #------------------------------------------------------------# # List of datafiles: # # --------------------# # echo "--------------------------------------" echo "GENERATING WORKFILES................. " echo "--------------------------------------" echo "set heading off" > $WORKDIR/$GENSQL echo "set pages 0" >> $WORKDIR/$GENSQL

echo "set feed off " >> $WORKDIR/$GENSQL echo "set echo off" >> $WORKDIR/$GENSQL echo "set wrap off " >> $WORKDIR/$GENSQL echo "set lines 133" >> $WORKDIR/$GENSQL echo "spool $WORKDIR/$WORKFILE" >> $WORKDIR/$GENSQL echo "select rtrim(tablespace_name,' ')||' '||rtrim(a.file_name,' ')||' '||a.bytes||' '||'*'||substr(file_name,instr(file_name,'.',1,1)) from dba_data_files a, v\$datafile b where file_id = file# and to_char(trunc(creation_time),'yyyy-mm-dd') < to_char(trunc(sysdate),'yyyy-mmdd') and a.file_name not in ( select file_name from ORA_ONLINE_BACKUP_FILES c where ( trunc(sysdate) - trunc(last_backup) ) > $NOFILES ) order by a.bytes desc,tablespace_name;" >> $WORKDIR/$GENSQL echo "spool off" >> $WORKDIR/$GENSQL echo "exit;" >> $WORKDIR/$GENSQL sqlplus $DBUSER/$DBPASS @$WORKDIR/$GENSQL rm $WORKDIR/$GENSQL # # # List of new datafiles created on day of run of backup and # datafiles that has not been backed up due to creation of # new datafiles causing the generated backup run file to # shuffle a lot. #------------------------------------------------------# # echo "set heading off" > $WORKDIR/$GENSQL echo "set pages 0" >> $WORKDIR/$GENSQL echo "set feed off " >> $WORKDIR/$GENSQL echo "set echo off" >> $WORKDIR/$GENSQL echo "set wrap off " >> $WORKDIR/$GENSQL echo "set lines 133" >> $WORKDIR/$GENSQL echo "spool $WORKDIR/$NEWWORKFILE" >> $WORKDIR/$GENSQL echo "select rtrim(tablespace_name,' ')||' '||rtrim(file_name,' ')||' '||a.bytes||' '||'*'||substr(file_name,instr(file_name,'.',1,1)) from dba_data_files a, v\$datafile b where file_id = file# and to_char(trunc(creation_time),'yyyy-mm-dd') = to_char(trunc(sysdate),'yyyy-mmdd') order by a.bytes desc,tablespace_name;" >> $WORKDIR/$GENSQL echo "select rtrim(tablespace_name,' ')||' '||rtrim(a.file_name,' ')||' '||a.bytes||' '||'*'||substr(file_name,instr(file_name,'.',1,1)) from dba_data_files a, v\$datafile b where file_id = file# and a.file_name in ( select file_name from ORA_ONLINE_BACKUP_FILES c where ( trunc(sysdate) trunc(last_backup) ) > $NOFILES ) order by a.bytes desc,tablespace_name;" >> $WORKDIR/$GENSQL echo "spool off" >> $WORKDIR/$GENSQL echo "exit;" >> $WORKDIR/$GENSQL sqlplus $DBUSER/$DBPASS @$WORKDIR/$GENSQL rm $WORKDIR/$GENSQL # # # #------------------------------------------------------------# # Begin and end backup sql scripts : # # ---------------------------------# # echo "--------------------------------------"

echo "GENERATING BEGIN AND END SQL......... " echo "--------------------------------------" echo "set heading off" > $WORKDIR/$GENSQL echo "set pages 0" >> $WORKDIR/$GENSQL echo "set feed off " >> $WORKDIR/$GENSQL echo "set echo off" >> $WORKDIR/$GENSQL echo "spool $WORKDIR/$ENDSQL" >> $WORKDIR/$GENSQL echo "select 'alter tablespace '||tablespace_name||' end backup;' from dba_tablespaces;" >> $WORKDIR/$GENSQL echo "spool off" >> $WORKDIR/$GENSQL echo "exit;" >> $WORKDIR/$GENSQL sqlplus $DBUSER/$DBPASS @$WORKDIR/$GENSQL rm $WORKDIR/$GENSQL echo "set heading off" > $WORKDIR/$GENSQL echo "set pages 0" >> $WORKDIR/$GENSQL echo "set feed off " >> $WORKDIR/$GENSQL echo "set echo off" >> $WORKDIR/$GENSQL echo "spool $WORKDIR/$BEGINSQL" >> $WORKDIR/$GENSQL echo "select 'alter tablespace '||tablespace_name||' begin backup;' from dba_tablespaces;" >> $WORKDIR/$GENSQL echo "spool off" >> $WORKDIR/$GENSQL echo "exit;" >> $WORKDIR/$GENSQL sqlplus $DBUSER/$DBPASS @$WORKDIR/$GENSQL rm $WORKDIR/$GENSQL echo "exit;" >> $WORKDIR/$ENDSQL echo "exit;" >> $WORKDIR/$BEGINSQL # #------------------------------------------------------------# # Generate networker and backup run file for backup : # # --------------------------------------------------# # # Current files : # --------------# # echo "--------------------------------------" echo "GENERATING NETWORKER/BACKUP RUN FILE.." echo "--------------------------------------" integer counter1=1 integer counter2=0 rm $WORKDIR/$NETWORKER rm $WORKDIR/$BACKUPRUN rm $WORKDIR/$UPDATEFILE backfilerun="" cat $WORKDIR/$WORKFILE | while read TB DF DFSIZE DFSUFF do if [ $counter1 -eq $DBCYCLE ] then backfilerun=$backfilerun" "$DF echo "$DF" >> $WORKDIR/$UPDATEFILE

echo "<< $DF >>" >> $WORKDIR/$NETWORKER echo " +compressasm: "$DFSUFF >> $WORKDIR/$NETWORKER echo " " >> $WORKDIR/$NETWORKER fi; if [ $counter2 -eq 0 ] ; then counter1=$counter1+1 ; fi if [ $counter2 -eq 1 ] ; then counter1=$counter1-1 ; fi if [ $counter1 -eq $NOFILES+1 ] then counter1=$counter1-1 counter2=1 ; fi -a [ $counter2 -eq 0 ] ;

if [ $counter1 -eq 0 ] -a [ $counter2 -eq 1 ] ; then counter1=$counter1+1 counter2=0 ; fi done backfilerun=$backfilerun" "$WORKDIR/$BACKUPCONTROLFILE backfilerun=$backfilerun" "$WORKDIR/$TRACECONTROLFILE echo "<< $WORKDIR/$BACKUPCONTROLFILE >>" >> $WORKDIR/$NETWORKER echo " +compressasm: *.control" >> $WORKDIR/$NETWORKER echo " " >> $WORKDIR/$NETWORKER echo "<< $WORKDIR/$TRACECONTROLFILE >>" >> $WORKDIR/$NETWORKER echo " +compressasm: *.trace" >> $WORKDIR/$NETWORKER echo " " >> $WORKDIR/$NETWORKER # # # Newlyadded files : # -----------------# # # cat $WORKDIR/$NEWWORKFILE | while read TB DF DFSIZE DFSUFF do backfilerun=$backfilerun" "$DF echo "$DF" >> $WORKDIR/$UPDATEFILE echo "<< $DF >>" >> $WORKDIR/$NETWORKER echo " +compressasm: "$DFSUFF >> $WORKDIR/$NETWORKER echo " " >> $WORKDIR/$NETWORKER done echo "/usr/bin/nsr/save -i -f $WORKDIR/$NETWORKER $backfilerun" > $WORKDIR/$BACKUPRUN # #------------------------------------------------------------# # Run of actual backup of files to tape : # #------------------------------------------------------------# # echo "--------------------------------------" echo "STARTING ACTUAL RUN OF BACKUP........." echo "--------------------------------------" svrmgrl << EOF connect internal @$WORKDIR/$ENDSQL;

EOF svrmgrl << EOF connect internal @$WORKDIR/$BEGINSQL; EOF if [ $? -gt 0 ] then echo "++++++++++++++++++++++++++++++++++++++++++++" > err.out echo "ERROR : Online backup of $ORACLE_SID failed " >> err.out echo "++++++++++++++++++++++++++++++++++++++++++++" >> err.out echo "++++++++++++++++++++++++++++++++++++++++++++" echo "ERROR : Online backup of $ORACLE_SID failed " echo "++++++++++++++++++++++++++++++++++++++++++++" mailx -s "`uname -n`:$ORACLE_SID: Online Backup" oradba < err.out rm err.out echo " BACKUP FAILED " >> $WORKDIR/$BACKUPLOGFILE echo " BACKUP ENDED :" >> $WORKDIR/$BACKUPLOGFILE date >> $WORKDIR/$BACKUPLOGFILE echo "-------------------------------------------------" >> $WORKDIR/$BACKUPLOGFILE exit fi; # echo " " echo " Starting save to tape..........." echo " " echo " " chmod 755 $WORKDIR/$BACKUPRUN # # echo "--------------------------------------" echo "SAVING TO TAPE........................" echo "--------------------------------------" SLEEPFLAG=on BACKSUCCESS=nono integer counter=0 # while [ $BACKSUCCESS = nono ] do $WORKDIR/$BACKUPRUN if [ $? -gt 0 ] then echo "---------------------------------" echo "save failed : Retrying .........." echo "---------------------------------" else BACKSUCCESS=success SLEEPFLAG=off counter=$counter+10 fi; if [ $SLEEPFLAG = on ] then echo "sleeping for 15 minutes" SLEEPFLAG=off sleep 900 fi;

counter=$counter+1 if [ counter -eq 2 ] then echo " backup failed " BACKSUCCESS=failed fi; done svrmgrl << EOF connect internal @$WORKDIR/$ENDSQL; EOF if [ $? -gt 0 ] then echo "++++++++++++++++++++++++++++++++++++++++++++" > err.out echo "ERROR : Online backup of $ORACLE_SID failed " >> err.out echo "++++++++++++++++++++++++++++++++++++++++++++" >> err.out echo "++++++++++++++++++++++++++++++++++++++++++++" echo "ERROR : Online backup of $ORACLE_SID failed " echo "++++++++++++++++++++++++++++++++++++++++++++" mailx -s "`uname -n`:$ORACLE_SID: Online Backup" oradba < err.out rm err.out exit fi; if [ $BACKSUCCESS = 'failed' ] then echo "++++++++++++++++++++++++++++++++++++++++++++" > err.out echo "ERROR : Online backup of $ORACLE_SID failed " >> err.out echo "++++++++++++++++++++++++++++++++++++++++++++" >> err.out echo "++++++++++++++++++++++++++++++++++++++++++++" echo "ERROR : Online backup of $ORACLE_SID failed " echo "++++++++++++++++++++++++++++++++++++++++++++" mailx -s "`uname -n`:$ORACLE_SID: Online Backup" oradba < err.out rm err.out echo " BACKUP FAILED " >> $WORKDIR/$BACKUPLOGFILE echo " BACKUP ENDED :" >> $WORKDIR/$BACKUPLOGFILE date >> $WORKDIR/$BACKUPLOGFILE echo "-------------------------------------------------" >> $WORKDIR/$BACKUPLOGFILE exit fi; #-------------------------------------------------------------# # Update CYCLE for next backup run : # # ---------------------------------# # # #-------------------------------------------------------------# echo "--------------------------------------" echo "UPDATE CYCLE FOR NEXT BACKUP RUN......" echo "--------------------------------------" DBCYCLE=$DBCYCLE+1 if [ DBCYCLE -gt NOFILES ] then DBCYCLE=1 fi; echo "--------------------------------" echo "Resetting DBCYCLE to : $DBCYCLE " echo "--------------------------------" svrmgrl << EOF connect internal update $DBUSER.ORA_ONLINE_BACKUP set cycle = $DBCYCLE;

EOF if [ $? -gt 0 ] then echo "++++++++++++++++++++++++++++++++++++++++++++" > err.out echo "ERROR : Reset of cycle for next backup failed " >> err.out echo "++++++++++++++++++++++++++++++++++++++++++++" >> err.out echo "++++++++++++++++++++++++++++++++++++++++++++" echo "ERROR : Reset of cycle for next backup failed " echo "++++++++++++++++++++++++++++++++++++++++++++" mailx -s "`uname -n`:$ORACLE_SID: Online Backup" oradba < err.out rm err.out fi; # #-------------------------------------------------------------# # Update backup date in table : ORA_ONLINE_BACKUP_FILES # # ---------------------------------# # # #-------------------------------------------------------------# # echo "--------------------------------------" echo "UPDATE BACKUP DATE OF FILES IN TABLE.." echo "--------------------------------------" cat $WORKDIR/$UPDATEFILE | while read FIL do echo "exec ORA_BACKUP_PROC1('$FIL')" >> $WORKDIR/$GENSQL done echo "exit;" >> $WORKDIR/$GENSQL sqlplus $DBUSER/$DBPASS @$WORKDIR/$GENSQL rm $WORKDIR/$GENSQL # # echo "********************************************************" echo " $ORACLE_SID ONLINE BACKUP COMPLETED SUCCESSFULLY " echo "********************************************************" echo "********************************************************" > err.out echo " $ORACLE_SID ONLINE BACKUP COMPLETED SUCCESSFULLY " >> err.out echo "********************************************************" >> err.out mailx -s "`uname -n`:$ORACLE_SID: Online Backup" oradba < err.out rm err.out echo " BACKUP COMPLETED SUCCESSFULLY " >> $WORKDIR/$BACKUPLOGFILE echo " BACKUP ENDED :" >> $WORKDIR/$BACKUPLOGFILE date >> $WORKDIR/$BACKUPLOGFILE echo "-------------------------------------------------" >> $WORKDIR/$BACKUPLOGFILE # # #------------------------------------------------------------# # T H E E N D # #------------------------------------------------------------#

#!/bin/ksh

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

------------------------------------------------------------------------This is a shell script for making exports directly to tape with a label. This label contains the db name and timestamp. This script also verifies the tape's protection. If the tape is protected it will display an error message and ask for a new tape. Another function lists the tape's label and its contents (option show=y of export). This script also writes a history log with dbname and timestamp. Sergio Klimberg <sklimberg@hotmail.com> -------------------------------------------------------------------------

clear echo ' ORACLE TAPE EXPORTS ' echo ' ------------------' b=' ' while [ "$b" != "end" ] do echo echo "* Enter DB for backup or list / Type 'end' to finish" echo ' ' read b if [ "$b" = "end" ] then exit fi echo ' ' echo "* Mount the tape and hit Enter or type 'list' / Type 'end' to finish" echo ' ' echo ' - Warning , Verify tape is not protected for backup ' echo ' - If are you going to list the result will appear on screeen and into /tmp/list.txt' echo ' ' read a echo ' ' read a if [ "$a" = "end" ] then exit fi mt -t /dev/rmt/0m rew # [ "$a" = "list" ] then echo echo "<= Export's Header =>" tar tf /dev/rmt/0mn echo " " echo "* Hit Enter for show the export's remainder / Type 'end' to finish" echo ' ' read c if

if [ "$c" = "end" ] then exit fi echo 'file=/dev/rmt/0m ' >list.imp echo 'log=/tmp/list.txt' >>list.imp echo 'show=y' >>list.imp echo 'volsize=4000M' >>list.imp echo 'full=y ' >>list.imp echo 'back/xxxxxx@'$b >>list.imp imp parfile=list.imp 2>&1 echo echo "Type 'end' to finish " read d exit fi HORA="`date '+%d-%m-%y %H:%M:%S'`" DESC_EXPORT="EXPORT $b $HORA" touch "$DESC_EXPORT" tar cvf /dev/rmt/0mn "$DESC_EXPORT" 2>/dev/null RTA=$? while [ $RTA != 0 ] do echo "Tape protected , Hit ENTER when it's ready finish" read RTA1 if [ "$RTA1" = "end" ] then exit fi tar cvf /dev/rmt/0mn "$DESC_EXPORT" 2>/dev/null RTA=$? done TIME_START="`date '+%d/%m/%y %H:%M:%S'`" echo 'back/xxxxxx@'$b >PARAMETERS.EXP echo 'file=/dev/rmt/0m ' >>PARAMETERS.EXP echo 'log=export.log' >>PARAMETERS.EXP echo 'volsize=4000M' >>PARAMETERS.EXP echo 'full=y ' >>PARAMETERS.EXP echo ' ' >>all_export.log echo 'EXPORT OF : '$b >>all_export.log echo 'START : ' $TIME_START >>all_export.log echo ' ' >>all_export.log exp parfile=PARAMETERS.EXP 2>&1 | tee -a all_export.log echo ' ' >>all_export.log TIME_END="`date '+%d/%m/%y %H:%M:%S'`" echo 'END : ' $TIME_END >>all_export.log echo "$TIME_START | $TIME_END | $b ">>export_resumen.log echo ' ' echo "$TIME_START | $TIME_END | $b ">>export_resumen.log echo ' ' echo Export $b end OK done

/ Type 'end' to

#!/bin/ksh #-------------------------------------------------------------------------# Sanjay Ganvkar - 16-Jul-2003 First Cut # # This script is applicable for users of StatsPack and want to # automate generation of statspack reports in a logical manner. # Script will loop thru the stats$snapshot and generate compressed # reports in the DDMM_StartTimeInHH24MI_EndTimeInHH24MI format # The script will also delete the snapIds once the report is generated # Note that the 'deletion' is an integral part of the script, since # the reports are generated using the existing snapIds in the stats$snapshot table. # Changing the script to rem-out the deletion will result in the reports getting # re-generated every time. # # The statspack original sppurge.sql has been altered to remove the undef for lo/hisnapid # since it interferes with the batch purging # # Setup # 1. Ensure that the sppurge.sql & spreport.sql are present in $STATSDIR # 2. Change the STATSDIR/STATSREP/DBMS_UID/DBMS_PWD as required # 3. Alter the sppurge.sql script to remove the undef for lo/hisnapid # 4. Run the script (no arguments) #--------------------------------------------------------------------------# ---------Change the values below as required

# <-------------------------------------------------. ~/.profile # Directory where this script resides STATSDIR=/export/home/oracle/statspack/scripts # Directory where the reports are created STATSREP=/export/home/oracle/statspack/reports DBMS_UID=perfstat DBMS_PWD=perfstat SQLSCRIPTFILE=snap.sql # --------------------------------------------------> # ---------- Start of program cd $STATSDIR mkdir -p $STATSREP rm $SQLSCRIPTFILE echo "Generating reports in $STATSREP ... Pls wait ..." sqlplus -s > /dev/null <<! $DBMS_UID/$DBMS_PWD set serveroutput on size 1000000

set feed off term off trims on linesize 300 spool $SQLSCRIPTFILE declare min_snap number; next_snap number; min_snap_time varchar2(20); next_snap_time varchar2(20); fileName varchar2(255); cursor c1 is select snap_id, to_char(snap_time,'ddmm_hh24mi') snap_time from stats\$snapshot order by snap_id; c1_rec c1%rowtype; begin for c1_rec in c1 loop select min(snap_id) into next_snap from stats\$snapshot where snap_id > c1_rec.snap_id; select to_char(snap_time,'hh24mi') into next_snap_time from stats\$snapshot where snap_id = next_snap; fileName := '$STATSREP'||'/'||c1_rec.snap_time||'_'||next_snap_time||'.lst'; -- Following for generating the reports dbms_output.put_line('define begin_snap='||c1_rec.snap_id); dbms_output.put_line('define end_snap='||next_snap); dbms_output.put_line('define report_name='||fileName); dbms_output.put_line('@spreport'); -- Following for Purging dbms_output.put_line('define losnapid='||c1_rec.snap_id); dbms_output.put_line('define hisnapid='||c1_rec.snap_id); dbms_output.put_line('@sppurge'); dbms_output.put_line('commit;'); -- Compress the reports dbms_output.put_line('host compress -f '||fileName); end loop; exception when no_data_found then -- Only last snap remaining null; when others then dbms_output.put_line(sqlerrm); end; / spool off ! sqlplus -s > /dev/null <<! $DBMS_UID/$DBMS_PWD @$SQLSCRIPTFILE ! #!/bin/ksh

# # # # # #

----------------------------------------------------------------------Filename: purgecat.ksh Purpose: RMAN Catalog maintenance: Delete RMAN backupsets older than a specified number of days Author: Frank Naude, Oracle FAQ -----------------------------------------------------------------------

DAYSTOKEEP=60 # -- Do not change anything below this line --------------------------CMDFILE=/tmp/rmanpurge$$.rcv LOGFILE=/tmp/rmanprige$$.log if [ ! -x $ORACLE_HOME/bin/rman ]; then echo "ERROR: RMAN not found or ORACLE_HOME not set." exit 8 fi if [ ! $ORACLE_SID ]; then echo "ERROR: ORACLE_SID not set." exit 8 fi if [ ! $1 ]; then echo "USAGE: $0 CatalogConnectString" exit; else RCVCAT=$1 fi; echo "Delete RMAN backupsets older than $DAYSTOKEEP days for db $ORACLE_SID." echo "ALLOCATE CHANNEL FOR DELETE TYPE 'SBT_TAPE';" >>$CMDFILE # List all old entries that needs to be deleted (rman rcvcat $RCVCAT target / <<-EOF list backupset of database from time 'SYSDATE-3000' until time 'SYSDATE-$DAYSTOKEEP'; exit; EOF ) | grep RMAN-06233 | while read filler key filler filler date rest do echo "# Delete backupset $key dated $date..." >>$CMDFILE echo "CHANGE BACKUPSET $key DELETE;" >>$CMDFILE done echo "RELEASE CHANNEL;" >>$CMDFILE # Delete the old entries rman rcvcat $RCVCAT target / cmdfile $CMDFILE echo "Done!" #! /bin/ksh # ----------------------------------------------------------------------# Filename: rmanarch.ksh

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

Purpose: Author: Notes:

Recatalog archived logs that were marked as deleted with the "change archivelog all validate/corsscheck;" command and later moved back to the archlog directory to be backed-up. Frank Naude, Oracle FAQ

DBA's frequently move files from the database archive destination to prevent this directory from filling up causing database freezes. The "change archivelog all validate/crosscheck;" command is then issued to mark missing archivelog files as DELETED in the catalog. Successive backups will not backup these "deleted" files. If one later move these files back to the archive log destination, they will not be backed up unless you re-catalog them. This script will generate the commands necessary to re-catalog these files. -----------------------------------------------------------------------

SYSPSW=change_on_install # Get the database archlog directory ARCHDIR=`sqlplus -s sys/${SYSPSW} <<-EOF set echo off feed off head off pages 0 termout off select value from sys.v_\\$parameter where name = 'log_archive_dest'; exit; EOF` print "Checking archlog dir $ARCHDIR for 'deleted' files...\n" # List all files in the archlog directory and check against the DB. find ${ARCHDIR}* -type f | while read f do RMANCMD=`sqlplus -s sys/${SYSPSW} <<-EOF set echo off feed off head off pages 0 termout off select 'CATALOG ARCHIVELOG '''||name||''';' from sys.v_\\$archived_log where name = '$f' and deleted = 'YES'; exit; EOF` if [ "${RMANCMD}" ]; then print $RMANCMD fi done print print print print "" "Please run the above RMAN command(s) to recatalog archived log files" "marked as deleted and later moved back to the archlog directory." ""

#! /bin/ksh # ----------------------------------------------------------------------# Filename: oraprod.ksh

# # # #

Purpose: List all Installed Oracle Products Note: This script works for all Oracle7 and 8i releases Author: Frank Naude, Oracle FAQ -----------------------------------------------------------------------

PAGER=more if [ ! -d "${ORACLE_HOME}" ]; then print "ERROR: Oracle home not set." exit -1 fi print "Oracle Installed Products for ORACLE_HOME ${ORACLE_HOME}:" if [ -f "${ORACLE_HOME}/orainst/inspdver" ]; then cd ${ORACLE_HOME}/orainst ./inspdver | ${PAGER} else cat ${ORACLE_HOME}/install/unix.rgs | ${PAGER} fi #! /bin/ksh # # # # # ----------------------------------------------------------------------Filename: dbup.ksh Purpose: Check if DB's background processes are started Author: Frank Naude, Oracle FAQ -----------------------------------------------------------------------

HELP=0; VERBOSE=0 while getopts hv KEY $* do case $KEY in v) VERBOSE=1;; *) HELP=1;; esac done if [ ${HELP} -eq "1" -o ${#} -eq "0" ] ; then cat 1>&2 <<EOF Usage: dbup [-h] [-v] ORACLE_SID [ORACLE_SID2...] where -h gives this help -v verbose

This command checks if a set of databases is started or not. It can be used to check database availability before serious work is atempted. Returns -1 is one of the databases is not running, otherwise 0. EOF exit fi shift OPTIND-1 FAILED=0; INSTANCEDOWN=0

for INSTANCE in $* do if [ ${VERBOSE} -eq "1" ] ; then echo "Checking instance ${INSTANCE}...\n" fi for PROCESS in pmon smon do RC=$(ps -ef | egrep ${INSTANCE} | egrep -v 'grep' | egrep ${PROCESS}) if [ "${RC}" = "" ] ; then INSTANCEDOWN=1 if [ ${VERBOSE} -eq "1" ] ; then echo "\tERROR: Instance ${INSTANCE} ${PROCESS} down!" fi fi done if [ ${INSTANCEDOWN} = "1" ] ; then echo "`date` - Instance ${INSTANCE} is DOWN!!!\n" FAILED=1 else echo "`date` - Instance ${INSTANCE} is running.\n" fi done if [ ${FAILED} = "1" ] ; then return -1 else return 0 fi

#!/bin/ksh # ----------------------------------------------------------------------# Filename: dbup # Purpose: Connect to databases via listeners to measure uptime and to # ensure that users can connect via the listeners # Return: 0 = success, 1 = something wrong (errors goes to log file) # Author: Frank Naude # Date: 27 September 2000 # Revised: 14 July 2006 #----------------------------------------------------------------------# Connect string to use when connecting to Oracle database CONNSTR=monitor/monitor # NODE=`hostname` works for most hosts # Hard code for floating hostnames eg. tcen-mast-int NODE=`hostname` # Format of TNSNAMES entries. Valid values: NODE, DB or NODE_DB TNSFORMAT="NODE_DB" # Databases to check. Change if you need to exclude certain databases. # Eg: DBMASK='^prd.*:.*:[NnYy]$' gives DBs with names starting with "prd"

DBMASK='^.*:.*:[Yy]$' # Connect timeout in seconds CONNTIMEOUT=60 # Write error messages to this log file LOGFILE=/tmp/dbup # ----------------------------------------------------------------------# Please do not change anything below this line # ----------------------------------------------------------------------# Locate the correct ORATAB file if [ -f /etc/oratab ]; then ORATAB=/etc/oratab elif [ -f /var/opt/oracle/oratab ]; then ORATAB=/var/opt/oracle/oratab else print "ERROR: Unable to locate ORATAB file" >>${LOGFILE} exit -1 fi # Locate the correct TNSNAMES.ORA file if [ -f /etc/tnsnames.ora ]; then TNSNAMES=/etc/tnsnames.ora elif [ -f /var/opt/oracle/tnsnames.ora ]; then TNSNAMES=/var/opt/oracle/tnsnames.ora fi ALL_DATABASES=`cat ${ORATAB} | grep -v "^#" | grep ${DBMASK} | cut -f1 -d: -s` for DB in do unset export export export export export ${ALL_DATABASES} TWO_TASK ORACLE_SID=$DB ORACLE_HOME=`grep "^${DB}:" ${ORATAB}|cut -d: -f2 -s` PATH=$ORACLE_HOME/bin:$PATH LD_LIBRARY_PATH=$ORACLE_HOME/lib SHLIB_PATH=$ORACLE_HOME/lib

# Skip non database home $ORACLE_HOME if [ ! -x $ORACLE_HOME/bin/oracle ]; then print "`date`: Skip non database home ${ORACLE_HOME}" >>${LOGFILE} continue fi # SQL*Plus not available in $ORACLE_HOME if [ ! -x $ORACLE_HOME/bin/sqlplus ]; then print "`date`: SQL*Plus not available in ${ORACLE_HOME}" >>${LOGFILE} continue fi if [ "${TNSFORMAT}" = "DB" ]; then NETNAME="${DB}" elif [ "${TNSFORMAT}" = "NODE" ]; then NETNAME="${NODE}" elif [ "${TNSFORMAT}" = "NODE_DB" ]; then

NETNAME="${NODE}_${DB}" else print "ERROR: Invalid TNSFORMAT value used" >>${LOGFILE} exit -1 fi # Open pipe to Oracle sqlplus sqlplus -s /nolog |& # Set connection timeout timer OUT="" PID=$! sleep ${CONNTIMEOUT} | ( read nothing # wait on sleep to finish kill -0 ${PID} 2>/dev/null || exit; # exit if finished print "`date`: SQL*Plus was hanging - Killed" >>${LOGFILE} kill -9 ${PID} 2>/dev/null # kill it!!! ) & # Connect to database print -p "whenever sqlerror exit" print -p "connect ${CONNSTR}@${NETNAME}" print -p "prompt Connected." read -p OUT # print -p "exit 0" 2>/dev/null # Remove empty lines from output ((i=0)) while [ "${OUT}" = "" -a "${i}" -lt "5" ]; do read -p OUT 2>/dev/null ((i=i+1)) done # Check connection status if [ "${OUT}" = "Connected." ]; then print "${NETNAME} 1" print "`date`: Successfully connected to ${NETNAME}" >>${LOGFILE} elif [ "${OUT}" = "" ]; then print "${NETNAME} 0" print "`date`: Unable to connect to ${NETNAME}" >>${LOGFILE} print "`date`: Connection is hanging - timed out!!!" >>${LOGFILE} # -- Add commands for SMS, EMail escalations here -else print "${NETNAME} 0" print "`date`: Unable to connect to ${NETNAME}" >>${LOGFILE} print "`date`: ${OUT}" >>${LOGFILE} read -p OUT 2>/dev/null print "`date`: ${OUT}" >>${LOGFILE} # -- Add commands for SMS, EMail escalations here -fi print -p "exit 0" 2>/dev/null exec 3>&p # Close co-processes' file descriptors kill -9 ${PID} 2>/dev/null wait ${PID} 2>/dev/null Done

######### Last Statement of: dbup.ksh #########

#!/bin/ksh # # # # # ----------------------------------------------------------------------Filename: wait4ora.ksh Purpose: Sleep until a database becomes available Author: Frank Naude, Oracle FAQ -----------------------------------------------------------------------

LOG=$0.log SLEEP_TIME=60 if [ ! -t 0 ]; then exec 1>>${LOG} 2>&1 fi # Write output to log if we run from cron

if [ "${1}" = "" ]; then echo "USAGE: Please supply a database name..." exit fi unset export export export TWO_TASK ORACLE_SID=${1} ORACLE_HOME=`grep -i "^${1}:" /etc/oratab|cut -d: -f2 -s` PATH=$ORACLE_HOME/bin:$PATH

echo "" echo "Waiting for database $1 to become available..." echo "Database: $ORACLE_SID Home: $ORACLE_HOME" while : do sqlplus -s >/dev/null 2>&1 "monitor/monitor" <<EOF whenever sqlerror exit 1 select * from dual; -- If we can not connect or select, we will not return 0!!! exit 0 EOF if [ $? -eq 0 ]; then echo "`date`: Database $ORACLE_SID is up and running." exit else echo "`date`: Still waiting for $ORACLE_SID to become available..." sleep ${SLEEP_TIME} fi done

#!/bin/ksh # # # # # ----------------------------------------------------------------------Filename: oidmon.ksh Purpose: Check if the Oracle OID (LDAP) Server is functioning Author: John Durai -----------------------------------------------------------------------

OIDSERVER=oidldapd ORACLE_SID=DBPROD MAILTO=jdurai@hotmail.com TESTENTRY=orcl ORACLE_HOME=`grep "^${ORACLE_SID}:" /var/opt/oracle/oratab | cut -d: -f2 -s` PATH=:$ORACLE_HOME/bin:$PATH # # Look if Oracle OID Server is installed on this machine # if [ ! -x $ORACLE_HOME/bin/oidctl ] ; then echo The Oracle OID Server is not installed on this machine or echo environment setup is incorrect!!! return -1 fi # # Check if the nameserver process is running... # RC=`ps -ef | egrep 'oidldapd' | egrep -v 'grep' | awk '{print $2}'` if [ "${RC}" = "" ]; then echo "Oracle OID Names Server $OIDSERVER is DOWN!!!" echo "Starting OID server again" $ORACLE_HOME/bin/oidmon connect=DBHUB sleep=10 start $ORACLE_HOME/bin/oidctl connect=DBHUB server=OIDLDAPD instance=4 flags="port=389" start fi RC=`ps -ef | egrep '/bin/oidmon' | egrep -v 'grep' | awk '{print $2}'` if [ "${RC}" = "" ]; then /bin/mail ${MAILTO} <<-EOF Subject: OID Server Down!!! `date` - Oracle OID Server $OIDSERVER is DOWN!!! EOF return -2 else echo " oracle OID is running properly" fi

#!/bin/ksh # # # # # ----------------------------------------------------------------------Filename: namesmon.ksh Purpose: Check if the Oracle Names Server is functioning. Author: Frank Naude, Oracle FAQ -----------------------------------------------------------------------

NAMESERVER=oranamesrvr0 ORACLE_SID=oranames ORATAB=/var/opt/oracle/oratab MAILTO=address\@domain.com TESTENTRY=orcl ORACLE_HOME=`grep "^${ORACLE_SID}:" $ORATAB | cut -d: -f2 -s` PATH=:$ORACLE_HOME/bin:$PATH # # Look if Oracle Names Server is installed on this machine # if [ ! -x $ORACLE_HOME/bin/namesctl ] ; then echo The Oracle Names Server is not installed on this machine or echo environment setup is incorrect!!! return -1 fi # # Check if the nameserver process is running... # RC=`ps -ef | egrep '/bin/names' | egrep -v 'grep' | awk '{print $2}'` if [ "${RC}" = "" ]; then echo "Oracle Names Server $NAMESERVER is DOWN!!!" /bin/mail ${MAILTO} <<-EOF # Note the TAB chars Subject: Names Server Down!!! `date` - Oracle Names Server $NAMESERVER is DOWN!!! EOF return -2 fi # # Check if the nameserver resolve names... # RC=`namesctl <<-EOF | grep normal set server $NAMESERVER query $TESTENTRY exit EOF` if [ "${RC}" = "" ] ; then echo "Names Server doesn't resolve names!!!" /bin/mail ${MAILTO} <<-EOF

Subject: Names Server doesn't resolve names!!! `date` - Oracle Names Server $NAMESERVER doesn't resolve names!!! EOF return -3 fi

#!/bin/sh # # The purpose of the script is to do the following for each listener ... # 1. "Swap" the listener log file # # Issued by Cron [55 23 * * 0] # # File : listenerlog_swap1.sh # Author : Ravin Maharaj # NB!! : Please do NOT modify or delete this script # without prior consent from the author MAILLIST="/usr/bin/utils/listener" HOST=`uname -n`" : " WorkDir="/oracle/scripts" listeners="${WorkDir}/listeners" lsnrcol5="${WorkDir}/lsnrcol5" SUBJECT="Subject: " LSNRRUNNING=`ps -ef | grep tns | grep -v grep` if [ -n "{LSNRRUNNING}" ] then ps -ef | grep tns | grep -v grep | awk '{print $5}' > ${lsnrcol5} # Get listener names for i in `cat ${lsnrcol5}` do case "${i}" in "Jan"|"Feb"|"Mar"|"Apr"|"May"|"Jun"|"Jul"|"Aug"|"Sep"|"Oct"|"Nov"|"Dec") ps -ef | grep tns | grep -v grep | awk '{print $10}' > ${listeners} ;; *) ps -ef | grep tns | grep -v grep | awk '{print $9}' > ${listeners} ;; esac done rm -f ${lsnrcol5} if [ -s "${listeners}" ] then for i in `cat ${listeners}` do uptime=`lsnrctl status ${i} | grep Uptime` if [ ${?} -eq 0 ] then lsnrlog=`lsnrctl status ${i} | grep "Listener Log" | awk '{print $4}'`

# # # # # # # #

if [ ! -f "${lsnrlog}" ] then echo "${lsnrlog} does not exist" echo "${HOST} ${lsnrlog} does not exist" >> ${MAILLIST} exit 1 fi printf "Now swapping the listener log for listener ${i}\n" KeepLogFile="${lsnrlog}.`date '+%d%b%Y'`" echo "LogFile is ${lsnrlog}" This will copy the listener log file to a save_set and initialise it echo "Appending ${lsnrlog} to ${KeepLogFile}" cat ${lsnrlog} >> ${KeepLogFile} if [ ${?} -eq 0 ] then cat /dev/null > ${lsnrlog} if [ ${?} -eq 0 ] then echo "${lsnrlog} initialised" Name of listener log file ========================= echo "${i}.log" > ${WorkDir}/lsnrlogfile Length (number of bytes) of name of listener log file ----------------------------------------------------lngth_logfle=`cat ${WorkDir}/lsnrlogfile | \ awk '{print length($1)}` Remove temporary file --------------------rm -f ${WorkDir}/lsnrlogfile Length of full listener log path (i.e incl log name) ==================================================== lngth_logpth=`lsnrctl stat ${i} | grep "Listener Log" | \ awk '{print length($4)}'` Length of log path (excl log name) ================================== ((lngth_logdir = ${lngth_logpth} - ${lngth_logfle})) Listener log directory ====================== lsnrlogdir=`lsnrctl status ${i} | grep "Listener Log" | \ awk '{print $4}' | cut -c1-${lngth_logdir}`

# # # #

logcnt=`find ${lsnrlogdir} -name "${i}.log.*" -mtime +7 | wc -w` echo "Removing ${logcnt} ${i}.log files older than 7 days" find ${lsnrlogdir} -name "${i}.log.*" -mtime +7 -exec rm {} \; else echo "${lsnrlog} could not be initialised" echo "${HOST} ${lsnrlog} could not be initialised" >> ${MAILLIST} fi else SUBJECT="Subject: Copy Error for listener log - ${i}" echo "Appending ${lsnrlog} to ${KeepLogFile} - failed !!!\n" echo "Initialise of ${lsnrlog} not done" echo "${HOST} Appending/Initialise of ${lsnrlog} failed" >> ${MAILLIST} fi

fi done rm -f ${listeners} else echo "${SUBJECT} Scan listeners failed\n" echo "${HOST} Scan for listeners failed" >> ${MAILLIST} fi else printf "Unable to swap listener log files - Listener down\n" echo "${HOST} Unable to swap listener log files - Listener down" >> ${MAILLIST} fi

#!/bin/ksh # ----------------------------------------------------------------------# Filename: cktnsnms.ksh # Purpose: Check if all entries in the TNSNAMES.ORA file is valid. # Author: Frank Naude, Oracle FAQ # ----------------------------------------------------------------------# Modified by: Dave Venus (dvenus@aholdusa.com) on 17-MAR-2000. # ----------------------------------------------------------------------# Find correct TNSNAMES.ORA location if [ -f $ORACLE_HOME/network/admin/tnsnames.ora ]; then NETPATH=$ORACLE_HOME/network/admin fi if [ -f /var/opt/oracle/tnsnames.ora ]; then NETPATH=/var/opt/oracle fi if [ -f /etc/tnsnames.ora ]; then NETPATH=/etc fi if [ ${TNS_ADMIN} ]; then NETPATH=${TNS_ADMIN} fi if [ ! ${NETPATH} ]; then echo "ERROR: Unable to locate TNSNAMES.ORA file." exit 8 else echo "# Use TNSNAMES.ORA in ${NETPATH}" fi # Read file and test all entries... grep -v -e '^ ' -e'^\t' -e'^$' -e '^#' -e'^)' ${NETPATH}/tnsnames.ora | awk '{sub("=", "", $1); print $1}' | while read NAME do OUT=`${ORACLE_HOME}/bin/tnsping $NAME | grep ADDRESS` if [ "${?}" = "1" ]; then echo "${NAME}: Unable to ping"

else # OUT=${OUT##*PORT=} # Strip off the port number # OUT=${OUT##*Port=} # OUT=${OUT##*port=} # PORT=${OUT%%\)*} # echo ${NAME} is alive on port ${PORT} echo "${NAME} is alive" fi done ######### Last Statement of: cktns.ksh #########

#!/bin/ksh # # # # # ----------------------------------------------------------------------Filename: webmon.ksh Purpose: Check if a webserver is responding to requests Author: Frank Naude, Oracle FAQ -----------------------------------------------------------------------

WEBSERVER=www.yourhost.com WEBPORT=80 MAILTO=address\@domain.com telnet $WEBSERVER $WEBPORT 2>/dev/null |& read -p CRAP 2>/dev/null read -p CRAP 2>/dev/null read -p CRAP 2>/dev/null print -p "get / http/1.0" 2>/dev/null print -p "" 2>/dev/null read -p LINE 2>/dev/null if [ "${LINE}" != "HTTP/1.0 200 OK" ]; then echo ERROR: Web Server is DOWN!!! /bin/mail $MAILTO <<-EOF Subject: $WEBSERVER: Web Server Down The Web server on $WEBSERVER doesn't respond to HTTP requests. Please investigate!!! EOF fi # Ensure the co-process is terminated exec 3>&p 3>&# Open pipe to web server # Ignore telnet headers

# Send HTTP request to server

#!/bin/ksh # # # # # --------------------------------------------------------------------------Filename: web2file.ksh Purpose: Download Web page to a flat file (eg. TNSNAMES.ORA) Author: Frank Naude, Oracle FAQ ---------------------------------------------------------------------------

WEBSERVER=www.orafaq.net WEBPORT=80 URLDIR=/download/tnsnames.ora TOFILE=tnsnames.ora telnet $WEBSERVER $WEBPORT 2>/dev/null |& IFS=~ read -p CRAP 2>/dev/null read -p CRAP 2>/dev/null read -p CRAP 2>/dev/null print -p "GET $URLDIR HTTP /1.0" 2>/dev/null print -p "" 2>/dev/null read -p LINE 2>/dev/null if [ "${LINE}" != "HTTP/1.0 200 OK" -a "${LINE}" != "HTTP/1.1 200 OK" ]; then echo "ERROR: Invalid response from Web Server: ${LINE}" exit 8 fi while [ "${LINE}" != "" ] do read -p LINE 2>/dev/null done rm -f "/tmp/${TOFILE}.web" while read -p LINE 2>/dev/null do echo "${LINE}" >>/tmp/${TOFILE}.web done if [ ! -z "/tmp/${TOFILE}.web" ]; then mv "/tmp/${TOFILE}.web" "${TOFILE}" fi # Process web page contents # Skip HTTP Headers # Ignore telnet headers # Open pipe to web server

# Send HTTP request to server

# Swap files

#!/usr/bin/ksh # ---------------------- Control Block ------------------------------

# # Program Name : index_rebuild 2.1 # Description : Rebuilds indexes in situ # Author : Chris Gould (chris_gould@hotmail.com) # Date Written : 99/02/27 23:16:23 # Version : @(#)shl gen index_rebuild 2.1@(#) # # Amendment History # Ref Version Date Author Description # 1.1 29/01/99 CMG Created # 1.2 02/02/99 CMG Tarting up # 1.3 03/02/99 CMG Handle unique constraints # 1.4 04/02/99 CMG Addn settings on index build # 1.5 23/02/99 CMG Include "getopts" processing # 1.6 27/02/99 CMG Add exit to end of script # 1.7 23/06/99 CMG Cater for bitmap indexes # 2.0 07/07/99 CMG additional options included # 2.1 08/07/99 CMG Now allows single index selection # (if constraint exists on this, disables it # but still disables all FK constraints) # --------------------------------------------------------------------------## ## Creates script to rebuild indexes on a table ## (using current settings) ## Also handles any primary and foreign key constraints ## by disabling and then re-enabling any that are initially enabled function Usage { echo "\n$THIS_FILE\n usage :" echo " $THIS_FILE -t TABLE_NAME -f OUTPUT_FILE [-A] [-u DB_CONNECT_STRING]" echo " [-N] [-i INDEX_NAME] [-p DDICT_TABLE_PREFIX] -D" echo "\n -A : append to output file" echo " -N : non-unique indexes only" echo " -D : debug (keep temp files)" echo "" } THIS_FILE=$(basename $0) P_DB_STR=/ ## default APPEND_TO_SCRIPT=N BUILD_TYPE="all" ## getopts processing while getopts "ADf:i:p:t:Nu:" opt do case $opt in A ) APPEND_TO_SCRIPT=Y;; D ) DEBUG=Y;; N ) UNIQUE_INDEXES=N;BUILD_TYPE="Non-unique";; f ) REBUILD_SCRIPT=$OPTARG;; i ) typeset -u INDEXNAME=$OPTARG;; p ) TB_PFX=$OPTARG;; t ) typeset -u TABLENAME=$OPTARG;; u ) P_DB_STR=${OPTARG:-/};;

* ) Usage;exit 10;; esac done shift $(($OPTIND -1)) ## Check parameters if [[ -n $REBUILD_SCRIPT && -n $TABLENAME ]]; then echo "Parameters OK ..." echo "Building index script for $TABLENAME \c" if [[ -n $INDEXNAME ]]; then BUILD_TYPE="single" echo "index $INDEXNAME \c" fi echo "..." else Usage exit 10 fi WORK_DIR=/tmp/${THIS_FILE}_$$ mkdir $WORK_DIR if (( $? > 0 )); then echo "+++Error: cannot create work directory $WORK_DIR" exit 10 fi TMP1_SQL=${WORK_DIR}/tmp1.sql GEN_ENABLE_FK_SQL=${WORK_DIR}/gen_enable_fk.sql GEN_DISABLE_FK_SQL=${WORK_DIR}/gen_disable_fk.sql GEN_ENABLE_PK_SQL=${WORK_DIR}/gen_enable_pk.sql GEN_DISABLE_PK_SQL=${WORK_DIR}/gen_disable_pk.sql GEN_DROP_IDX_SQL=${WORK_DIR}/gen_drop_idx.sql GEN_BLD_IDX_SQL=${WORK_DIR}/gen_bld_idx.sql ENABLE_FK_SQL=${WORK_DIR}/enable_fk.sql DISABLE_FK_SQL=${WORK_DIR}/disable_fk.sql ENABLE_PK_SQL=${WORK_DIR}/enable_pk.sql DISABLE_PK_SQL=${WORK_DIR}/disable_pk.sql DROP_IDX_SQL=${WORK_DIR}/drop_idx.sql BLD_IDX_SQL=${WORK_DIR}/bld_idx.sql ### if just dealing with non-unique indexes there won't ### be any constraints using them, so don't need these if [[ $UNIQUE_INDEXES != N ]]; then ### ### Create SQL to disable/enable foreign-key constraints ### referencing this table { echo echo echo echo "set "set "set "set head off" feedback off" linesize 132" pagesize 0 "

echo "select 'alter table '||uc1.owner||'.'||uc1.table_name||"

echo echo echo echo echo echo echo

" ' disable constraint '||uc1.constraint_name||';'" "from ${TB_PFX}user_constraints uc1" " ,${TB_PFX}user_constraints uc2" "where uc2.table_name = '$TABLENAME'" " and uc2.constraint_name = uc1.r_constraint_name" " and uc2.owner = uc1.r_owner" "/"

} >$GEN_DISABLE_FK_SQL echo "Creating FK disable stmts ..." cat $GEN_DISABLE_FK_SQL | sqlplus -S $P_DB_STR >$DISABLE_FK_SQL { echo echo echo echo echo echo echo echo echo echo echo echo echo "set "set "set "set head off" feedback off" linesize 132" pagesize 0 "

"select decode(uc1.status,'DISABLED','REM ',NULL)||" " 'alter table '||uc1.owner||'.'||uc1.table_name||" " ' enable constraint '||uc1.constraint_name||';'" "from ${TB_PFX}user_constraints uc1" " ,${TB_PFX}user_constraints uc2" "where uc2.table_name = '$TABLENAME'" " and uc2.constraint_name = uc1.r_constraint_name" " and uc2.owner = uc1.r_owner" "/"

} >$GEN_ENABLE_FK_SQL echo "Creating FK enable stmts ..." cat $GEN_ENABLE_FK_SQL | sqlplus -S $P_DB_STR >$ENABLE_FK_SQL ### ### Create SQL to disable/enable primary-key and unique constraints ### on this table { echo echo echo echo "set "set "set "set head off" feedback off" linesize 132" pagesize 0 "

echo "select 'alter table '||uc1.owner||'.'||uc1.table_name||" echo " ' disable constraint '||uc1.constraint_name||';'" echo "from user_constraints uc1" echo "where uc1.table_name = '$TABLENAME'" echo " and uc1.constraint_type in ('U','P')" echo " and uc1.status = 'ENABLED'" if [[ -n $INDEXNAME ]]; then ## all this just to get the constraint_name (if any) that uses this index echo echo echo echo "and uc1.constraint_name = (" " select constraint_name" " from ${TB_PFX}user_cons_columns ucc" " ,${TB_PFX}user_ind_columns uic"

echo echo echo echo echo echo echo echo echo echo echo echo echo echo echo echo echo echo echo echo fi echo "/"

" " " " " " " " " " " " " " " " " " " ")"

where and and and and

uic.index_name = '$INDEXNAME'" uic.table_name = ucc.table_name" uic.column_name = ucc.column_name" ucc.position = uic.column_position" ucc.position = (select max(uic2.column_position)" from ${TB_PFX}user_ind_columns uic2" where uic2.table_name = uic.table_name" and uic2.index_name = uic.index_name)" and ucc.position = (select max(ucc2.position)" from ${TB_PFX}user_cons_columns ucc2" where ucc2.constraint_name = ucc.constraint_name)" and ucc.position = (select count(*) " from ${TB_PFX}user_cons_columns ucc3" ,${TB_PFX}user_ind_columns uic3" where ucc3.constraint_name = ucc.constraint_name" and uic3.index_name = uic.index_name" and uic3.table_name = ucc3.table_name" and uic3.column_name = ucc3.column_name" and uic3.column_position = ucc3.position)"

} >$GEN_DISABLE_PK_SQL echo "Creating PK disable stmts ..." cat $GEN_DISABLE_PK_SQL | sqlplus -S $P_DB_STR >$DISABLE_PK_SQL { echo echo echo echo "set "set "set "set head off" feedback off" linesize 132" pagesize 0 "

echo "select 'alter table '||uc1.owner||'.'||uc1.table_name||" echo " ' enable constraint '||uc1.constraint_name||';'" echo "from ${TB_PFX}user_constraints uc1" echo "where uc1.table_name = '$TABLENAME'" echo " and uc1.constraint_type in ('U','P')" echo " and uc1.status = 'ENABLED'" if [[ -n $INDEXNAME ]]; then ## all this just to get the constraint_name (if any) that uses this index echo echo echo echo echo echo echo echo echo echo echo echo echo echo "and uc1.constraint_name = (" " select constraint_name" " from ${TB_PFX}user_cons_columns ucc" " ,${TB_PFX}user_ind_columns uic" " where uic.index_name = '$INDEXNAME'" " and uic.table_name = ucc.table_name" " and uic.column_name = ucc.column_name" " and ucc.position = uic.column_position" " and ucc.position = (select max(uic2.column_position)" " from ${TB_PFX}user_ind_columns uic2" " where uic2.table_name = uic.table_name" " and uic2.index_name = uic.index_name)" " and ucc.position = (select max(ucc2.position)" " from ${TB_PFX}user_cons_columns ucc2"

echo echo echo echo echo echo echo echo echo echo fi echo "/"

" " " " " " " " " ")"

where ucc2.constraint_name = ucc.constraint_name)" and ucc.position = (select count(*) " from ${TB_PFX}user_cons_columns ucc3" ,${TB_PFX}user_ind_columns uic3" where ucc3.constraint_name = ucc.constraint_name" and uic3.index_name = uic.index_name" and uic3.table_name = ucc3.table_name" and uic3.column_name = ucc3.column_name" and uic3.column_position = ucc3.position)"

} >$GEN_ENABLE_PK_SQL echo "Creating PK enable stmts ..." cat $GEN_ENABLE_PK_SQL | sqlplus -S $P_DB_STR >$ENABLE_PK_SQL fi ### ### Create SQL to drop indexes { echo echo echo echo "set "set "set "set head off" feedback off" linesize 132" pagesize 0 "

echo "select 'drop index '||ui.index_name||';'" echo "from user_indexes ui" echo "where ui.table_name = '$TABLENAME'" if [[ $UNIQUE_INDEXES = N ]]; then echo "and ui.uniqueness = 'NONUNIQUE'" fi if [[ -n $INDEXNAME ]]; then echo "and ui.index_name = '$INDEXNAME'" fi echo "/" } >$GEN_DROP_IDX_SQL echo "Creating index drop stmts ..." cat $GEN_DROP_IDX_SQL | sqlplus -S $P_DB_STR >$DROP_IDX_SQL ### ### Create SQL to re-create indexes { echo "clear breaks" echo "clear columns" echo "break on idxnm on tblnm on echo echo echo echo echo "set "set "set "set "set head off" feedback off" linesize 132" pagesize 30 " maxd 60000" tblsp skip page"

echo "set arraysize 10" echo "-- pagesize needs to be large to get all cols on a page (max 16)" echo echo echo echo echo echo echo echo echo echo echo "col "col "col "col "col "col "col "col "col "col "col uniq new_value v_uniq noprint" bitm new_value v_bitm noprint" idxnm new_value v_idxnm noprint" tblnm new_value v_tblnm noprint" tblown new_value v_tblown noprint" colseq noprint" tblsp old_value v_tblsp noprint" init old_value v_init noprint" next old_value v_next noprint" pci old_value v_pci noprint" pcf old_value v_pcf noprint"

echo "TTITLE LEFT 'prompt table:' v_tblnm ' index:' v_idxnm SKIP -" echo "'create ' v_uniq ' ' v_bitm ' index ' v_idxnm SKIP ' on ' v_tblown '.' v_tblnm SKIP ' ('" echo "BTITLE LEFT ' ) ' SKIP ' tablespace ' v_tblsp SKIP -" echo "' pctfree ' v_pcf SKIP -" echo "' storage (initial ' v_init ' next ' v_next ' pctincrease ' v_pci ') unrecoverable noparallel' SKIP '/'" echo "select ui.index_name idxnm," echo " ui.table_name tblnm," echo " ui.table_owner tblown," echo " uic.column_position colseq," echo " ui.tablespace_name tblsp," echo " decode(ui.uniqueness,'UNIQUE','UNIQUE',NULL) uniq," echo " decode(ui.index_type,'BITMAP','BITMAP',NULL) bitm," echo " LTRIM(ui.initial_extent) init," echo " LTRIM(ui.next_extent) next," echo " LTRIM(ui.pct_increase) pci," echo " LTRIM(ui.pct_free) pcf," echo " decode(uic.column_position,1,NULL,',') leading_comma," echo " uic.column_name colnm" echo "from ${TB_PFX}user_indexes ui" echo " ,${TB_PFX}user_segments us" echo " ,${TB_PFX}user_ind_columns uic" echo "where uic.table_name = ui.table_name" echo "and uic.index_name = ui.index_name" echo "and us.segment_name = ui.index_name" echo "and us.tablespace_name = ui.tablespace_name" echo "and ui.table_name = '$TABLENAME'" if [[ $UNIQUE_INDEXES = N ]]; then echo "and ui.uniqueness = 'NONUNIQUE'" fi if [[ -n $INDEXNAME ]]; then echo "and ui.index_name = '$INDEXNAME'" fi echo "order by tblsp,tblnm,idxnm,colseq" echo "/" echo "ttitle off" echo "btitle off" } >$GEN_BLD_IDX_SQL echo "Creating index create stmts ..."

cat $GEN_BLD_IDX_SQL | sqlplus -S $P_DB_STR >$TMP1_SQL ## Now get rid of blank lines from constructed SQL sed /^$/d <$TMP1_SQL >$BLD_IDX_SQL ### ### Now put all the generated scripts together ### to produce the index rebuild script if [[ $APPEND_TO_SCRIPT = N ]]; then echo "" >$REBUILD_SCRIPT fi { echo "REM *******************************************" echo "REM $BUILD_TYPE index rebuild script for $TABLENAME" if [[ -n $INDEXNAME ]]; then echo "REM index $INDEXNAME" fi echo "REM (constraints currently disabled REM'd out)" echo "REM Created \c" date echo "REM *******************************************" echo "set timing on" } >>$REBUILD_SCRIPT echo "Creating final script ..." if [[ $UNIQUE_INDEXES != N ]]; then cat \ $DISABLE_FK_SQL \ $DISABLE_PK_SQL \ >>$REBUILD_SCRIPT fi cat \ $DROP_IDX_SQL \ $BLD_IDX_SQL \ >>$REBUILD_SCRIPT if [[ $UNIQUE_INDEXES != N ]]; then cat \ $ENABLE_PK_SQL \ $ENABLE_FK_SQL \ >>$REBUILD_SCRIPT fi if [[ $APPEND_TO_SCRIPT = N ]]; then echo "exit" >>$REBUILD_SCRIPT fi echo "Done" if [[ $DEBUG = Y ]]; then echo "** temp files are in ${WORK_DIR}" else rm -rf ${WORK_DIR} >/dev/null 2>&1 fi

#!/bin/ksh # # # # # # ----------------------------------------------------------------------Filename: mailx.ksh Purpose: Demonstrates how one can attach files when sending E-Mail messages from the Unix mailx utility. Author: Frank Naude, Oracle FAQ -----------------------------------------------------------------------

SUBJECT="Send mail from Unix with file attachments" TO=address\@domain.com SPOOLFILE=/tmp/sqlplus.txt echo "Produce listing from SQL*Plus..." sqlplus -s scott/tiger >$SPOOLFILE <<-EOF set echo off feed off veri off pages 0 head off select * from tab; EOF # echo "Convert file to DOS mode..." # unix2dos $SPOOLFILE $SPOOLFILE 2>/dev/null echo "Send the E-mail message..." /usr/bin/mailx -s "${SUBJECT}" ${TO} <<-EOF Hi, This sample E-mail message demonstrates how one can attach files when sending messages with the Unix mailx utility. First attachment: SQL*Plus spool file ~< ! uuencode $SPOOLFILE `basename $SPOOLFILE` Second attachment: mailx.ksh (this script) ~< ! uuencode mailx.ksh mailx.txt Third attachment: /etc/passwd file ~< ! uuencode /etc/passwd passwords Best regards ~. EOF echo "Done!"

#!/bin/ksh # # # # # # -------------------------------------------------------------------Script: unix_mail_withattachments.ksh Aurthor: Ravin Maharaj Purpose: Use sendmail to e-mail messages from Unix with file attachements --------------------------------------------------------------------

SUBJ="Send mail from Unix with file attachments" TO=someone@domain_name CC=someoneelse_1@domain_name,someoneelse_2@domain_name ( cat << ! To : ${TO} Subject : ${SUBJ} Cc : ${CC} ! cat << ! HOPE THIS WORKS This sample E-mail message demonstrates how one can attach files when sending messages with the Unix sendmail utility. ! uuencode ${file_1} uuencode ${file_2} uuencode ${file_3} ! ${file_1} ${file_2} ${file_3}

) | sendmail -v ${TO} ${CC}

#!/bin/ksh # -------------------------------------------------------------------# Change a string in all files in the current directory # NOTES: Remember to change the FROM and TO variables # Frank Naude - Oracle FAQ # -------------------------------------------------------------------FROM="ORA920" TO="ORA1020" EXCLUDE=`basename $0` # find . -name ... -exec grep -l ... {} \; | while read FILE for FILE in `grep -l ${FROM} * | grep -v $EXCLUDE` do # Make backup of file,,, cp ${FILE} ${FILE}.bak # Edit the file...

sed "s/${FROM}/${TO}/g" <${FILE} >/tmp/sed_work # Copy back if OK... if [ -s "/tmp/sed_work" ]; then mv /tmp/sed_work ${FILE} else echo Something is wrong - abort exit -1 fi done

#!/bin/ksh # # # # # # ----------------------------------------------------------------------Filename: dumpdata.ksh Purpose: Dump first record of binary file according to C-language definition to see if the data and layout match. Author: Frank Naude, Oracle FAQ ----------------------------------------------------------------------# Binary data file # Map file - C field definitions (see sample below) # Offset of fist record in DATAFILE

DATAFILE=y.data MAPFILE=y.map STARTPOS=16

cat $MAPFILE | while read line do X=`echo $line | cut -d\[ -f 2` FLD=`echo $line | cut -d\[ -f 1` BYTES=`echo $X | cut -d\] -f 1`

# get variable name # get variable length

# Map the variable to the data file... VAL=`od -j $STARTPOS -N $BYTES -c $DATAFILE | cut -c11- | tr -s '\t' ' '` echo "$FLD len=$BYTES val=[$VAL]" ((STARTPOS=STARTPOS+BYTES)) done VAL=`od -j $STARTPOS -N 20 -c $DATAFILE | cut -c11- | tr -s '\t' ' '` echo "First 20 bytes of 2nd record = [$VAL]" # Sample MAPFILE: # --------------# char rowid[18]; # char ename[6]; # unsigned char sal[8]; # unsigned char comm[8]; # char car_reg[8]; #

#!/bin/ksh # --------------------------------------------------------------------------# Filename: vxfreesp.ksh # Purpose: List free space for disk groups # (Veritas Volume Manager required) # Author: Frank Naude, Oracle FAQ # --------------------------------------------------------------------------DISKGROUPS=`vxdisk list | grep ^e | nawk '{print $4}' | sort -u` for DG in $DISKGROUPS do echo "Disk Group $DG:" vxprint -ht BEGIN /gen/ END -g $DG | nawk ' {i = 0} {i = i + $6} {print "... Total size: " i/2/1024 " Meg"}'

vxdg -g $DG free | nawk ' { if ($5/2/1024 > 100) print "... Free chunk: " $5/2/1024, "Meg" }' done

#!/bin/ksh # --------------------------------------------------------------------------# Filename: vxcreate.ksh # Purpose: Create volume to be added to Oracle database as raw file # (Veritas Volume Manager required) # Author: Frank Naude, Oracle FAQ # --------------------------------------------------------------------------### Create volumes cat x.map | grep -v '^#' | while read VOL DG SIZ TS do ((SIZ=SIZ*1024*1024/512+100)) echo "Create volume $VOL in $DG with size $SIZ" NCOL=`vxprint -htg $DG | grep '^dm' | wc -l | awk '{print $1}'` vxassist -g $DG -U gen make $VOL $SIZ layout=stripe,nolog stripewidth=64k ncol=$NCOL vxedit -g ${DG} set user=oracle $VOL vxedit -g ${DG} set group=dba $VOL

vxedit -g ${DG} set mode=660 $VOL done #### Add volumes to Oracle database . ~oracle/.profile cat x.map | grep -v '^#' | while read VOL DG SIZ TS do echo "Create tablespace $TS.." if [ $TS = "NONE" ]; then continue; fi sqlplus -s /nolog <<-EOF connect system/manager create tablespace $TS DATAFILE '/dev/vx/rdsk/$DG/$VOL' size ${SIZ}M; alter tablespace $TS ADD DATAFILE '/dev/vx/rdsk/$DG/$VOL' size ${SIZ}M; exit; EOF done ### Sample MAP file: ### ---------------# ccms_redo01 DG6206 500 NONE # ccms_redo02 DG6206 500 NONE # ccms_redo03 DG6206 500 NONE # ccms_control01 DG6207 100 NONE # ccms_control02 DG6206 100 NONE # ccms_control03 DG6205 100 NONE # ccms_userdata01 DG6201 1000 DATA_USER # ccms_userindex01 DG6202 1000 INDEX_USER # ccms_infokeydata01 DG6203 1000 INFOKEY_DATA # ccms_infokeyindex01 DG6204 500 INFOKEY_INDEX # ccms_rbs01 DG6205 1000 RBS # ccms_system01 DG6206 500 SYSTEM # ccms_temp01 DG6206 1000 TEMP # ccms_tools01 DG6207 100 TOOLS #

#!/bin/ksh # --------------------------------------------------------------------------# Filename: vxdelete.ksh # Purpose: Delete a volume # (Veritas Volume Manager required) # Warning: Make sure nobody uses the volume and that it is not part of # your database anymore. # Author: Frank Naude, Oracle FAQ

# --------------------------------------------------------------------------vxedit -g DG6201 -fr rm opdlve_opdisdata20

#!/bin/ksh # --------------------------------------------------------------------------# Filename: vxrename.ksh # Purpose: Rename a volume # (Veritas Volume Manager required) # Author: Frank Naude, Oracle FAQ # --------------------------------------------------------------------------echo Rename OldName vxedit -g DiskGroup vxedit -g DiskGroup vxedit -g DiskGroup vxedit -g DiskGroup vxedit -g DiskGroup to NewName in DiskGroup... -v rename OldName NewName -p rename OldName-a NewName-1 set user=oracle NewName set group=dba NewName set mode=660 NewName

#!/bin/ksh # --------------------------------------------------------------------------# Filename: vxrename.ksh # Purpose: Rename a volume # (Veritas Volume Manager required) # Author: Frank Naude, Oracle FAQ # --------------------------------------------------------------------------echo Rename OldName vxedit -g DiskGroup vxedit -g DiskGroup vxedit -g DiskGroup vxedit -g DiskGroup vxedit -g DiskGroup to NewName in DiskGroup... -v rename OldName NewName -p rename OldName-a NewName-1 set user=oracle NewName set group=dba NewName set mode=660 NewName

Anda mungkin juga menyukai