Oracle 12c rman auf CentOS7 Cronjob funktioniert nicht
Guten Morgen zusammen,
ich bin einem Problem auf der Spur und suche Rat bei euch.
Es geht um folgendes:
Betriebssystem: CentOS7 Minimal mit Oracle 12 c Standard Edition 2
Anwendung: rman backup manager
rmanbackup Ordner auf oracle:oinstall 775 Rechte
backup_rman.log datei auf oracle:oinstall 775 rechte
Logge mich als Orcale user ein setze richtige SID.
Führe folgendes Script manuell aus:
funktioniert tadellos.
jetzt möchte ich das ganze als cronjob laufen lassen unter User Oracle wie folgt:
(mit root auch schon versucht, selbes problem)
(((SID ist manuell festgelegt)))
55 2 * * * /u01/app/oracle/product/12.2.0/dbhome_1/backup_rman.sh
jedoch taucht folgendes Problem auf wenn ich das über einen Cronjob laufen lasse:
manuell funktiniert das und via cronjob nicht?
Was mache ich flasch oder übersehe ich ???
Freue mich auf euer Feedback
ich bin einem Problem auf der Spur und suche Rat bei euch.
Es geht um folgendes:
Betriebssystem: CentOS7 Minimal mit Oracle 12 c Standard Edition 2
Anwendung: rman backup manager
rmanbackup Ordner auf oracle:oinstall 775 Rechte
backup_rman.log datei auf oracle:oinstall 775 rechte
Logge mich als Orcale user ein setze richtige SID.
Führe folgendes Script manuell aus:
#! /bin/bash
#
# /opt/oracle/bin/backup_rman.sh
#
# 2014-Nov-06 ada changed the way in which it checks for Primary or Standby
# 2013-Jun-06 vl removed extra memory for rman again
# 2013-Jun-06 pmo added support for systems running in german language
# 2013-Apr-25 vl more memory for rman; adjust default bakwin to 7 days to be in sync with default retention policy for controlfile
# 2013-Apr-10 vl remove filesperset
# 2013-Apr-09 vl backup retention policy only for primary server
# 2013-Apr-05 vl remove redundant commands, incremental backup during the week, remove archwin, change bakwin rule
# 2013-Feb-01 ada added NLS_DATE_FORMAT
# 2012-Sep-04 ada added "as compressed backupset" from #2278693
# 2012-Aug-28 pmo changed Mail to mailx
# 2012-Jul-04 pmo 'alter system archive log current' now dependent on database_role
# 2011-Oct-14 dk changed nomenklatura for backup name. DBID included now
# 2011-Sep-12 vl add support for red hat Enterprise Linux Server. source .bash_profile
# 2009-Jul-03 pe bugfix: SLES sets an Environment that avoids a successful rman login, use .profile instead
# 2009-Jan-08 ahu changed command order, first delete obsoletes and then backup
# 2008-Nov-11 pe bugfix: SLES 9 sets an Environment that avoids a successful rman login, use .profile instead
# 2008-Oct-27 pe on Solaris source .profile if available
# 2008-Jun-12 aka logfile includes history information now (append-write)
# 2008-Feb-26 vl/aka archivelog deletion changed
# 2008-Feb-25 aka rewritten for full backup -
# backup + database id is enough to reconstruct all necessary files
# typical cron: 40 5 * * * test -x /opt/oracle/bin/backup_rman.sh && /opt/oracle/bin/backup_rman.sh
#
# use
#
# find ~corpus/css/app ~corpus/cscs/app -name "*.xml" | xargs grep -P '<cron\s+pattern='
#
# to checkout cronjobs within platform. grep option -h suppresses filename output
#
# script parameters - change at installation time
set -x
bakdir=/rmanbackup
bakwin=7 # backup window in days - must be greater than 7 because only one full backup a week
# keeptime in oracle should be more than bakwin. Check with: "show parameter keep_time;"
# and change if needed: "alter system set control_file_record_keep_time=14 scope=both;"
logfil=/var/log/backup_rman.log
esetup=/etc/profile.d/oracle.sh # Solaris: ~oracle/.profile should contain all variable definitions
mailad=root
dbid=$(echo -e "select dbid from v\$database;" | sqlplus / as sysdba 2>/dev/null | grep [0-9][0-9][0-9][0-9][0-9][0-9] | sed -e 's/ //g')
Error () { echo >&2 "$*"; exit 1; }
# reread environment if necessary (ORACLE_SID) and available
test -z "$ORACLE_SID" -a -f "$esetup" && source "$esetup"
test $(uname) = Linux -a -f /etc/SuSE-release && grep -i "SUSE LINUX Enterprise Server" /etc/SuSE-release >/dev/null && source ~oracle/.profile
test $(uname) = Linux -a -f /etc/redhat-release && grep -i "Red Hat Enterprise Linux Server" /etc/redhat-release >/dev/null && source ~oracle/.bash_profile
# check environment
test $(uname) = SunOS && { test -e ~oracle/.profile && source ~oracle/.profile; }
test -z "$ORACLE_SID" && Error "\$ORACLE_SID required."
test -z "$ORACLE_HOME" && Error "\$ORACLE_HOME required."
test ! -d "$ORACLE_HOME" && Error "dir ORACLE_HOME='$ORACLE_HOME' not found."
test ! -d "$bakdir" && Error "dir bakdir='$bakdir' not found."
touch "$logfil" || Error "log '$logfil' not writeable."
rman=$ORACLE_HOME/bin/rman
test ! -x "$rman" && Error "rman program '$rman' not found or not executable."
test "$bakwin" -ge 7 >&/dev/null || Error "bakwin='$bakwin' must greater-equal 7."
# increase memory for rman
# export ORA_RMAN_SGA_SIZE=33554432
# exec rman with logging
exec >>$logfil 2>&1
echo
echo "-----------------------------------------------------------"
echo "$(date +"%Y-%m-%d_%H:%M:%S") starting rman backup..."
# define backup methods depending on day of week
if test "$(date +%a)" = Sat -o "$(date +%a)" = Sa; then
BACKUPMETHOD="backup as compressed backupset incremental level 0 database plus archivelog;"
else
BACKUPMETHOD="backup as compressed backupset incremental level 1 database plus archivelog;"
fi
# check db role because BAKWIN can only defined on the primary
DATABASE_ROLE=$(echo -e "whenever sqlerror exit sql.sqlcode;\nconnect / as sysdba;\nselect database_role, open_mode from v\$database;\nquit;" | sqlplus /nolog || Error "cannot determine database_role, open_mode from v\$database;")
echo $DATABASE_ROLE | grep "PHYSICAL STANDBY MOUNTED" > /dev/null &&
BACKUPWIN="" ||
BACKUPWIN="configure retention policy to recovery window of $bakwin days;"
export NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS'
set -x
$rman target / <<-EOF
configure channel device type disk format '$bakdir/$ORACLE_SID-$dbid-ora-df%t_s%s_s%p';
configure controlfile autobackup format for device type disk to '$bakdir/$ORACLE_SID%F';
configure backup optimization on;
$BACKUPWIN
run {
delete noprompt obsolete;
}
run {
$BACKUPMETHOD
}
quit;
EOF
ec=$?
type Mail >&/dev/null && Mail=Mail || Mail=/usr/bin/mailx
test $ec != 0 && echo "see log '$logfil'" | \
$Mail -s "$HOSTNAME: error '$ec' on rman backup" $mailad
echo "$(date +"%Y-%m-%d_%H:%M:%S") rman backup finished."
~
funktioniert tadellos.
jetzt möchte ich das ganze als cronjob laufen lassen unter User Oracle wie folgt:
(mit root auch schon versucht, selbes problem)
(((SID ist manuell festgelegt)))
55 2 * * * /u01/app/oracle/product/12.2.0/dbhome_1/backup_rman.sh
jedoch taucht folgendes Problem auf wenn ich das über einen Cronjob laufen lasse:
Subject: Cron <oracle@EFAGLIVEDB01> /u01/app/oracle/product/12.2.0/dbhome_1/backup_rman.sh
Content-Type: text/plain; charset=UTF-8
Auto-Submitted: auto-generated
Precedence: bulk
X-Cron-Env: <XDG_SESSION_ID=3697>
X-Cron-Env: <XDG_RUNTIME_DIR=/run/user/1000>
X-Cron-Env: <LANG=en_US.UTF-8>
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/u01/app/oracle/product/12.2.0/dbhome_1>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=oracle>
X-Cron-Env: <USER=oracle>
Message-Id: <20171109085501.54970C8001800@EFAGLIVEDB01.softlayer.com>
Date: Thu, 9 Nov 2017 02:55:01 -0600 (CST)
+ bakdir=/rmanbackup
+ bakwin=7
+ logfil=/var/log/backup_rman.log
+ esetup=/etc/profile.d/oracle.sh
+ mailad=root
++ echo -e 'select dbid from v$database;'
++ sqlplus / as sysdba
++ sed -e 's/ //g'
++ grep '[0-9][0-9][0-9][0-9][0-9][0-9]'
+ dbid=
+ test -z '' -a -f /etc/profile.d/oracle.sh
++ uname
+ test Linux = Linux -a -f /etc/SuSE-release
++ uname
+ test Linux = Linux -a -f /etc/redhat-release
+ grep -i 'Red Hat Enterprise Linux Server' /etc/redhat-release
++ uname
+ test Linux = SunOS
+ test -z ''
+ Error '$ORACLE_SID required.'
+ echo '$ORACLE_SID required.'
$ORACLE_SID required.
+ exit 1
manuell funktiniert das und via cronjob nicht?
Was mache ich flasch oder übersehe ich ???
Freue mich auf euer Feedback
Bitte markiere auch die Kommentare, die zur Lösung des Beitrags beigetragen haben
Content-ID: 354234
Url: https://administrator.de/contentid/354234
Ausgedruckt am: 26.11.2024 um 01:11 Uhr