sp2-0640 error while doing coldbackup in crontab. [message #74445] |
Fri, 10 December 2004 11:54 |
Natraj
Messages: 53 Registered: March 2003
|
Member |
|
|
Hi ,
I when i am doing cold backup using cron job, i get the error .sp2:0640 not connected in my .lst file. in the log file i created its connecting to the databnase. itshows error as below
02:00.01 1 Files found in: /u01/app/oracle/admin/natraj/cold_bkup_nat
All files removed from /u01/app/oracle/admin/natraj/cold_bkup_nat
02:00.02 Backup commands generated
02:00.02 Shutdown immediate issued for instance raj 02:00.09 Instance raj shutdown
02:00.10 Database backed up to:
0 Database files
0 Log files
0 Copies of control file
0 .
0 Password file
1 Total files backed up
02:00.10 Startup issued for instance raj
02:00.16 Instance raj started
but says 0 files copied then shuts down the database and s. my tnsping is working. database is up and running.i dont want to stop and start the listener. how do i resolve this?
|
|
|
|
|
Re: sp2-0640 error while doing coldbackup in crontab. [message #74475 is a reply to message #74452] |
Fri, 17 December 2004 10:52 |
Natraj
Messages: 53 Registered: March 2003
|
Member |
|
|
Requirements:
# cold_bkup_gen.sql
# .pwget.sh
# .pwtab
#
############################################################################
#
# Set up environment variables:
export ORACLE_BASE=/u01/app/oracle
# Accept input as oracle version and set oracle home accordingly
if [[ $# -gt 1 ]]
then
export ORACLE_HOME=$ORACLE_BASE/product/$2
else
export ORACLE_HOME=$ORACLE_BASE/product/8.1.7
fi
#export ORACLE_HOME=$ORACLE_BASE/product/$2
export LOG_DIR=$ORACLE_BASE/logs
export SCRIPT_NAME=cold_bkup.sh
export SCRIPT_DIR=${ORACLE_BASE}/scripts
export TEMP_DIR=${ORACLE_BASE}/tmp
export ORATAB_DIR=/var/opt/oracle
# Accept input name of database to backup
if [[ $# -gt 0 ]]
then SID=$1
else
echo "ERROR: $SCRIPT_NAME - No instance name specified."
exit 1
fi
# Remove previous output log
export LOG_FILE=${LOG_DIR}/cold_bkup_${SID}.log
if [[ -f $LOG_FILE ]]
then rm $LOG_FILE
fi
# Check if this database is listed in the oratab file
if [[ `egrep -v '^#' $ORATAB_DIR/oratab |awk -F: '{print $1}'|grep $SID|wc -l` -eq 0 ]]
then
echo "ERROR: $SCRIPT_NAME - $SID is not listed in $ORATAB_DIR/oratab" >> $LOG_FILE
exit 1
fi
# Is this instance up? exit if it is not -- cannot create dynamic list of files
if [[ ` ps -fu oracle|grep "ora_[[a-z]]*_$SID"|wc -l ` -eq 0 ]]
then
echo "Warning: $SCRIPT_NAME - Instance $SID is not running. Unable to perform cold backup." >> $LOG_FILE
exit 2
fi
# Set up environment variables:
export ORACLE_SID=$SID
export COLD_BKUP_1=$ORACLE_BASE/admin/$SID/cold_bkup_1
# delete backup pieces from last run.
if [[ -f $COLD_BKUP_1/* ]]
then
TTL_CNT=`ls -l $COLD_BKUP_1/* |wc -l`
TIME_STAMP=`date '+%H:%M.%S'`
echo $TIME_STAMP $TTL_CNT Files found in: $COLD_BKUP_1 >> $LOG_FILE
rm $COLD_BKUP_1/*
echo "All files removed from $COLD_BKUP_1" >> $LOG_FILE
else
TIME_STAMP=`date '+%H:%M.%S'`
echo $TIME_STAMP No files found in: $COLD_BKUP_1 >> $LOG_FILE
fi
# Get traj password
PW=$($ORACLE_BASE/scripts/.pwget.sh $SID traj); export PW;
if [[ $PW = "ERROR" ]]
then
echo "$SCRIPT_NAME Error: Password retrieval - .pwget.sh." >> $LOG_FILE
exit 1
fi
# Generate commands to copy database
COLD_BKUP_CPY=$TEMP_DIR/cold_bkup_cpy_${SID}.lst
export COLD_BKUP_CPY
if [[ -f $COLD_BKUP_CPY ]]
then rm $COLD_BKUP_CPY
fi
$ORACLE_HOME/bin/sqlplus -S /nolog <<EOF
connect dbcron/$PW @$SID
set echo on;
@$SCRIPT_DIR/cold_bkup_gen $SID;
set echo off;
exit;
EOF
if [[ -f $COLD_BKUP_CPY ]]
then
TIME_STAMP=`date '+%H:%M.%S'`
echo $TIME_STAMP Backup commands generated >> $LOG_FILE
else
echo "No backup commands generated " >> $LOG_FILE
exit 2
fi
# Shutdown the instance
TIME_STAMP=`date '+%H:%M.%S'`
echo $TIME_STAMP Shutdown immediate issued for instance $SID >> $LOG_FILE
$ORACLE_HOME/bin/sqlplus -S /nolog <<EOF
connect / as sysdba
shutdown immediate
exit;
EOF
TIME_STAMP=`date '+%H:%M.%S'`
echo $TIME_STAMP Instance $SID shutdown >> $LOG_FILE
# Run commands to backup the database
chmod 740 $COLD_BKUP_CPY
. $COLD_BKUP_CPY
# Following are added to check the Zip files for zero size and email if any found
export LOCAL=`uname -n |tr '[[a-z]]' '[[A-Z]]'`
export LOGFILE=${LOG_DIR}/cold_bkup_chk_zerosize_${SID}.log
export MAILLIST_COLDBKUP_ERROR=/u01/app/oracle/admin/local_email_addr/maillist_coldbkup_error.dat
MSEND_ZEROSIZE_EMAIL=0
echo "" > $LOGFILE
ls -l $COLD_BKUP_1/*.gz | while read line
do
MM=`echo $line | awk '{print $5}'`
if [[ $MM -le 0 ]]
then
MSEND_ZEROSIZE_EMAIL=1
echo "Check Size: $line" >> $LOGFILE
fi
done
if [[ $MSEND_ZEROSIZE_EMAIL = 1 ]]
then
MSEND_ZEROSIZE_EMAIL=0
/usr/ucb/mail -s "Check! $LOCAL: $SID: ZIP files have 0 size" `cat $MAILLIST_COLDBKUP_ERROR` < $LOGFILE
fi
# End of zero-size (zipFile) checking
# Report completion counts
DBFILE_CNT=`ls -l $COLD_BKUP_1/*dbf*|wc -l`
LOGFILE_CNT=`ls -l $COLD_BKUP_1/*log*|wc -l`
CTL_CNT=`ls -l $COLD_BKUP_1/control*|wc -l`
INITORA_CNT=`ls -l $COLD_BKUP_1/init*.ora|wc -l`
INITORA_FULL_NAME=`ls $COLD_BKUP_1/init*.ora`
INITORA_BASE_NAME=`basename $INITORA_FULL_NAME`
PWFILE_CNT=`ls -l $COLD_BKUP_1/orapw*|wc -l`
TTL_CNT=`ls -l $COLD_BKUP_1/* |wc -l`
TIME_STAMP=`date '+%H:%M.%S'`
echo $TIME_STAMP Database backed up to: $COLD_BACKUP >> $LOG_FILE
echo " " $DBFILE_CNT Database files >> $LOG_FILE
echo " " $LOGFILE_CNT Log files >> $LOG_FILE
echo " " $CTL_CNT Copies of control file >> $LOG_FILE
echo " " $INITORA_CNT $INITORA_BASE_NAME >> $LOG_FILE
echo " " $PWFILE_CNT Password file >> $LOG_FILE
echo " " $TTL_CNT Total files backed up >> $LOG_FILE
# Restart the instance
TIME_STAMP=`date '+%H:%M.%S'`
echo $TIME_STAMP Startup issued for instance $SID >> $LOG_FILE
# Startup the instance
$ORACLE_HOME/bin/sqlplus -S /nolog <<EOF
connect / as sysdba
startup
exit;
EOF
TIME_STAMP=`date '+%H:%M.%S'`
echo $TIME_STAMP Instance $SID started >> $LOG_FILE
#
|
|
|
|
Re: sp2-0640 error while doing coldbackup in crontab. [message #74505 is a reply to message #74491] |
Tue, 21 December 2004 06:50 |
Natraj
Messages: 53 Registered: March 2003
|
Member |
|
|
Hi,
i havent reloaded the listener yet, however my server has 9.2.0.44 and 9.2.0.1, the 9.2.0.4 cold backup runs,whereas 9.2.0.1 fails. again in the env parameters, for 9.2.0 db, my tns_admin is configured to take 9.2.0.4, tnsping works correctly. do i need to look into any other parameter in the environmental settings of 9.2.0 database?why do you think the lisntener needs to be reloaded?
|
|
|
|
Re: sp2-0640 error while doing coldbackup in crontab. [message #74520 is a reply to message #74507] |
Fri, 24 December 2004 04:53 |
Natraj
Messages: 53 Registered: March 2003
|
Member |
|
|
Mahesh,
the listener is all fine.Actually when i run this cold backup script using cronjobsie when i schedule it, i get the error sp2-0640, however if i run it using nohup commenad.or for taht matter execute it immediately it goes through. i think trouble is with enironmental settings.. how does cronjob differ from nohup in this unique manner?
Thanks Natraj
|
|
|
Re: sp2-0640 error while doing coldbackup in crontab. [message #74521 is a reply to message #74520] |
Fri, 24 December 2004 09:06 |
Natraj
Messages: 53 Registered: March 2003
|
Member |
|
|
i got it amahesh, error was my oracle_home was 9.2.0... however in 9.2.0/network admin. i didnt have entry in tnsnames.ora.i had rntry of db in 9.2.0.4 's tnsnames.ora... once i added that it went thru clearly via cronjobs. need to research more on nohup..:0 unix is really interestng..
Thanks Natraj
|
|
|