Backup Configuration PPS
Backup Configuration PPS
Backup Configuration PPS
Page 1
Copyright © EVRY.
Page 2
Copyright © EVRY.
Requires the helper_partition_dbid in the rman schema in the CATALOG database (this will exists unless the CATALOG server is renewed)
sqlplus rman/<password>@dat-rman-scan:1521/rcatalog
CREATE TABLE helper_partition_dbid
( dbid number(10) NOT NULL,
partition varchar2(40) NOT NULL,
sid varchar2(10)
)
Installation
Install the new client (It will only install if there's newer software in the repo)
Page 3
Copyright © EVRY.
t096car_dat_sa-oracle
d096car_dat_sa-oracle
Page 4
Copyright © EVRY.
and so on...
Field Value
<dbname>_<hostname/clustername>-oracle
<dbname>_<hostname/clustername>-oracle
Agreement/Contract number:
Add dsm.sys
Page 5
Copyright © EVRY.
SErvername MARGE
TCPServeraddress 153.110.140.60
TCPPort 3010
Passwordaccess PROMPT
ERRORLOGname /u01/app/oracle/admin/backup/tdp_err.log
DISKBUFFSIZE 32
SErvername BART
TCPServeraddress 153.110.140.34
TCPPort 3010
Passwordaccess PROMPT
ERRORLOGname /u01/app/oracle/admin/backup/tdp_err.log
DISKBUFFSIZE 32" > $TIVOLIDIR/tsm/client/api/bin64/dsm.sys
chmod 644 $TIVOLIDIR/tsm/client/api/bin64/dsm.sys
If you change the ERRORLOGname you must remember to script below accordingly
Page 6
Copyright © EVRY.
Page 7
Copyright © EVRY.
/usr/tivoli/tsm/client/oracle/bin64/t096car/tdpo.opt
DSMI_ORC_CONFIG /usr/tivoli/tsm/client/oracle/bin64/dsm.opt_MARGE
DSMI_LOG /u01/app/oracle/admin/t096car/backup/dsmi.log
TDPO_FS adsmorc
TDPO_NODE T096CAR_DAT-SA-ORACLE
TDPO_OWNER oracle
TDPO_PSWDPATH /usr/tivoli/tsm/client/oracle/bin64/t096car
Content of /usr/tivoli/tsm/client/oracle/bin64/t096car
-rw-r----- 1 root dba 291 okt. 26 11:29 tdpo.opt
-rw-r--r-- 1 root system 66 okt. 26 11:29
TDPO.T096CAR_DAT-SA-ORACLE
For a cluster the dsm.sys and files under /usr/tivoli/tsm/client/oracle/bin64 must be copied to all nodes:
Page 8
Copyright © EVRY.
This script requires ssh passwordless login to be enabled for the root user among the nodes in the cluster (similar to the oracle user).
Schedule it in cron as root in order to propagate changes automatically
For a cluster this should be done only on one of the nodes which you designates to run the backup scripts.
Environment
Make sure ORACLE_HOME and TNS_ADMIN are pointing to the correct directories for the database you are configuring.
Database configuration
For PCI hardened databases or databases where the sys account is disabled the script must be run on the actual node where the database is
running (set ORACLE_SID and run sqlplus /nolog). For other databases the script can be executed from a remote node if you know the sys
password. In order to enable archiving you must shut down all but one node (RAC only) of the database and run the script from the last node from
sqlplus after setting correct ORACLE_SID.
Create/unlock sysbackup account, enable block change tracking and list archiving status
Page 9
Copyright © EVRY.
Oracle 11
conn / as sysdba
create profile EVRY_SYSBACKUP_PROFILE limit
failed_login_attempts unlimited;
alter profile EVRY_SYSBACKUP_PROFILE limit
failed_login_attempts unlimited
password_life_time unlimited
password_reuse_max unlimited
password_reuse_time unlimited
password_lock_time 1
password_grace_time 365
password_verify_function NULL
;
create user sysbackup identified by XYXYXYXYXYXY;
alter user sysbackup profile EVRY_SYSBACKUP_PROFILE;
grant connect,sysdba to sysbackup;
alter user sysbackup identified by XYXYXYXYXYXY;
alter user sysbackup account unlock;
ALTER DATABASE ENABLE BLOCK CHANGE TRACKING;
archive log list;
Oracle 12
connect / as sysdba
alter user sysbackup identified by XYXYXYXYXYXY;
alter user sysbackup account unlock;
grant sysbackup to sysbackup;
ALTER DATABASE ENABLE BLOCK CHANGE TRACKING;
archive log list;
If the "archive log list" shows that the database isn't running in archivelog mode immediately execute the script below to enable archiving:
Enable archiving
shutdown immediate;
startup mount;
alter database archivelog;
alter database open;
Configure RMAN
1. Add rcatalog entry to the correct tnsnames.ora
2. If it is not already present add an entry for the database you are going to back up in the tnsnames.ora (must use same name as the
service).
3. Download the script package from the PPS repo and untar it.
4. Execute create_backup_script_pps.sh
Page 10
4.
Copyright © EVRY.
Sample run
oracle@dat-efs-c04ora01 /home/oracle/q > ./create_backup_script_pps.sh
New ORACLE_SERVICE name: crcdb01
SYSBACKUP user password: XYXYXYXYXYXY
Oracle version 11g or older (Y/N): Y
ORACLE_BASE (/u01/app/oracle):
ORACLE_HOME (/u01/app/oracle/product/12.1.0/dbhome_1):
TNS_ADMIN (/u01/app/12.1.0.2/grid/network/admin):
RMAN catalog user (rman):
RMAN catalog user password (XYXYXYXYXYXY):
RMAN catalog database (rcatalog):
RMAN catalog is rcatalog
xspaceASxspaceSYSDBA
rman_env_mal
OBS !!
Check if environment file .rman_env is ok
/u01/app/oracle/admin/crcdb01/backup/rman/.rman_env
archivelog_backup.rcv
configure_rman.rcv
delete_obsolete.rcv
getdbid.sql
incr0_backup.rcv
incr1_backup.rcv
incr2_backup.rcv
insertdbid_rcatalog.sh
list.rcv
full_restore_point_in_time.rcv
full_restore.rcv
restore_datafile.rcv
crcdb01_archivelog_backup.rcv
crcdb01_configure_rman.rcv
crcdb01_crontab_list
crcdb01_delete_obsolete.rcv
crcdb01_getdbid.sql
crcdb01_incr0_backup.rcv
crcdb01_incr1_backup.rcv
crcdb01_incr2_backup.rcv
crcdb01_insertdbid_rcatalog.sh
crcdb01_list.rcv
crcdb01.dbid
crcdb01_full_restore_point_in_time.rcv
crcdb01_full_restore.rcv
crcdb01_restore_datafile.rcv
crcdb01_archivelog_backup.rcv
crcdb01_configure_rman.rcv
crcdb01_crontab_list
crcdb01_delete_obsolete.rcv
crcdb01_getdbid.sql
crcdb01_incr0_backup.rcv
crcdb01_incr1_backup.rcv
crcdb01_incr2_backup.rcv
crcdb01_insertdbid_rcatalog.sh
Page 11
Copyright © EVRY.
crcdb01_list.rcv
crcdb01.dbid
crcdb01_full_restore_point_in_time.rcv
crcdb01_full_restore.rcv
crcdb01_restore_datafile.rcv
crontab_list_mal
OBS !!
Check and modify backup schedule
/u01/app/oracle/admin/crcdb01/backup/rman/crcdb01_crontab_list
********************************************************************
* You have now created all scripts for backup and restore file
* Open the file
/u01/app/oracle/admin/crcdb01/backup/rman/crcdb01_crontab_list
* and add its content to crontab. Remember to uncomment the lines
Page 12
Copyright © EVRY.
********************************************************************
* To configure rman settings execute
* /u01/app/oracle/admin/crcdb01/backup/rman/crcdb01_configure_rman.rcv
and execute the <service>_configure_rman.rcv script in order to configure corect settings for backup, and register the database with
the catalog server.
Try to set time of incremental backup (0-2) between 05-22, as 2230 until 0500 is a peak time for the TSM server. This to avoid
overloading the TSM server, which when this happens in return will result in that PPS backup is stopped.
Post activities
If you earlier had TSM backup of /rman/backup directory, and now have moved all databases to TDP, remember to remove this directory,
and free the diskspace. Also remember to remove TSM backup of this filesystem
When RMAN backup is done for all databases on the server, and this backup is verified, remember to do the following:
disable backup of /fs/oracle_home<x> and /oradata filesystems on the server.
remove all old backups on /rman/backup. If the file system then is free, remove to free disk space. Use some of this space and
add it to the archive directory.
If this frees a lot of disk space, remember to remove this in the correct manner from the partition to reduce disk cost.
Remove stop and start of database from the TSM configuration.
Monitoring (overvåking) of the RMAN backup status
Monitoring of RMAN backup for PPS Oracle databases is available at http://alt-aot-app01.man.cosng.net/rman/. Note! Oracle 9i databases
are not included
Add script
Can be downloaded
Download rotate_rman_logs.sh
sudo su - oracle
mkdir -p $ORACLE_BASE/admin/scripts
cd $ORACLE_BASE/admin/scripts
wget http://153.110.72.43/software/Oracle/RMAN_TDPO/rotate_rman_logs.sh
rotate_rman_logs.sh
#!/usr/bin/ksh
# Rotation of old rman log files, and deletion of old files
# Rotate logs, and delete files older than x DAYS
# Run at 0600 Friday
# Tom Fladsrud 2014
# Crontab entry for oracle user
# RMAN TDPO log rotation
# 0 06 * * 5 $ORACLE_BASE/admin/scripts/rotate_rman_logs.sh
Page 13
Copyright © EVRY.
$ORACLE_BASE/admin 2>&1
#i.e
# 0 06 * * 5 /fs/oracle_home/admin/scripts/rotate_rman_logs.sh
/fs/oracle_home/admin 2>&1
#
DAYS=30
#FILE_TYPE=_backup.log
#DATO=`/usr/bin/date +'%y%m%d'`
Usage()
{
echo "Usage: $0 <directory>"
echo "<directory>: the directory to start searching for logfiles"
echo "Example: sh $0 $ORACLE_HOME/admin"
}
if [ $# -lt 1 ]
then
Usage
exit 1
fi
CUR_DIR=`pwd`
START_DIR=$1
cd "$START_DIR"
function rotate
{
date_daily=`date +"%d-%m-%Y"`
#echo "$date_daily"
#rotate the logs
for FILE1 in `ls | grep _backup.log | grep -v old`
do
cp $FILE1 $FILE1-old-$date_daily
> $FILE1
done
# clean up old logs
CUR_D=`pwd`
cd ..
#echo "find $CUR_D -type f -name '*-old-*' -mtime +$DAYS -print"
for FILE2 in `find $CUR_D -type f -name '*-old-*' -mtime +$DAYS
-print`
do
#echo "File $FILE2 to old. Will be deleted"
rm -f $FILE2
done
cd -
}
#ROTATE LOG FILES
for FILE in `ls`
do
if [ -d $FILE ]
then
#echo "$FILE is a subdirectory..."
if [ -d "$FILE/backup/rman/log" ]
then
#echo "$FILE/backup/rman/log exists"
Page 14
Copyright © EVRY.
cd "$FILE/backup/rman/log"
rotate
cd $START_DIR
Page 15
Copyright © EVRY.
fi
fi
done
Add to crontab
Add the following to crontab. Remember to uncomment
Entry in crontab
# RMAN TDPO log rotation
0 6 * * 5 /u01/app/oracle/admin/scripts/rotate_rman_logs.sh
/u01/app/oracle/admin 2>&1
cd /u0/app/oracle/admin/rman_scripts_temp/
sh create_backup_script_pps.sh
For connecting to Oracle 11 or lower, remove AS SYSBACKUP from the command. See HowtoconnecttoRMANandCATALOG for details.
Procedure for removing TDPO backup
rman
Page 16
Copyright © EVRY.
If the database is not to be reused, notify "EDB Drift TURNUS storage open" (z999sdms) that the tdpo node for the database can be removed,
and that all backup for this database shall be removed.
For connecting to Oracle 11 or lower, remove AS SYSBACKUP from the command. See HowtoconnecttoRMANandCATALOG for details.
rman
connect target SYSBACKUP/<PASSWORD>@DATABASE AS SYSBACKUP;
connect CATALOG rman/<password>@rcatalog;
UNREGISTER DATABASE NOPROMPT;
Then you must find the correct row of the DB table in the CATALOG database. Using the DB_ID you fond in he previous SQL
Then you can remove the database from the CATALOG database with the following SQL
Page 17
Copyright © EVRY.
Field Value
Tjenesteområde Datalagring
Appendix
Finding the service name for your database
restore of datafile
full restore
full restore at a specific restore point
Before running the script, you must of course alter the script to suit your need. What datafile you want to restore, what time and so on. Examples
is given in the files. The actual work is commented out to avoid someone running the scripts by accident, causing problems. Suggest they are
commented out again after usage.
Page 18
Copyright © EVRY.
Be aware that these scripts are not customized for Oracle 12c. For Oracle 12c or higher, use manual routines.
rman
connect target SYSBACKUP/<PASSWORD>@DATABASE AS SYSBACKUP;
connect CATALOG rman/<password>@rcatalog;
shutdown abort;
startup nomount;
restore controlfile;
You might get a error message saing "RMAN-06004: ORACLE error from recovery catalog database: RMAN-20005: target
database name is ambiguous":
Solution:
Find the dbid from one of the rman backup logfiles. Then set the dbid:
Then when someone has verified the database, run a full backup (incr0) uncomment the cronjobs for this database.
Page 19
Copyright © EVRY.
restore controlfile;
RESTORE DATABASE; # Restore datafiles from full backup.
alter database mount;
RECOVER DATABASE; # Append archive files to database.
RMAN-00571: ===========================================================
RMAN-00571: ===========================================================
Solution
Oracle does not stop the recovery at the last available archive log in the database backupsets as per the restored control file.
Instead it keeps on requesting for the "next available archive log sequence" number. But in reality, as per the above example,
there is no log sequence 3. So the database is already consistent after applying log sequence 2 (final archive log sequence as per
the restored control file) and hence the recovery is in fact successful. Just try to open the database with the resetlogs option. It
should work
You should get the "Database altered" message which indicates that the database was opened successfully.
Then when someone has verified the database, run a full backup (incr0) uncomment the cronjobs for this database.
One or more datafiles are corrupt or deleted - Restore and Recover entire database at one spesific point in time
This is not necessarily discovered during backup, but first discovered when using the database. It could the be desirable to restore
to a point in time where you know this worked.
For connecting to Oracle 11 or lower, remove AS SYSBACKUP from the command. See HowtoconnecttoRMANandCATALOG for details.
Page 20
Copyright © EVRY.
For connecting to Oracle 11 or lower, remove AS SYSBACKUP from the command. See HowtoconnecttoRMANandCATALOG for details.
Recovery with RMAN when controlfile also must be restored at a specific time
set NLS_DATE_FORMAT='Mon DD YYYY HH24:MI:SS'
rman
connect target SYSBACKUP/<PASSWORD>@DATABASE AS SYSBACKUP;
connect CATALOG rman/<password>@rcatalog;
shutdown abort;
startup force nomount;
run
{
set until time "to_date('2015-05-20:16:00:00',
'yyyy-mm-dd:hh24:mi:ss')";
RESTORE CONTROLFILE;
}
alter database mount;
run
{
set until time "to_date('2015-05-20:16:00:00',
'yyyy-mm-dd:hh24:mi:ss')";
restore database;
recover database;
}
alter database open resetlogs;
Because the database is a new incarnation, the backups made before the RESETLOGS are not easily
usable. For example, run the following to back up the database:
Page 21
Copyright © EVRY.
SHUTDOWN IMMEDIATE
STARTUP MOUNT
BACKUP DATABASE;
For connecting to Oracle 11 or lower, remove AS SYSBACKUP from the command. See HowtoconnecttoRMANandCATALOG for details.
rman
connect target SYSBACKUP/<PASSWORD>@DATABASE AS SYSBACKUP;
connect CATALOG rman/<password>@rcatalog;
Gjenopprettingsstyrer : Release 11.1.0.7.0 - Production on On Mar 5
09:38:10 2014
Copyright (c) 1982, 2007, Oracle. All rights reserved.
RMAN-00571:
===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS
===============
RMAN-00571:
===========================================================
RMAN-00554: feil ved initialisering av intern
gjenopprettingsstyrerpakke
RMAN-04005: feil fra mldatabasen:
ORA-00604: det oppstod en feil p rekursivt SQL-niv 1
ORA-01116: feil ved pning av databasefilen 1
ORA-01110: datafil 1: /fs/oracle_home4/fd11/system01.dbf
ORA-27041: kan ikke pne filen IBM AIX RISC System/6000 Error: 2: No
such file or directory Additional information: 3
If so, run ps -ef | grep smon_<oracle sid> and kill the process of the database you are working on.
For connecting to Oracle 11 or lower, remove AS SYSBACKUP from the command. See HowtoconnecttoRMANandCATALOG for details.
Page 22
Copyright © EVRY.
rman
connect target SYSBACKUP/<PASSWORD>@DATABASE AS SYSBACKUP;
connect CATALOG rman/<password>@rcatalog;
set dbid 1770049508
startup mount
RESTORE DATAFILE '/fs/oracle_home4/fd11/system01.dbf';
RECOVER DATAFILE '/fs/oracle_home4/fd11/system01.dbf';
alter database open;
RMAN-00571:
===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS
===============
RMAN-00571:
===========================================================
RMAN-03002: kommandoen alter db mislyktes ved 03/05/2014 10:41:35
ORA-01157: kan ikke identifisere/lse datafilen 3 - se sporingsfilen
for DBWR
ORA-01110: datafil 3: /fs/oracle_home4/fd11/undotbs01.dbf
If so run
If so, try the following, where you set the incarnation to the Inc Key of the PARENT. In this case the parent Inc Key was19669935
Page 23
Copyright © EVRY.
Then retry the operation you tried when getting the RMAN-06004 message.
Page 24