cp initCOPIA.ora initCOPIA.ora
Modificar directorios
Instancia 1
RMAN> backup database plus archivelog;
Instancia 1
SQL> alter database backup controlfile to trace;
REVISAR EL ARCHIVO GENERADO EN EL DIRECTORIO udump
Y MODIFICARLO
Instancia 2 OJO CAMBIAR REUSE POR SET
STARTUP NOMOUNT
CREATE CONTROLFILE SET DATABASE "COPIA" RESETLOGS ARCHIVELOG REUSE
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 '/u01/app/oracle/oradata/COPIA/redo01.log' SIZE 50M,
GROUP 2 '/u01/app/oracle/oradata/COPIA/redo02.log' SIZE 50M,
GROUP 3 '/u01/app/oracle/oradata/COPIA/redo03.log' SIZE 50M
DATAFILE
'/u01/app/oracle/oradata/COPIA/system01.dbf',
'/u01/app/oracle/oradata/COPIA/undotbs01.dbf',
'/u01/app/oracle/oradata/COPIA/sysaux01.dbf',
'/u01/app/oracle/oradata/COPIA/users01.dbf',
'/u01/app/oracle/oradata/COPIA/example01.dbf'
CHARACTER SET WE8ISO8859P1;
Database altered.
[afrodita_COPIA ]# rman target /
Recovery Manager: Release 10.2.0.4.0 - Production on Thu Oct 15 14:30:54 2009
Copyright (c) 1982, 2007, Oracle. All rights reserved.
connected to target database (not started)
RMAN> startup nomount;
Oracle instance started
Total System Global Area 1610612736 bytes
Fixed Size 2139256 bytes
Variable Size 396188552 bytes
Database Buffers 1207959552 bytes
Redo Buffers 4325376 bytes
RMAN> restore controlfile from '/u01/app/oracle/COPIA/flash_recovery_area/COPIA/autobackup/2009_10_15/o1_mf_s_700324017_5fgxw1yz_.bkp';
Starting restore at 15-OCT-09
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=107 devtype=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:02
output filename=/u01/app/oracle/oradata/COPIA/control01.ctl
output filename=/u01/app/oracle/oradata/COPIA/control02.ctl
output filename=/u01/app/oracle/oradata/COPIA/control03.ctl
Finished restore at 15-OCT-09
RMAN>
RMAN> catalog backuppiece '/u01/app/oracle/POWER/flash_recovery_area/POWER/backupset/2009_10_15/o1_mf_nnndf_TAG20091015T142630_5fgxv6ld_.bkp';
cataloged backuppiece
backup piece handle=/u01/app/oracle/POWER/flash_recovery_area/POWER/backupset/2009_10_15/o1_mf_nnndf_TAG20091015T142630_5fgxv6ld_.bkp recid=1 stamp=700327997
RMAN> list backup summary;
List of Backups
===============
Key TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag
------- -- -- - ----------- --------------- ------- ------- ---------- ---
1 B F A DISK 15-OCT-09 1 1 NO TAG20091015T142630
RMAN> restore database;
Starting restore at 15-OCT-09
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=106 devtype=DISK
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /u01/app/oracle/oradata/COPIA/system01.dbf
restoring datafile 00002 to /u01/app/oracle/oradata/COPIA/undotbs01.dbf
restoring datafile 00003 to /u01/app/oracle/oradata/COPIA/sysaux01.dbf
restoring datafile 00004 to /u01/app/oracle/oradata/COPIA/users01.dbf
restoring datafile 00005 to /u01/app/oracle/oradata/COPIA/example01.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/POWER/flash_recovery_area/POWER/backupset/2009_10_15/o1_mf_nnndf_TAG20091015T142630_5fgxv6ld_.bkp
channel ORA_DISK_1: restored backup piece 1
piece handle=/u01/app/oracle/POWER/flash_recovery_area/POWER/backupset/2009_10_15/o1_mf_nnndf_TAG20091015T142630_5fgxv6ld_.bkp tag=TAG20091015T142630
channel ORA_DISK_1: restore complete, elapsed time: 00:00:36
Finished restore at 15-OCT-09
RMAN> recover database;
Starting recover at 15-OCT-09
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=105 devtype=DISK
starting media recovery
RMAN> alter database open resetlogs;
database opened
Si se requiere entonces
RESTORE DATABASE UNTIL SEQUENCE 13243;
OTRO METODO
STARTUP NOMOUNT
RUN
{
RESTORE CONTROLFILE FROM 'save_controlfile_location';
ALTER DATABASE MOUNT;
RESTORE DATABASE FROM TAG before_upgrade
RECOVER DATABASE NOREDO;
ALTER DATABASE OPEN RESETLOGS;
}
jueves, 15 de octubre de 2009
RMAN Duplicate Windows
sc delete OracleServiceAUXPOWER
SQL> STARTUP mount PFILE=D:\oracle\product\10.2.0\admin\POWER\pfile\INITaux.ora;
SQL> create pfile = 'D:\oracle\product\10.2.0\admin\POWER\pfile\INITaux.ora' fro
m spfile;
Crear password
D:\oracle\product\10.2.0\admin\POWER\pfile>orapwd file=d:\oracle\product\10.2.0\
admin\POWER\pfile\pwdauxpower.ora password=oracle entries=5
Crear servicio
D:\oracle\product\10.2.0\admin\POWER\pfile>oradim -new -sid auxpower -startmode m -pfile D:\oracle\product\10.2.0\admin\POWER\pfile\INITaux.ora
Instance created.
SET ORACLE_SID=AUXPOWER
sqlplus "/as sysdba"
SQL>startup mount;
SQL>startup mount force;
SQL>select * from v$instance;
RMAN> rman target /@power auxiliary /
RMAN> duplicate target database to auxpower;
SQL> alter database open resetlogs;
File created.
RMAN
CONNECT AUXILIARY SYS/ORACLE@AUX.WORLD
CONNECT TARGET SYS/ORACLE@ORCL.WORLD
STARTUP CLONE NOMOUNT FORCE;
DUPLICATE TARGET DATABASE TO AUX;
*.control_files='D:\oracle\product\10.2.0\oradata\AUXPOWER\control01.ctl','D:\oracle\product\10.2.0\oradata\AUXPOWER\control02.ctl','D:\oracle\product\10.2.0\oradata\AUXPOWER\control03.ctl'
DUPLICATE TARGET DATABASE to auxpower UNTIL TIME “TO_DATE(’09/18/2008',’MM/DD/YYYY’)”;
DUPLICATE TARGET DATABASE TO auxpower NOFILENAMECHECK UNTIL TIME 'SYSDATE-7';
SQL> STARTUP mount PFILE=D:\oracle\product\10.2.0\admin\POWER\pfile\INITaux.ora;
SQL> create pfile = 'D:\oracle\product\10.2.0\admin\POWER\pfile\INITaux.ora' fro
m spfile;
Crear password
D:\oracle\product\10.2.0\admin\POWER\pfile>orapwd file=d:\oracle\product\10.2.0\
admin\POWER\pfile\pwdauxpower.ora password=oracle entries=5
Crear servicio
D:\oracle\product\10.2.0\admin\POWER\pfile>oradim -new -sid auxpower -startmode m -pfile D:\oracle\product\10.2.0\admin\POWER\pfile\INITaux.ora
Instance created.
SET ORACLE_SID=AUXPOWER
sqlplus "/as sysdba"
SQL>startup mount;
SQL>startup mount force;
SQL>select * from v$instance;
RMAN> rman target /@power auxiliary /
RMAN> duplicate target database to auxpower;
SQL> alter database open resetlogs;
File created.
RMAN
CONNECT AUXILIARY SYS/ORACLE@AUX.WORLD
CONNECT TARGET SYS/ORACLE@ORCL.WORLD
STARTUP CLONE NOMOUNT FORCE;
DUPLICATE TARGET DATABASE TO AUX;
*.control_files='D:\oracle\product\10.2.0\oradata\AUXPOWER\control01.ctl','D:\oracle\product\10.2.0\oradata\AUXPOWER\control02.ctl','D:\oracle\product\10.2.0\oradata\AUXPOWER\control03.ctl'
DUPLICATE TARGET DATABASE to auxpower UNTIL TIME “TO_DATE(’09/18/2008',’MM/DD/YYYY’)”;
DUPLICATE TARGET DATABASE TO auxpower NOFILENAMECHECK UNTIL TIME 'SYSDATE-7';
DUPLICATE
Crear la nueva instanacia donde se va a levantar la base de datos:
para eso vamos donde estan los archivos de inicializacion de las bases de datos de oracle.
cd $HOME/dbs
cp initorac.ora initoracrest.init
y modificamos el archivo “initoracrest.init”.
Cambiamos los paramentros donde diga “orac” por “oracrest” y cambiamos los path de:
1 archive
2 control
3 dump
Todos a la nueva ruta como se muestra:
log_archive_dest=/storage/restore/oracle/archive/
control_files=/storage/restore/oracle/control/cntrlorac.dbf,/storage/restore/oracle/control/contr2orac.dbf
rollback_segments = ROLL1,ROLL2,ROLL3,ROLL4,ROLL5,ROLL6,ROLL7,ROLL8,ROLL9,ROLL10,ROLL11,ROLL12,ROLL13,ROLL14,ROLL15,ROLL16,ROLL17,ROLL18,ROLL19,ROLL20,ROLL21
,ROLL22,ROLL23,ROLL24,ROLL25,ROLL26,ROLL27
core_dump_dest = /storage/restore/oracle/cdump
crear los anteriores directorios
ahora fijamos el ORACLE_SID=oracrest
export ORACLE_SID=oracrest
ahora nos conectamos como sysdba.
sqlplus '/as sysdba'
SQL>startup nomount;
y verificamos que tengamos la nueva instancia:
#ps -fea | grep pmon
Debe estar la “oracrest”
Ahora vamos a construir el script de recuperacion del control file:
/opt/oracle/rman/oracrest/
mdkir oracrest
cd oracrest
mkdir -p restore/control
cd restore/control
vi control.sh
y adicionamos
RECUPERAR ARCHIVO DE CONTROL
connect catalog rman/rman@cat9i;
set dbid=887613172;
connect target;
run {
ALLOCATE CHANNEL ch00
TYPE 'SBT_TAPE' parms 'ENV=(NB_ORA_CLIENT=heo_01_v4904,NB_ORA_POLICY=BD_Online_orac_heo_01_v4904,NB_ORA_SERV=bksrv01,NB_ORA_SCHED=Default-Application-Backup)';
restore controlfile;
RELEASE CHANNEL ch00;
}
Verificar que el restore fue exitoso.
oracle@heo_01_v4904-V4im:/storage/restore/oracle/control#ls
cntrlorac.dbf contr2orac.dbf
Ahora hacer el scrips de recuperar los datos:
oracle@heo_01_v4904-V4im:/rman/oracrest/restore/database#cat database.sh
connect catalog rman/rman@cat9i;
set dbid=887613172;
connect target;
run {
ALLOCATE CHANNEL ch00
TYPE 'SBT_TAPE' parms 'ENV=(NB_ORA_CLIENT=heo_01_v4904,NB_ORA_POLICY=BD_Online_orac_heo_01_v4904,NB_ORA_SERV=bksrv01,NB_ORA_SCHED=Default-Application-Backup)';
ALLOCATE CHANNEL ch01
TYPE 'SBT_TAPE' parms 'ENV=(NB_ORA_CLIENT=heo_01_v4904,NB_ORA_POLICY=BD_Online_orac_heo_01_v4904,NB_ORA_SERV=bksrv01,NB_ORA_SCHED=Default-Application-Backup)';
ALLOCATE CHANNEL ch02
TYPE 'SBT_TAPE' parms 'ENV=(NB_ORA_CLIENT=heo_01_v4904,NB_ORA_POLICY=BD_Online_orac_heo_01_v4904,NB_ORA_SERV=bksrv01,NB_ORA_SCHED=Default-Application-Backup)';
ALLOCATE CHANNEL ch03
TYPE 'SBT_TAPE' parms 'ENV=(NB_ORA_CLIENT=heo_01_v4904,NB_ORA_POLICY=BD_Online_orac_heo_01_v4904,NB_ORA_SERV=bksrv01,NB_ORA_SCHED=Default-Application-Backup)';
set newname for datafile 1 to '/storage/restore/oracle/datos/2systemorac1.dbf';
set newname for datafile 2 to '/storage/restore/oracle/datos/2tsr1.dat';
set newname for datafile 3 to '/storage/restore/oracle/datos/2tsr2.dat';
set newname for datafile 4 to '/storage/restore/oracle/datos/2tempgeneral.dbf';
set newname for datafile 5 to '/storage/restore/oracle/datos/2uhi_real_tmp.dbf';
set newname for datafile 6 to '/storage/restore/oracle/datos/2uhi_tab_tmp.dbf';
set newname for datafile 7 to '/storage/restore/oracle/datos/2HIS_tb_pr.dbf';
set newname for datafile 8 to '/storage/restore/oracle/datos/2HIS_i_pr.dbf';
set newname for datafile 9 to '/storage/restore/oracle/datos/2HIS_tb_bkp.dbf';
set newname for datafile 10 to '/storage/restore/oracle/datos/2HIS_i_bkp.dbf';
set newname for datafile 11 to '/storage/restore/oracle/datos/2conmut_real_tmp.dbf';
set newname for datafile 12 to '/storage/restore/oracle/datos/2conmut_tmp.dbf';
set newname for datafile 13 to '/storage/restore/oracle/datos/2_NEAX61E_tb_pr.dbf';
set newname for datafile 14 to '/storage/restore/oracle/datos/2_NEAX61E_i_pr.dbf';
set newname for datafile 15 to '/storage/restore/oracle/datos/2_NEAX61E_tb_bkp.dbf';
set newname for datafile 16 to '/storage/restore/oracle/datos/2_NEAX61E_i_bkp.dbf';
set newname for datafile 17 to '/storage/restore/oracle/datos/2_AXE_tb_pr.dbf';
set newname for datafile 18 to '/storage/restore/oracle/datos/2_AXE_i_pr.dbf';
set newname for datafile 19 to '/storage/restore/oracle/datos/2_AXE_tb_bkp.dbf';
set newname for datafile 20 to '/storage/restore/oracle/datos/2_AXE_i_bkp.dbf';
set newname for datafile 21 to '/storage/restore/oracle/datos/2BDCentral_idx.dbf';
set newname for datafile 22 to '/storage/restore/oracle/datos/2BDCentral_pr.dbf';
set newname for datafile 23 to '/storage/restore/oracle/datos/2BDCentral_tmp.dbf';
set newname for datafile 24 to '/storage/restore/oracle/datos/2dbgenap001.dbf';
set newname for datafile 25 to '/storage/restore/oracle/datos/2dbgenap002.dbf';
set newname for datafile 26 to '/storage/restore/oracle/datos/2dbgenap003.dbf';
set newname for datafile 27 to '/storage/restore/oracle/datos/2_MGPP_tb_pr.dbf';
set newname for datafile 28 to '/storage/restore/oracle/datos/2_MGPP_i_pr.dbf';
set newname for datafile 29 to '/storage/restore/oracle/datos/2_MGPP_tb_bkp.dbf';
set newname for datafile 30 to '/storage/restore/oracle/datos/2_MGPP_i_bkp.dbf';
set newname for datafile 31 to '/storage/restore/oracle/datos/2_MGPP_tb_pr1.dbf';
set newname for datafile 32 to '/storage/restore/oracle/datos/2_NEAX61E_tb_pr1.dbf';
set newname for datafile 33 to '/storage/restore/oracle/datos/2_AXE_tb_pr1.dbf';
restore database;
RELEASE CHANNEL ch00;
RELEASE CHANNEL ch01;
RELEASE CHANNEL ch02;
RELEASE CHANNEL ch03;
}
rman cmdfile=database.sh
verificar que el restore fue exitoso.
Nos conectamos a la base de datos para iniciar el proceso de subirla.
Como se esta restaurando sobre la misma maquina se requiere recrear el control file:
Recrear Archivo de Control.
SQL>alter database mount;
SQL>alter database backup controlfile to trace;
SQL>show parameters dump;
SQL>exit
Vamos a la ruta mostrada para los udump.
cd /opt/oracle/product/9.2.0.8/rdbms/log
ls -ltr
se edita y se cambian las rutas, tambien se cambian
cp orac_ora_7152.trc control
oracle@heo_01_v4904-V4im:/product/9.2.0.8/rdbms/log#cat orac_ora_7152.trc
Dump file /opt/oracle/product/9.2.0.8/rdbms/log/orac_ora_7152.trc
Oracle9i Enterprise Edition Release 9.2.0.8.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.8.0 - Production
ORACLE_HOME = /opt/oracle/product/9.2.0.8
System name: SunOS
Node name: heo_01_v4904
Release: 5.10
Version: Generic_125100-07
Machine: sun4u
Instance name: orac
Redo thread mounted by this instance: 1
Oracle process number: 11
Unix process pid: 7152, image: oracle@heo_01_v4904 (TNS V1-V3)
Archivo Control File Original
*** SESSION ID:(10.3) 2007-11-10 12:13:35.698
*** 2007-11-10 12:13:35.698
# The following are current System-scope REDO Log Archival related
# parameters and can be included in the database initialization file.
#
# LOG_ARCHIVE_DEST=''
# LOG_ARCHIVE_DUPLEX_DEST=''
#
# LOG_ARCHIVE_FORMAT=orac_%s_%t.ARC
# REMOTE_ARCHIVE_ENABLE=TRUE
# LOG_ARCHIVE_START=TRUE
# LOG_ARCHIVE_MAX_PROCESSES=2
# STANDBY_FILE_MANAGEMENT=MANUAL
# STANDBY_ARCHIVE_DEST=?/dbs/arch
# FAL_CLIENT=''
# FAL_SERVER=''
#
# LOG_ARCHIVE_DEST_1='LOCATION=/users/oracle/archive/'
# LOG_ARCHIVE_DEST_1='MANDATORY NOREOPEN NODELAY'
# LOG_ARCHIVE_DEST_1='ARCH NOAFFIRM SYNC'
# LOG_ARCHIVE_DEST_1='NOREGISTER NOALTERNATE NODEPENDENCY'
# LOG_ARCHIVE_DEST_1='NOMAX_FAILURE NOQUOTA_SIZE NOQUOTA_USED'
# LOG_ARCHIVE_DEST_STATE_1=ENABLE
#
# Below are two sets of SQL statements, each of which creates a new
# control file and uses it to open the database. The first set opens
# the database with the NORESETLOGS option and should be used only if
# the current versions of all online logs are available. The second
# set opens the database with the RESETLOGS option and should be used
# if online logs are unavailable.
# The appropriate set of statements can be copied from the trace into
# a script file, edited as necessary, and executed when there is a
# need to re-create the control file.
#
# Set #1. NORESETLOGS case
#
# The following commands will create a new control file and use it
# to open the database.
# Data used by the recovery manager will be lost. Additional logs may
# be required for media recovery of offline data files. Use this
# only if the current version of all online logs are available.
STARTUP NOMOUNT
CREATE CONTROLFILE REUSE DATABASE "ORAC" NORESETLOGS ARCHIVELOG
-- SET STANDBY TO MAXIMIZE PERFORMANCE
MAXLOGFILES 16
MAXLOGMEMBERS 2
MAXDATAFILES 120
MAXINSTANCES 1
MAXLOGHISTORY 680
LOGFILE
GROUP 1 (
'/OraDatos/REDO/redoorac1.log',
'/OraIndices/REDO/redoorac3.log'
) SIZE 10M,
GROUP 2 (
'/OraDatos/REDO/redoorac2.log',
'/OraIndices/REDO/redoorac4.log'
) SIZE 10M
-- STANDBY LOGFILE
DATAFILE
'/OraDatos/SYSTEM/systemorac1.dbf',
'/OraIndices/ROLLBACK/tsr1.dat',
'/OraDatos/ROLLBACK/tsr2.dat',
'/OraDatos/TABLESPACES/tempgeneral.dbf',
'/OraDatos/TABLESPACES/uhi_real_tmp.dbf',
'/OraDatos/TABLESPACES/uhi_tab_tmp.dbf',
'/OraDatos/TABLESPACES/HIS_tb_pr.dbf',
'/OraIndices/TABLESPACES/HIS_i_pr.dbf',
'/OraDatos/TABLESPACES/HIS_tb_bkp.dbf',
'/OraIndices/TABLESPACES/HIS_i_bkp.dbf',
'/OraDatos/TABLESPACES/conmut_real_tmp.dbf',
'/OraDatos/TABLESPACES/conmut_tmp.dbf',
'/OraDatos/TABLESPACES/_NEAX61E_tb_pr.dbf',
'/OraIndices/TABLESPACES/_NEAX61E_i_pr.dbf',
'/OraDatos/TABLESPACES/_NEAX61E_tb_bkp.dbf',
'/OraIndices/TABLESPACES/_NEAX61E_i_bkp.dbf',
'/OraDatos/TABLESPACES/_AXE_tb_pr.dbf',
'/OraIndices/TABLESPACES/_AXE_i_pr.dbf',
'/OraDatos/TABLESPACES/_AXE_tb_bkp.dbf',
'/OraIndices/TABLESPACES/_AXE_i_bkp.dbf',
'/opt/oracle/product/9.2.0.8/dbs/BDCentral_idx.dbf',
'/opt/oracle/product/9.2.0.8/dbs/BDCentral_pr.dbf',
'/opt/oracle/product/9.2.0.8/dbs/BDCentral_tmp.dbf',
'/opt/oracle/product/9.2.0.8/dbs/dbgenap001.dbf',
'/opt/oracle/product/9.2.0.8/dbs/dbgenap002.dbf',
'/opt/oracle/product/9.2.0.8/dbs/dbgenap003.dbf',
'/OraDatos/TABLESPACES/_MGPP_tb_pr.dbf',
'/OraIndices/TABLESPACES/_MGPP_i_pr.dbf',
'/OraDatos/TABLESPACES/_MGPP_tb_bkp.dbf',
'/OraIndices/TABLESPACES/_MGPP_i_bkp.dbf',
'/OraDatos/TABLESPACES/_MGPP_tb_pr1.dbf',
'/OraDatos/TABLESPACES/_NEAX61E_tb_pr1.dbf',
'/OraDatos/TABLESPACES/_AXE_tb_pr1.dbf'
CHARACTER SET US7ASCII
;
# Recovery is required if any of the datafiles are restored backups,
# or if the last shutdown was not normal or immediate.
RECOVER DATABASE
# All logs need archiving and a log switch is needed.
ALTER SYSTEM ARCHIVE LOG ALL;
# Database can now be opened normally.
ALTER DATABASE OPEN;
# No tempfile entries found to add.
#
# Set #2. RESETLOGS case
#
# The following commands will create a new control file and use it
# to open the database.
# The contents of online logs will be lost and all backups will
# be invalidated. Use this only if online logs are damaged.
STARTUP NOMOUNT
CREATE CONTROLFILE REUSE DATABASE "ORAC" RESETLOGS ARCHIVELOG
-- SET STANDBY TO MAXIMIZE PERFORMANCE
MAXLOGFILES 16
MAXLOGMEMBERS 2
MAXDATAFILES 120
MAXINSTANCES 1
MAXLOGHISTORY 680
LOGFILE
GROUP 1 (
'/OraDatos/REDO/redoorac1.log',
'/OraIndices/REDO/redoorac3.log'
) SIZE 10M,
GROUP 2 (
'/OraDatos/REDO/redoorac2.log',
'/OraIndices/REDO/redoorac4.log'
) SIZE 10M
-- STANDBY LOGFILE
DATAFILE
'/OraDatos/SYSTEM/systemorac1.dbf',
'/OraIndices/ROLLBACK/tsr1.dat',
'/OraDatos/ROLLBACK/tsr2.dat',
'/OraDatos/TABLESPACES/tempgeneral.dbf',
'/OraDatos/TABLESPACES/uhi_real_tmp.dbf',
'/OraDatos/TABLESPACES/uhi_tab_tmp.dbf',
'/OraDatos/TABLESPACES/HIS_tb_pr.dbf',
'/OraIndices/TABLESPACES/HIS_i_pr.dbf',
'/OraDatos/TABLESPACES/HIS_tb_bkp.dbf',
'/OraIndices/TABLESPACES/HIS_i_bkp.dbf',
'/OraDatos/TABLESPACES/conmut_real_tmp.dbf',
'/OraDatos/TABLESPACES/conmut_tmp.dbf',
'/OraDatos/TABLESPACES/_NEAX61E_tb_pr.dbf',
'/OraIndices/TABLESPACES/_NEAX61E_i_pr.dbf',
'/OraDatos/TABLESPACES/_NEAX61E_tb_bkp.dbf',
'/OraIndices/TABLESPACES/_NEAX61E_i_bkp.dbf',
'/OraDatos/TABLESPACES/_AXE_tb_pr.dbf',
'/OraIndices/TABLESPACES/_AXE_i_pr.dbf',
'/OraDatos/TABLESPACES/_AXE_tb_bkp.dbf',
'/OraIndices/TABLESPACES/_AXE_i_bkp.dbf',
'/opt/oracle/product/9.2.0.8/dbs/BDCentral_idx.dbf',
'/opt/oracle/product/9.2.0.8/dbs/BDCentral_pr.dbf',
'/opt/oracle/product/9.2.0.8/dbs/BDCentral_tmp.dbf',
'/opt/oracle/product/9.2.0.8/dbs/dbgenap001.dbf',
'/opt/oracle/product/9.2.0.8/dbs/dbgenap002.dbf',
'/opt/oracle/product/9.2.0.8/dbs/dbgenap003.dbf',
'/OraDatos/TABLESPACES/_MGPP_tb_pr.dbf',
'/OraIndices/TABLESPACES/_MGPP_i_pr.dbf',
'/OraDatos/TABLESPACES/_MGPP_tb_bkp.dbf',
'/OraIndices/TABLESPACES/_MGPP_i_bkp.dbf',
'/OraDatos/TABLESPACES/_MGPP_tb_pr1.dbf',
'/OraDatos/TABLESPACES/_NEAX61E_tb_pr1.dbf',
'/OraDatos/TABLESPACES/_AXE_tb_pr1.dbf'
CHARACTER SET US7ASCII
;
# Recovery is required if any of the datafiles are restored backups,
# or if the last shutdown was not normal or immediate.
RECOVER DATABASE USING BACKUP CONTROLFILE
# Database can now be opened zeroing the online logs.
ALTER DATABASE OPEN RESETLOGS;
# No tempfile entries found to add.
#
Se edita y se peluquea el archivo y se deja como en los Nuevos Path de Almacenamiento
bash-3.00# more control.sh
STARTUP NOMOUNT
CREATE CONTROLFILE SET DATABASE "oracrest" RESETLOGS NOARCHIVELOG
-- SET STANDBY TO MAXIMIZE PERFORMANCE
MAXLOGFILES 16
MAXLOGMEMBERS 2
MAXDATAFILES 120
MAXINSTANCES 1
MAXLOGHISTORY 680
LOGFILE
GROUP 1 (
'/storage/restore/oracle/redoorac1.log',
'/storage/restore/oracle/redoorac3.log'
) SIZE 10M,
GROUP 2 (
'/storage/restore/oracle/redoorac2.log',
'/storage/restore/oracle/redoorac4.log'
) SIZE 10M
-- STANDBY LOGFILE
DATAFILE
'/storage/restore/oracle/datos/2systemorac1.dbf',
'/storage/restore/oracle/datos/2tsr1.dat',
'/storage/restore/oracle/datos/2tsr2.dat',
'/storage/restore/oracle/datos/2tempgeneral.dbf',
'/storage/restore/oracle/datos/2uhi_real_tmp.dbf',
'/storage/restore/oracle/datos/2uhi_tab_tmp.dbf',
'/storage/restore/oracle/datos/2HIS_tb_pr.dbf',
'/storage/restore/oracle/datos/2HIS_i_pr.dbf',
'/storage/restore/oracle/datos/2HIS_tb_bkp.dbf',
'/storage/restore/oracle/datos/2HIS_i_bkp.dbf',
'/storage/restore/oracle/datos/2conmut_real_tmp.dbf',
'/storage/restore/oracle/datos/2conmut_tmp.dbf',
'/storage/restore/oracle/datos/2_NEAX61E_tb_pr.dbf',
'/storage/restore/oracle/datos/2_NEAX61E_i_pr.dbf',
'/storage/restore/oracle/datos/2_NEAX61E_tb_bkp.dbf',
'/storage/restore/oracle/datos/2_NEAX61E_i_bkp.dbf',
'/storage/restore/oracle/datos/2_AXE_tb_pr.dbf',
'/storage/restore/oracle/datos/2_AXE_i_pr.dbf',
'/storage/restore/oracle/datos/2_AXE_tb_bkp.dbf',
'/storage/restore/oracle/datos/2_AXE_i_bkp.dbf',
'/storage/restore/oracle/datos/2BDCentral_idx.dbf',
'/storage/restore/oracle/datos/2BDCentral_pr.dbf',
'/storage/restore/oracle/datos/2BDCentral_tmp.dbf',
'/storage/restore/oracle/datos/2dbgenap001.dbf',
'/storage/restore/oracle/datos/2dbgenap002.dbf',
'/storage/restore/oracle/datos/2dbgenap003.dbf',
'/storage/restore/oracle/datos/2_MGPP_tb_pr.dbf',
'/storage/restore/oracle/datos/2_MGPP_i_pr.dbf',
'/storage/restore/oracle/datos/2_MGPP_tb_bkp.dbf',
'/storage/restore/oracle/datos/2_MGPP_i_bkp.dbf',
'/storage/restore/oracle/datos/2_MGPP_tb_pr1.dbf',
'/storage/restore/oracle/datos/2_NEAX61E_tb_pr1.dbf',
'/storage/restore/oracle/datos/2_AXE_tb_pr1.dbf'
CHARACTER SET US7ASCII ;
SQL>@control.sh
SQL>select open_mode from v$database;
SQL>alter database open resetlogs;
# Recuperar la base de datos, mediante los archives.
SQL>recover database using backup control file until cancel;
En este paso hay que recuperar con otro shell los archives que esta pidiendo en este punto.
oracle@heo_01_v4904-V4im:/rman/oracrest/restore/archives#pwd
/opt/oracle/rman/oracrest/restore/archives
oracle@heo_01_v4904-V4im:/rman/oracrest/restore/archives#ls
archives.sh
oracle@heo_01_v4904-V4im:/rman/oracrest/restore/archives#
oracle@heo_01_v4904-V4im:/rman/oracrest/restore/archives#more archives.sh
connect catalog rman/rman@cat9i;
set dbid=887613172;
connect target;
run {
ALLOCATE CHANNEL ch00
TYPE 'SBT_TAPE' parms 'ENV=(NB_ORA_CLIENT=heo_01_v4904,NB_ORA_POLICY=BD_Online_orac_heo_01_v4904,NB_ORA_SERV=bksrv01,NB_ORA_SCHED=Default-Application-Bac
kup)';
restore archivelog from logseq=2917 until logseq=2925;
RELEASE CHANNEL ch00;
}
Esperar hasta que aplique todos los archives.
Se da un enter en la pantalla anterior(primera pantalla), se le da enter hasta que llegue al ultimo, y en ese punto se le da cancel.
SQL>alter database open resetlogs;
SQL>shutdown immediate;
SQL>startup mount;
SQL>alter database archivelog;
para eso vamos donde estan los archivos de inicializacion de las bases de datos de oracle.
cd $HOME/dbs
cp initorac.ora initoracrest.init
y modificamos el archivo “initoracrest.init”.
Cambiamos los paramentros donde diga “orac” por “oracrest” y cambiamos los path de:
1 archive
2 control
3 dump
Todos a la nueva ruta como se muestra:
log_archive_dest=/storage/restore/oracle/archive/
control_files=/storage/restore/oracle/control/cntrlorac.dbf,/storage/restore/oracle/control/contr2orac.dbf
rollback_segments = ROLL1,ROLL2,ROLL3,ROLL4,ROLL5,ROLL6,ROLL7,ROLL8,ROLL9,ROLL10,ROLL11,ROLL12,ROLL13,ROLL14,ROLL15,ROLL16,ROLL17,ROLL18,ROLL19,ROLL20,ROLL21
,ROLL22,ROLL23,ROLL24,ROLL25,ROLL26,ROLL27
core_dump_dest = /storage/restore/oracle/cdump
crear los anteriores directorios
ahora fijamos el ORACLE_SID=oracrest
export ORACLE_SID=oracrest
ahora nos conectamos como sysdba.
sqlplus '/as sysdba'
SQL>startup nomount;
y verificamos que tengamos la nueva instancia:
#ps -fea | grep pmon
Debe estar la “oracrest”
Ahora vamos a construir el script de recuperacion del control file:
/opt/oracle/rman/oracrest/
mdkir oracrest
cd oracrest
mkdir -p restore/control
cd restore/control
vi control.sh
y adicionamos
RECUPERAR ARCHIVO DE CONTROL
connect catalog rman/rman@cat9i;
set dbid=887613172;
connect target;
run {
ALLOCATE CHANNEL ch00
TYPE 'SBT_TAPE' parms 'ENV=(NB_ORA_CLIENT=heo_01_v4904,NB_ORA_POLICY=BD_Online_orac_heo_01_v4904,NB_ORA_SERV=bksrv01,NB_ORA_SCHED=Default-Application-Backup)';
restore controlfile;
RELEASE CHANNEL ch00;
}
Verificar que el restore fue exitoso.
oracle@heo_01_v4904-V4im:/storage/restore/oracle/control#ls
cntrlorac.dbf contr2orac.dbf
Ahora hacer el scrips de recuperar los datos:
oracle@heo_01_v4904-V4im:/rman/oracrest/restore/database#cat database.sh
connect catalog rman/rman@cat9i;
set dbid=887613172;
connect target;
run {
ALLOCATE CHANNEL ch00
TYPE 'SBT_TAPE' parms 'ENV=(NB_ORA_CLIENT=heo_01_v4904,NB_ORA_POLICY=BD_Online_orac_heo_01_v4904,NB_ORA_SERV=bksrv01,NB_ORA_SCHED=Default-Application-Backup)';
ALLOCATE CHANNEL ch01
TYPE 'SBT_TAPE' parms 'ENV=(NB_ORA_CLIENT=heo_01_v4904,NB_ORA_POLICY=BD_Online_orac_heo_01_v4904,NB_ORA_SERV=bksrv01,NB_ORA_SCHED=Default-Application-Backup)';
ALLOCATE CHANNEL ch02
TYPE 'SBT_TAPE' parms 'ENV=(NB_ORA_CLIENT=heo_01_v4904,NB_ORA_POLICY=BD_Online_orac_heo_01_v4904,NB_ORA_SERV=bksrv01,NB_ORA_SCHED=Default-Application-Backup)';
ALLOCATE CHANNEL ch03
TYPE 'SBT_TAPE' parms 'ENV=(NB_ORA_CLIENT=heo_01_v4904,NB_ORA_POLICY=BD_Online_orac_heo_01_v4904,NB_ORA_SERV=bksrv01,NB_ORA_SCHED=Default-Application-Backup)';
set newname for datafile 1 to '/storage/restore/oracle/datos/2systemorac1.dbf';
set newname for datafile 2 to '/storage/restore/oracle/datos/2tsr1.dat';
set newname for datafile 3 to '/storage/restore/oracle/datos/2tsr2.dat';
set newname for datafile 4 to '/storage/restore/oracle/datos/2tempgeneral.dbf';
set newname for datafile 5 to '/storage/restore/oracle/datos/2uhi_real_tmp.dbf';
set newname for datafile 6 to '/storage/restore/oracle/datos/2uhi_tab_tmp.dbf';
set newname for datafile 7 to '/storage/restore/oracle/datos/2HIS_tb_pr.dbf';
set newname for datafile 8 to '/storage/restore/oracle/datos/2HIS_i_pr.dbf';
set newname for datafile 9 to '/storage/restore/oracle/datos/2HIS_tb_bkp.dbf';
set newname for datafile 10 to '/storage/restore/oracle/datos/2HIS_i_bkp.dbf';
set newname for datafile 11 to '/storage/restore/oracle/datos/2conmut_real_tmp.dbf';
set newname for datafile 12 to '/storage/restore/oracle/datos/2conmut_tmp.dbf';
set newname for datafile 13 to '/storage/restore/oracle/datos/2_NEAX61E_tb_pr.dbf';
set newname for datafile 14 to '/storage/restore/oracle/datos/2_NEAX61E_i_pr.dbf';
set newname for datafile 15 to '/storage/restore/oracle/datos/2_NEAX61E_tb_bkp.dbf';
set newname for datafile 16 to '/storage/restore/oracle/datos/2_NEAX61E_i_bkp.dbf';
set newname for datafile 17 to '/storage/restore/oracle/datos/2_AXE_tb_pr.dbf';
set newname for datafile 18 to '/storage/restore/oracle/datos/2_AXE_i_pr.dbf';
set newname for datafile 19 to '/storage/restore/oracle/datos/2_AXE_tb_bkp.dbf';
set newname for datafile 20 to '/storage/restore/oracle/datos/2_AXE_i_bkp.dbf';
set newname for datafile 21 to '/storage/restore/oracle/datos/2BDCentral_idx.dbf';
set newname for datafile 22 to '/storage/restore/oracle/datos/2BDCentral_pr.dbf';
set newname for datafile 23 to '/storage/restore/oracle/datos/2BDCentral_tmp.dbf';
set newname for datafile 24 to '/storage/restore/oracle/datos/2dbgenap001.dbf';
set newname for datafile 25 to '/storage/restore/oracle/datos/2dbgenap002.dbf';
set newname for datafile 26 to '/storage/restore/oracle/datos/2dbgenap003.dbf';
set newname for datafile 27 to '/storage/restore/oracle/datos/2_MGPP_tb_pr.dbf';
set newname for datafile 28 to '/storage/restore/oracle/datos/2_MGPP_i_pr.dbf';
set newname for datafile 29 to '/storage/restore/oracle/datos/2_MGPP_tb_bkp.dbf';
set newname for datafile 30 to '/storage/restore/oracle/datos/2_MGPP_i_bkp.dbf';
set newname for datafile 31 to '/storage/restore/oracle/datos/2_MGPP_tb_pr1.dbf';
set newname for datafile 32 to '/storage/restore/oracle/datos/2_NEAX61E_tb_pr1.dbf';
set newname for datafile 33 to '/storage/restore/oracle/datos/2_AXE_tb_pr1.dbf';
restore database;
RELEASE CHANNEL ch00;
RELEASE CHANNEL ch01;
RELEASE CHANNEL ch02;
RELEASE CHANNEL ch03;
}
rman cmdfile=database.sh
verificar que el restore fue exitoso.
Nos conectamos a la base de datos para iniciar el proceso de subirla.
Como se esta restaurando sobre la misma maquina se requiere recrear el control file:
Recrear Archivo de Control.
SQL>alter database mount;
SQL>alter database backup controlfile to trace;
SQL>show parameters dump;
SQL>exit
Vamos a la ruta mostrada para los udump.
cd /opt/oracle/product/9.2.0.8/rdbms/log
ls -ltr
se edita y se cambian las rutas, tambien se cambian
cp orac_ora_7152.trc control
oracle@heo_01_v4904-V4im:/product/9.2.0.8/rdbms/log#cat orac_ora_7152.trc
Dump file /opt/oracle/product/9.2.0.8/rdbms/log/orac_ora_7152.trc
Oracle9i Enterprise Edition Release 9.2.0.8.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.8.0 - Production
ORACLE_HOME = /opt/oracle/product/9.2.0.8
System name: SunOS
Node name: heo_01_v4904
Release: 5.10
Version: Generic_125100-07
Machine: sun4u
Instance name: orac
Redo thread mounted by this instance: 1
Oracle process number: 11
Unix process pid: 7152, image: oracle@heo_01_v4904 (TNS V1-V3)
Archivo Control File Original
*** SESSION ID:(10.3) 2007-11-10 12:13:35.698
*** 2007-11-10 12:13:35.698
# The following are current System-scope REDO Log Archival related
# parameters and can be included in the database initialization file.
#
# LOG_ARCHIVE_DEST=''
# LOG_ARCHIVE_DUPLEX_DEST=''
#
# LOG_ARCHIVE_FORMAT=orac_%s_%t.ARC
# REMOTE_ARCHIVE_ENABLE=TRUE
# LOG_ARCHIVE_START=TRUE
# LOG_ARCHIVE_MAX_PROCESSES=2
# STANDBY_FILE_MANAGEMENT=MANUAL
# STANDBY_ARCHIVE_DEST=?/dbs/arch
# FAL_CLIENT=''
# FAL_SERVER=''
#
# LOG_ARCHIVE_DEST_1='LOCATION=/users/oracle/archive/'
# LOG_ARCHIVE_DEST_1='MANDATORY NOREOPEN NODELAY'
# LOG_ARCHIVE_DEST_1='ARCH NOAFFIRM SYNC'
# LOG_ARCHIVE_DEST_1='NOREGISTER NOALTERNATE NODEPENDENCY'
# LOG_ARCHIVE_DEST_1='NOMAX_FAILURE NOQUOTA_SIZE NOQUOTA_USED'
# LOG_ARCHIVE_DEST_STATE_1=ENABLE
#
# Below are two sets of SQL statements, each of which creates a new
# control file and uses it to open the database. The first set opens
# the database with the NORESETLOGS option and should be used only if
# the current versions of all online logs are available. The second
# set opens the database with the RESETLOGS option and should be used
# if online logs are unavailable.
# The appropriate set of statements can be copied from the trace into
# a script file, edited as necessary, and executed when there is a
# need to re-create the control file.
#
# Set #1. NORESETLOGS case
#
# The following commands will create a new control file and use it
# to open the database.
# Data used by the recovery manager will be lost. Additional logs may
# be required for media recovery of offline data files. Use this
# only if the current version of all online logs are available.
STARTUP NOMOUNT
CREATE CONTROLFILE REUSE DATABASE "ORAC" NORESETLOGS ARCHIVELOG
-- SET STANDBY TO MAXIMIZE PERFORMANCE
MAXLOGFILES 16
MAXLOGMEMBERS 2
MAXDATAFILES 120
MAXINSTANCES 1
MAXLOGHISTORY 680
LOGFILE
GROUP 1 (
'/OraDatos/REDO/redoorac1.log',
'/OraIndices/REDO/redoorac3.log'
) SIZE 10M,
GROUP 2 (
'/OraDatos/REDO/redoorac2.log',
'/OraIndices/REDO/redoorac4.log'
) SIZE 10M
-- STANDBY LOGFILE
DATAFILE
'/OraDatos/SYSTEM/systemorac1.dbf',
'/OraIndices/ROLLBACK/tsr1.dat',
'/OraDatos/ROLLBACK/tsr2.dat',
'/OraDatos/TABLESPACES/tempgeneral.dbf',
'/OraDatos/TABLESPACES/uhi_real_tmp.dbf',
'/OraDatos/TABLESPACES/uhi_tab_tmp.dbf',
'/OraDatos/TABLESPACES/HIS_tb_pr.dbf',
'/OraIndices/TABLESPACES/HIS_i_pr.dbf',
'/OraDatos/TABLESPACES/HIS_tb_bkp.dbf',
'/OraIndices/TABLESPACES/HIS_i_bkp.dbf',
'/OraDatos/TABLESPACES/conmut_real_tmp.dbf',
'/OraDatos/TABLESPACES/conmut_tmp.dbf',
'/OraDatos/TABLESPACES/_NEAX61E_tb_pr.dbf',
'/OraIndices/TABLESPACES/_NEAX61E_i_pr.dbf',
'/OraDatos/TABLESPACES/_NEAX61E_tb_bkp.dbf',
'/OraIndices/TABLESPACES/_NEAX61E_i_bkp.dbf',
'/OraDatos/TABLESPACES/_AXE_tb_pr.dbf',
'/OraIndices/TABLESPACES/_AXE_i_pr.dbf',
'/OraDatos/TABLESPACES/_AXE_tb_bkp.dbf',
'/OraIndices/TABLESPACES/_AXE_i_bkp.dbf',
'/opt/oracle/product/9.2.0.8/dbs/BDCentral_idx.dbf',
'/opt/oracle/product/9.2.0.8/dbs/BDCentral_pr.dbf',
'/opt/oracle/product/9.2.0.8/dbs/BDCentral_tmp.dbf',
'/opt/oracle/product/9.2.0.8/dbs/dbgenap001.dbf',
'/opt/oracle/product/9.2.0.8/dbs/dbgenap002.dbf',
'/opt/oracle/product/9.2.0.8/dbs/dbgenap003.dbf',
'/OraDatos/TABLESPACES/_MGPP_tb_pr.dbf',
'/OraIndices/TABLESPACES/_MGPP_i_pr.dbf',
'/OraDatos/TABLESPACES/_MGPP_tb_bkp.dbf',
'/OraIndices/TABLESPACES/_MGPP_i_bkp.dbf',
'/OraDatos/TABLESPACES/_MGPP_tb_pr1.dbf',
'/OraDatos/TABLESPACES/_NEAX61E_tb_pr1.dbf',
'/OraDatos/TABLESPACES/_AXE_tb_pr1.dbf'
CHARACTER SET US7ASCII
;
# Recovery is required if any of the datafiles are restored backups,
# or if the last shutdown was not normal or immediate.
RECOVER DATABASE
# All logs need archiving and a log switch is needed.
ALTER SYSTEM ARCHIVE LOG ALL;
# Database can now be opened normally.
ALTER DATABASE OPEN;
# No tempfile entries found to add.
#
# Set #2. RESETLOGS case
#
# The following commands will create a new control file and use it
# to open the database.
# The contents of online logs will be lost and all backups will
# be invalidated. Use this only if online logs are damaged.
STARTUP NOMOUNT
CREATE CONTROLFILE REUSE DATABASE "ORAC" RESETLOGS ARCHIVELOG
-- SET STANDBY TO MAXIMIZE PERFORMANCE
MAXLOGFILES 16
MAXLOGMEMBERS 2
MAXDATAFILES 120
MAXINSTANCES 1
MAXLOGHISTORY 680
LOGFILE
GROUP 1 (
'/OraDatos/REDO/redoorac1.log',
'/OraIndices/REDO/redoorac3.log'
) SIZE 10M,
GROUP 2 (
'/OraDatos/REDO/redoorac2.log',
'/OraIndices/REDO/redoorac4.log'
) SIZE 10M
-- STANDBY LOGFILE
DATAFILE
'/OraDatos/SYSTEM/systemorac1.dbf',
'/OraIndices/ROLLBACK/tsr1.dat',
'/OraDatos/ROLLBACK/tsr2.dat',
'/OraDatos/TABLESPACES/tempgeneral.dbf',
'/OraDatos/TABLESPACES/uhi_real_tmp.dbf',
'/OraDatos/TABLESPACES/uhi_tab_tmp.dbf',
'/OraDatos/TABLESPACES/HIS_tb_pr.dbf',
'/OraIndices/TABLESPACES/HIS_i_pr.dbf',
'/OraDatos/TABLESPACES/HIS_tb_bkp.dbf',
'/OraIndices/TABLESPACES/HIS_i_bkp.dbf',
'/OraDatos/TABLESPACES/conmut_real_tmp.dbf',
'/OraDatos/TABLESPACES/conmut_tmp.dbf',
'/OraDatos/TABLESPACES/_NEAX61E_tb_pr.dbf',
'/OraIndices/TABLESPACES/_NEAX61E_i_pr.dbf',
'/OraDatos/TABLESPACES/_NEAX61E_tb_bkp.dbf',
'/OraIndices/TABLESPACES/_NEAX61E_i_bkp.dbf',
'/OraDatos/TABLESPACES/_AXE_tb_pr.dbf',
'/OraIndices/TABLESPACES/_AXE_i_pr.dbf',
'/OraDatos/TABLESPACES/_AXE_tb_bkp.dbf',
'/OraIndices/TABLESPACES/_AXE_i_bkp.dbf',
'/opt/oracle/product/9.2.0.8/dbs/BDCentral_idx.dbf',
'/opt/oracle/product/9.2.0.8/dbs/BDCentral_pr.dbf',
'/opt/oracle/product/9.2.0.8/dbs/BDCentral_tmp.dbf',
'/opt/oracle/product/9.2.0.8/dbs/dbgenap001.dbf',
'/opt/oracle/product/9.2.0.8/dbs/dbgenap002.dbf',
'/opt/oracle/product/9.2.0.8/dbs/dbgenap003.dbf',
'/OraDatos/TABLESPACES/_MGPP_tb_pr.dbf',
'/OraIndices/TABLESPACES/_MGPP_i_pr.dbf',
'/OraDatos/TABLESPACES/_MGPP_tb_bkp.dbf',
'/OraIndices/TABLESPACES/_MGPP_i_bkp.dbf',
'/OraDatos/TABLESPACES/_MGPP_tb_pr1.dbf',
'/OraDatos/TABLESPACES/_NEAX61E_tb_pr1.dbf',
'/OraDatos/TABLESPACES/_AXE_tb_pr1.dbf'
CHARACTER SET US7ASCII
;
# Recovery is required if any of the datafiles are restored backups,
# or if the last shutdown was not normal or immediate.
RECOVER DATABASE USING BACKUP CONTROLFILE
# Database can now be opened zeroing the online logs.
ALTER DATABASE OPEN RESETLOGS;
# No tempfile entries found to add.
#
Se edita y se peluquea el archivo y se deja como en los Nuevos Path de Almacenamiento
bash-3.00# more control.sh
STARTUP NOMOUNT
CREATE CONTROLFILE SET DATABASE "oracrest" RESETLOGS NOARCHIVELOG
-- SET STANDBY TO MAXIMIZE PERFORMANCE
MAXLOGFILES 16
MAXLOGMEMBERS 2
MAXDATAFILES 120
MAXINSTANCES 1
MAXLOGHISTORY 680
LOGFILE
GROUP 1 (
'/storage/restore/oracle/redoorac1.log',
'/storage/restore/oracle/redoorac3.log'
) SIZE 10M,
GROUP 2 (
'/storage/restore/oracle/redoorac2.log',
'/storage/restore/oracle/redoorac4.log'
) SIZE 10M
-- STANDBY LOGFILE
DATAFILE
'/storage/restore/oracle/datos/2systemorac1.dbf',
'/storage/restore/oracle/datos/2tsr1.dat',
'/storage/restore/oracle/datos/2tsr2.dat',
'/storage/restore/oracle/datos/2tempgeneral.dbf',
'/storage/restore/oracle/datos/2uhi_real_tmp.dbf',
'/storage/restore/oracle/datos/2uhi_tab_tmp.dbf',
'/storage/restore/oracle/datos/2HIS_tb_pr.dbf',
'/storage/restore/oracle/datos/2HIS_i_pr.dbf',
'/storage/restore/oracle/datos/2HIS_tb_bkp.dbf',
'/storage/restore/oracle/datos/2HIS_i_bkp.dbf',
'/storage/restore/oracle/datos/2conmut_real_tmp.dbf',
'/storage/restore/oracle/datos/2conmut_tmp.dbf',
'/storage/restore/oracle/datos/2_NEAX61E_tb_pr.dbf',
'/storage/restore/oracle/datos/2_NEAX61E_i_pr.dbf',
'/storage/restore/oracle/datos/2_NEAX61E_tb_bkp.dbf',
'/storage/restore/oracle/datos/2_NEAX61E_i_bkp.dbf',
'/storage/restore/oracle/datos/2_AXE_tb_pr.dbf',
'/storage/restore/oracle/datos/2_AXE_i_pr.dbf',
'/storage/restore/oracle/datos/2_AXE_tb_bkp.dbf',
'/storage/restore/oracle/datos/2_AXE_i_bkp.dbf',
'/storage/restore/oracle/datos/2BDCentral_idx.dbf',
'/storage/restore/oracle/datos/2BDCentral_pr.dbf',
'/storage/restore/oracle/datos/2BDCentral_tmp.dbf',
'/storage/restore/oracle/datos/2dbgenap001.dbf',
'/storage/restore/oracle/datos/2dbgenap002.dbf',
'/storage/restore/oracle/datos/2dbgenap003.dbf',
'/storage/restore/oracle/datos/2_MGPP_tb_pr.dbf',
'/storage/restore/oracle/datos/2_MGPP_i_pr.dbf',
'/storage/restore/oracle/datos/2_MGPP_tb_bkp.dbf',
'/storage/restore/oracle/datos/2_MGPP_i_bkp.dbf',
'/storage/restore/oracle/datos/2_MGPP_tb_pr1.dbf',
'/storage/restore/oracle/datos/2_NEAX61E_tb_pr1.dbf',
'/storage/restore/oracle/datos/2_AXE_tb_pr1.dbf'
CHARACTER SET US7ASCII ;
SQL>@control.sh
SQL>select open_mode from v$database;
SQL>alter database open resetlogs;
# Recuperar la base de datos, mediante los archives.
SQL>recover database using backup control file until cancel;
En este paso hay que recuperar con otro shell los archives que esta pidiendo en este punto.
oracle@heo_01_v4904-V4im:/rman/oracrest/restore/archives#pwd
/opt/oracle/rman/oracrest/restore/archives
oracle@heo_01_v4904-V4im:/rman/oracrest/restore/archives#ls
archives.sh
oracle@heo_01_v4904-V4im:/rman/oracrest/restore/archives#
oracle@heo_01_v4904-V4im:/rman/oracrest/restore/archives#more archives.sh
connect catalog rman/rman@cat9i;
set dbid=887613172;
connect target;
run {
ALLOCATE CHANNEL ch00
TYPE 'SBT_TAPE' parms 'ENV=(NB_ORA_CLIENT=heo_01_v4904,NB_ORA_POLICY=BD_Online_orac_heo_01_v4904,NB_ORA_SERV=bksrv01,NB_ORA_SCHED=Default-Application-Bac
kup)';
restore archivelog from logseq=2917 until logseq=2925;
RELEASE CHANNEL ch00;
}
Esperar hasta que aplique todos los archives.
Se da un enter en la pantalla anterior(primera pantalla), se le da enter hasta que llegue al ultimo, y en ese punto se le da cancel.
SQL>alter database open resetlogs;
SQL>shutdown immediate;
SQL>startup mount;
SQL>alter database archivelog;
lunes, 5 de octubre de 2009
Unix Comandos Examples SED
Ejemplo SED cuando se tiene formato fecha
sed s/'24\/Jun'/'23\/Sep'/g hola.txt > prueba
sed s/'24\/Jun'/'23\/Sep'/g hola.txt > prueba
sed
s/’#PermitRoot’/’PermitRoot’/g sshd_config > sshd_test
viernes, 2 de octubre de 2009
Oracle DataGuard
INIT POWER
POWER.__db_cache_size=1207959552
POWER.__java_pool_size=16777216
POWER.__large_pool_size=16777216
POWER.__shared_pool_size=352321536
POWER.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/POWER/adump'
*.background_dump_dest='/u01/app/oracle/admin/POWER/bdump'
*.compatible='10.2.0.3.0'
*.control_files='/u01/app/oracle/oradata/POWER/control01.ctl','/u01/app/oracle/oradata/POWER/control02.ctl','/u01/app/oracle/oradata/POWER/control03.ctl'
*.core_dump_dest='/u01/app/oracle/admin/POWER/cdump'
*.db_block_size=8192
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='POWER'
*.db_recovery_file_dest_size=2147483648
*.db_recovery_file_dest='/u01/app/oracle/POWER/flash_recovery_area'
*.DB_UNIQUE_NAME='POWER'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=POWERXDB)'
*.FAL_CLIENT='POWER'
*.FAL_SERVER='AUXPOWER'
*.job_queue_processes=10
*.log_archive_config='dg_config=(POWER,AUXPOWER)'
*.LOG_ARCHIVE_DEST_1='LOCATION=/u01/app/oracle/POWER/flash_recovery_area'
*.log_archive_dest_2='service=AUXPOWER async valid_for=(online_logfile,primary_role) db_unique_name=AUXPOWER'
*.LOG_ARCHIVE_DEST_STATE_1='ENABLE'
*.LOG_ARCHIVE_DEST_STATE_2='ENABLE'
*.LOG_ARCHIVE_FORMAT='%t_%s_%r.arc'
*.LOG_ARCHIVE_MAX_PROCESSES=30
*.nls_language='LATIN AMERICAN SPANISH'
*.nls_territory='COLOMBIA'
*.open_cursors=300
*.pga_aggregate_target=848297984
*.processes=200
*.remote_login_passwordfile='EXCLUSIVE'
*.sessions=225
*.sga_target=1610612736
*.STANDBY_FILE_MANAGEMENT='AUTO'
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/u01/app/oracle/admin/POWER/udump'
INIT AUXPOWER
*.audit_file_dest='/u01/app/oracle/admin/AUXPOWER/adump'
*.background_dump_dest='/u01/app/oracle/admin/AUXPOWER/bdump'
*.compatible='10.2.0.3.0'
*.core_dump_dest='/u01/app/oracle/admin/AUXPOWER/cdump'
*.control_files='/u01/app/oracle/oradata/AUXPOWER/control01.ctl','/u01/app/oracle/oradata/AUXPOWER/control02.ctl','/u01/app/oracle/oradata/AUXPOWER/control03.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='POWER'
*.db_recovery_file_dest_size=2147483648
*.db_recovery_file_dest='/u01/app/oracle/AUXPOWER/flash_recovery_area'
*.DB_UNIQUE_NAME='AUXPOWER'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=AUXPOWERXDB)'
*.job_queue_processes=10
*.log_archive_config='dg_config=(POWER,AUXPOWER)'
*.LOG_ARCHIVE_DEST_1='LOCATION=/u01/app/oracle/AUXPOWER/flash_recovery_area'
*.log_archive_dest_2='service=POWER async valid_for=(online_logfile,primary_role) db_unique_name=POWER'
*.LOG_ARCHIVE_DEST_STATE_1='ENABLE'
*.LOG_ARCHIVE_DEST_STATE_2='ENABLE'
*.LOG_ARCHIVE_FORMAT='%t_%s_%r.arc'
*.LOG_ARCHIVE_MAX_PROCESSES=30
*.nls_language='LATIN AMERICAN SPANISH'
*.nls_territory='COLOMBIA'
*.open_cursors=300
*.pga_aggregate_target=848297984
*.processes=200
*.remote_login_passwordfile='EXCLUSIVE'
*.sessions=225
*.sga_target=700612736
*.STANDBY_FILE_MANAGEMENT='AUTO'
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/u01/app/oracle/admin/AUXPOWER/udump'
*.FAL_SERVER=POWER
*.FAL_CLIENT=AUXPOWER
*.db_file_name_convert=('/u01/app/oracle/oradata/POWER','/u01/app/oracle/oradata/AUXPOWER')
*.log_file_name_convert=('/u01/app/oracle/oradata/POWER','/u01/app/oracle/oradata/AUXPOWER')
SQL> alter system set log_archive_config='dg_config=(POWER,AUXPOWER)';
SQL> alter system set log_archive_dest_2='service=AUXPOWER async valid_for=(online_logfile,primary_role) db_unique_name=AUXPOWER';
-bash-3.00$ rman target sys/sys@power auxiliary /
INSTANCIA PRIMARIA
startup mount pfile=initPOWER.ora
ORACLE instance started.
Total System Global Area 1610612736 bytes
Fixed Size 2139256 bytes
Variable Size 396188552 bytes
Database Buffers 1207959552 bytes
Redo Buffers 4325376 bytes
Database mounted.
SQL> alter database add standby logfile
('/u01/app/oracle/oradata/POWER/srl01.log',
'/u01/app/oracle/oradata/POWER/srl02.log',
'/u01/app/oracle/oradata/POWER/srl03.log')
size 52428800
/
SQL> ALTER DATABASE CREATE STANDBY CONTROLFILE AS '/u01/app/oracle/oradata/AUXPOWER/auxpowerstby.ctl';
SELECT * FROM V$STANDBY_LOG;
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 1610612736 bytes
Fixed Size 2139256 bytes
Variable Size 396188552 bytes
Database Buffers 1207959552 bytes
Redo Buffers 4325376 bytes
Database mounted.
SQL> alter database archivelog;
Database altered.
SQL> alter database flashback on;
Database altered.
SQL> alter database open;
Database altered.
NOMOUNT
$ export ORACLE_SID=AUXPOWER
SQL> startup nomount pfile=initAUXPOWER.ora
ORACLE instance started.
Total System Global Area 700448768 bytes
Fixed Size 2141504 bytes
Variable Size 186471104 bytes
Database Buffers 507510784 bytes
Redo Buffers 4325376 bytes
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
-bash-3.00$ rman target sys/sys@power auxiliary /
Recovery Manager: Release 10.2.0.4.0 - Production on Tue Sep 30 18:02:57 2008
Copyright (c) 1982, 2007, Oracle. All rights reserved.
connected to target database: POWER (DBID=1586828541)
connected to auxiliary database: POWER (not mounted)
RMAN> duplicate target database for standby nofilenamecheck dorecover;
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE;
SQL> alter database recover managed standby database cancel;
SQL> alter database open;
SQL> create spfile from pfile;
EJEMPLO DE SALIDA DE STANDBY DATABASE
-bash-3.00$ rman target sys/sys@power auxiliary /
Recovery Manager: Release 10.2.0.4.0 - Production on Wed Oct 1 15:57:13 2008
Copyright (c) 1982, 2007, Oracle. All rights reserved.
connected to target database: POWER (DBID=1586828541)
connected to auxiliary database: POWER (not mounted)
RMAN> duplicate target database for standby nofilenamecheck dorecover;
Starting Duplicate Db at 01-OCT-08
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=104 devtype=DISK
contents of Memory Script:
{
set until scn 3950745;
restore clone standby controlfile;
sql clone 'alter database mount standby database';
}
executing Memory Script
executing command: SET until clause
Starting restore at 01-OCT-08
using channel ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: copied control file copy
input filename=/u01/app/oracle/oradata/POWER/auxpower.ctl
output filename=/u01/app/oracle/oradata/AUXPOWER/control01.ctl
output filename=/u01/app/oracle/oradata/AUXPOWER/control02.ctl
output filename=/u01/app/oracle/oradata/AUXPOWER/control03.ctl
Finished restore at 01-OCT-08
sql statement: alter database mount standby database
released channel: ORA_AUX_DISK_1
contents of Memory Script:
{
set until scn 3950745;
set newname for tempfile 1 to
"/u01/app/oracle/oradata/AUXPOWER/temp01.dbf";
switch clone tempfile all;
set newname for datafile 1 to
"/u01/app/oracle/oradata/AUXPOWER/system01.dbf";
set newname for datafile 2 to
"/u01/app/oracle/oradata/AUXPOWER/undotbs01.dbf";
set newname for datafile 3 to
"/u01/app/oracle/oradata/AUXPOWER/sysaux01.dbf";
set newname for datafile 4 to
"/u01/app/oracle/oradata/AUXPOWER/users01.dbf";
set newname for datafile 5 to
"/u01/app/oracle/oradata/AUXPOWER/example01.dbf";
restore
check readonly
clone database
;
}
executing Memory Script
executing command: SET until clause
executing command: SET NEWNAME
renamed temporary file 1 to /u01/app/oracle/oradata/AUXPOWER/temp01.dbf in control file
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting restore at 01-OCT-08
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=104 devtype=DISK
channel ORA_AUX_DISK_1: starting datafile backupset restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /u01/app/oracle/oradata/AUXPOWER/system01.dbf
restoring datafile 00002 to /u01/app/oracle/oradata/AUXPOWER/undotbs01.dbf
restoring datafile 00003 to /u01/app/oracle/oradata/AUXPOWER/sysaux01.dbf
restoring datafile 00004 to /u01/app/oracle/oradata/AUXPOWER/users01.dbf
restoring datafile 00005 to /u01/app/oracle/oradata/AUXPOWER/example01.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u01/app/oracle/POWER/flash_recovery_area/POWER/backupset/2008_10_01/o1_mf_nnndf_TAG20081001T144816_4g7o00mh_.bkp
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/u01/app/oracle/POWER/flash_recovery_area/POWER/backupset/2008_10_01/o1_mf_nnndf_TAG20081001T144816_4g7o00mh_.bkp tag=TAG20081001T144816
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:15
Finished restore at 01-OCT-08
contents of Memory Script:
{
switch clone datafile all;
}
executing Memory Script
datafile 1 switched to datafile copy
input datafile copy recid=8 stamp=666979072 filename=/u01/app/oracle/oradata/AUXPOWER/system01.dbf
datafile 2 switched to datafile copy
input datafile copy recid=9 stamp=666979072 filename=/u01/app/oracle/oradata/AUXPOWER/undotbs01.dbf
datafile 3 switched to datafile copy
input datafile copy recid=10 stamp=666979072 filename=/u01/app/oracle/oradata/AUXPOWER/sysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy recid=11 stamp=666979072 filename=/u01/app/oracle/oradata/AUXPOWER/users01.dbf
datafile 5 switched to datafile copy
input datafile copy recid=12 stamp=666979072 filename=/u01/app/oracle/oradata/AUXPOWER/example01.dbf
contents of Memory Script:
{
set until scn 3950745;
recover
standby
clone database
delete archivelog
;
}
executing Memory Script
executing command: SET until clause
Starting recover at 01-OCT-08
using channel ORA_AUX_DISK_1
starting media recovery
archive log thread 1 sequence 24 is already on disk as file /u01/app/oracle/POWER/flash_recovery_area/1_24_666695680.arc
archive log thread 1 sequence 25 is already on disk as file /u01/app/oracle/POWER/flash_recovery_area/1_25_666695680.arc
archive log thread 1 sequence 26 is already on disk as file /u01/app/oracle/POWER/flash_recovery_area/1_26_666695680.arc
archive log thread 1 sequence 27 is already on disk as file /u01/app/oracle/POWER/flash_recovery_area/1_27_666695680.arc
archive log thread 1 sequence 28 is already on disk as file /u01/app/oracle/POWER/flash_recovery_area/1_28_666695680.arc
archive log thread 1 sequence 29 is already on disk as file /u01/app/oracle/POWER/flash_recovery_area/1_29_666695680.arc
archive log thread 1 sequence 30 is already on disk as file /u01/app/oracle/POWER/flash_recovery_area/1_30_666695680.arc
archive log filename=/u01/app/oracle/POWER/flash_recovery_area/1_24_666695680.arc thread=1 sequence=24
archive log filename=/u01/app/oracle/POWER/flash_recovery_area/1_25_666695680.arc thread=1 sequence=25
archive log filename=/u01/app/oracle/POWER/flash_recovery_area/1_26_666695680.arc thread=1 sequence=26
archive log filename=/u01/app/oracle/POWER/flash_recovery_area/1_27_666695680.arc thread=1 sequence=27
archive log filename=/u01/app/oracle/POWER/flash_recovery_area/1_28_666695680.arc thread=1 sequence=28
archive log filename=/u01/app/oracle/POWER/flash_recovery_area/1_29_666695680.arc thread=1 sequence=29
archive log filename=/u01/app/oracle/POWER/flash_recovery_area/1_30_666695680.arc thread=1 sequence=30
media recovery complete, elapsed time: 00:00:02
Finished recover at 01-OCT-08
Finished Duplicate Db at 01-OCT-08
RMAN> exit
Recovery Manager complete.
-bash-3.00$ sqlplus '/as sysdba'
SQL*Plus: Release 10.2.0.4.0 - Production on Wed Oct 1 15:59:23 2008
Copyright (c) 1982, 2007, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select * from v$instance;
INSTANCE_NUMBER INSTANCE_NAME
--------------- ----------------
HOST_NAME
----------------------------------------------------------------
VERSION STARTUP_ STATUS PAR THREAD# ARCHIVE LOG_SWITCH_WAIT
----------------- -------- ------------ --- ---------- ------- ---------------
LOGINS SHU DATABASE_STATUS INSTANCE_ROLE ACTIVE_ST BLO
---------- --- ----------------- ------------------ --------- ---
1 AUXPOWER
afrodita
10.2.0.4.0 01/10/08 MOUNTED NO 1 STARTED
ALLOWED NO ACTIVE PRIMARY_INSTANCE NORMAL NO
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /u01/app/oracle/AUXPOWER/flash_recovery_area
Oldest online log sequence 23
Next log sequence to archive 0
Current log sequence 31
SQL>
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE NODELAY;
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE;
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE FINISH;
Database altered.
SQL> select * from v$instance;
INSTANCE_NUMBER INSTANCE_NAME
--------------- ----------------
HOST_NAME
----------------------------------------------------------------
VERSION STARTUP_ STATUS PAR THREAD# ARCHIVE LOG_SWITCH_WAIT
----------------- -------- ------------ --- ---------- ------- ---------------
LOGINS SHU DATABASE_STATUS INSTANCE_ROLE ACTIVE_ST BLO
---------- --- ----------------- ------------------ --------- ---
1 AUXPOWER
afrodita
10.2.0.4.0 01/10/08 MOUNTED NO 1 STARTED
ALLOWED NO ACTIVE PRIMARY_INSTANCE NORMAL NO
SQL> set line 300
SQL> /
SQL> SELECT * FROM V$DATAGUARD_STATS;
INSTANCE_NUMBER INSTANCE_NAME HOST_NAME VERSION STARTUP_ STATUS PAR THREAD# ARCHIVE LOG_SWITCH_WAIT LOGINS SHU DATABASE_STATUS INSTANCE_ROLE ACTIVE_ST BLO
--------------- ---------------- ---------------------------------------------------------------- ----------------- -------- ------------ --- ---------- ------- --------------- ---------- --- ----------------- ------------------ --------- ---
1 AUXPOWER afrodita 10.2.0.4.0 01/10/08 MOUNTED NO 1 STARTED ALLOWED NO ACTIVE PRIMARY_INSTANCE NORMAL NO
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /u01/app/oracle/AUXPOWER/flash_recovery_area
Oldest online log sequence 31
Next log sequence to archive 0
Current log sequence 31
SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-01154: database busy. Open, close, mount, and dismount not allowed now
SQL> ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE PERFORMANCE;
SQL> ALTER DATABASE ACTIVATE PHYSICAL STANDBY DATABASE;
SQL> SELECT PROTECTION_MODE FROM V$DATABASE;
SQL> SELECT * FROM V$DATAGUARD_STATS;
SQL> ALTER DATABASE OPEN READ ONLY;
Verify the new redo data was archived on the standby database.
SQL > SELECT SEQUENCE#, FIRST_TIME, NEXT_TIME FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;
SQL> SELECT NAME,OPEN_MODE,SWITCHOVER_STATUS,GUARD_STATUS,CURRENT_SCN,FLASHBACK_ON, DB_UNIQUE_NAME, STANDBY_BECAME_PRIMARY_SCN FROM V$DATABASE;
SQL > SELECT PROTECTION_MODE FROM V$DATABASE;
Verify that received redo has been applied.
SQL> SELECT SEQUENCE#,APPLIED FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#
SQL> SELECT MAX(SEQUENCE#), THREAD# FROM V$ARCHIVED_LOG GROUP BY THREAD#;
SQL> ALTER DATABASE ACTIVATE PHYSICAL STANDBY DATABASE;
SQL> ALTER DATABASE PREPARE TO SWITCHOVER TO LOGICAL STANDBY;
SQL> SELECT NAME,GUARD_STATUS,CURRENT_SCN,LAST_OPEN_INCARNATION#,SWITCHOVER_STATUS FROM V$DATABASE
SQL> ALTER DATABASE REGISTER PHYSICAL LOGFILE
SQL> SELECT * FROM V$MANAGED_STANDBY
POWER.__db_cache_size=1207959552
POWER.__java_pool_size=16777216
POWER.__large_pool_size=16777216
POWER.__shared_pool_size=352321536
POWER.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/POWER/adump'
*.background_dump_dest='/u01/app/oracle/admin/POWER/bdump'
*.compatible='10.2.0.3.0'
*.control_files='/u01/app/oracle/oradata/POWER/control01.ctl','/u01/app/oracle/oradata/POWER/control02.ctl','/u01/app/oracle/oradata/POWER/control03.ctl'
*.core_dump_dest='/u01/app/oracle/admin/POWER/cdump'
*.db_block_size=8192
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='POWER'
*.db_recovery_file_dest_size=2147483648
*.db_recovery_file_dest='/u01/app/oracle/POWER/flash_recovery_area'
*.DB_UNIQUE_NAME='POWER'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=POWERXDB)'
*.FAL_CLIENT='POWER'
*.FAL_SERVER='AUXPOWER'
*.job_queue_processes=10
*.log_archive_config='dg_config=(POWER,AUXPOWER)'
*.LOG_ARCHIVE_DEST_1='LOCATION=/u01/app/oracle/POWER/flash_recovery_area'
*.log_archive_dest_2='service=AUXPOWER async valid_for=(online_logfile,primary_role) db_unique_name=AUXPOWER'
*.LOG_ARCHIVE_DEST_STATE_1='ENABLE'
*.LOG_ARCHIVE_DEST_STATE_2='ENABLE'
*.LOG_ARCHIVE_FORMAT='%t_%s_%r.arc'
*.LOG_ARCHIVE_MAX_PROCESSES=30
*.nls_language='LATIN AMERICAN SPANISH'
*.nls_territory='COLOMBIA'
*.open_cursors=300
*.pga_aggregate_target=848297984
*.processes=200
*.remote_login_passwordfile='EXCLUSIVE'
*.sessions=225
*.sga_target=1610612736
*.STANDBY_FILE_MANAGEMENT='AUTO'
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/u01/app/oracle/admin/POWER/udump'
INIT AUXPOWER
*.audit_file_dest='/u01/app/oracle/admin/AUXPOWER/adump'
*.background_dump_dest='/u01/app/oracle/admin/AUXPOWER/bdump'
*.compatible='10.2.0.3.0'
*.core_dump_dest='/u01/app/oracle/admin/AUXPOWER/cdump'
*.control_files='/u01/app/oracle/oradata/AUXPOWER/control01.ctl','/u01/app/oracle/oradata/AUXPOWER/control02.ctl','/u01/app/oracle/oradata/AUXPOWER/control03.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='POWER'
*.db_recovery_file_dest_size=2147483648
*.db_recovery_file_dest='/u01/app/oracle/AUXPOWER/flash_recovery_area'
*.DB_UNIQUE_NAME='AUXPOWER'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=AUXPOWERXDB)'
*.job_queue_processes=10
*.log_archive_config='dg_config=(POWER,AUXPOWER)'
*.LOG_ARCHIVE_DEST_1='LOCATION=/u01/app/oracle/AUXPOWER/flash_recovery_area'
*.log_archive_dest_2='service=POWER async valid_for=(online_logfile,primary_role) db_unique_name=POWER'
*.LOG_ARCHIVE_DEST_STATE_1='ENABLE'
*.LOG_ARCHIVE_DEST_STATE_2='ENABLE'
*.LOG_ARCHIVE_FORMAT='%t_%s_%r.arc'
*.LOG_ARCHIVE_MAX_PROCESSES=30
*.nls_language='LATIN AMERICAN SPANISH'
*.nls_territory='COLOMBIA'
*.open_cursors=300
*.pga_aggregate_target=848297984
*.processes=200
*.remote_login_passwordfile='EXCLUSIVE'
*.sessions=225
*.sga_target=700612736
*.STANDBY_FILE_MANAGEMENT='AUTO'
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/u01/app/oracle/admin/AUXPOWER/udump'
*.FAL_SERVER=POWER
*.FAL_CLIENT=AUXPOWER
*.db_file_name_convert=('/u01/app/oracle/oradata/POWER','/u01/app/oracle/oradata/AUXPOWER')
*.log_file_name_convert=('/u01/app/oracle/oradata/POWER','/u01/app/oracle/oradata/AUXPOWER')
SQL> alter system set log_archive_config='dg_config=(POWER,AUXPOWER)';
SQL> alter system set log_archive_dest_2='service=AUXPOWER async valid_for=(online_logfile,primary_role) db_unique_name=AUXPOWER';
-bash-3.00$ rman target sys/sys@power auxiliary /
INSTANCIA PRIMARIA
startup mount pfile=initPOWER.ora
ORACLE instance started.
Total System Global Area 1610612736 bytes
Fixed Size 2139256 bytes
Variable Size 396188552 bytes
Database Buffers 1207959552 bytes
Redo Buffers 4325376 bytes
Database mounted.
SQL> alter database add standby logfile
('/u01/app/oracle/oradata/POWER/srl01.log',
'/u01/app/oracle/oradata/POWER/srl02.log',
'/u01/app/oracle/oradata/POWER/srl03.log')
size 52428800
/
SQL> ALTER DATABASE CREATE STANDBY CONTROLFILE AS '/u01/app/oracle/oradata/AUXPOWER/auxpowerstby.ctl';
SELECT * FROM V$STANDBY_LOG;
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 1610612736 bytes
Fixed Size 2139256 bytes
Variable Size 396188552 bytes
Database Buffers 1207959552 bytes
Redo Buffers 4325376 bytes
Database mounted.
SQL> alter database archivelog;
Database altered.
SQL> alter database flashback on;
Database altered.
SQL> alter database open;
Database altered.
NOMOUNT
$ export ORACLE_SID=AUXPOWER
SQL> startup nomount pfile=initAUXPOWER.ora
ORACLE instance started.
Total System Global Area 700448768 bytes
Fixed Size 2141504 bytes
Variable Size 186471104 bytes
Database Buffers 507510784 bytes
Redo Buffers 4325376 bytes
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
-bash-3.00$ rman target sys/sys@power auxiliary /
Recovery Manager: Release 10.2.0.4.0 - Production on Tue Sep 30 18:02:57 2008
Copyright (c) 1982, 2007, Oracle. All rights reserved.
connected to target database: POWER (DBID=1586828541)
connected to auxiliary database: POWER (not mounted)
RMAN> duplicate target database for standby nofilenamecheck dorecover;
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE;
SQL> alter database recover managed standby database cancel;
SQL> alter database open;
SQL> create spfile from pfile;
EJEMPLO DE SALIDA DE STANDBY DATABASE
-bash-3.00$ rman target sys/sys@power auxiliary /
Recovery Manager: Release 10.2.0.4.0 - Production on Wed Oct 1 15:57:13 2008
Copyright (c) 1982, 2007, Oracle. All rights reserved.
connected to target database: POWER (DBID=1586828541)
connected to auxiliary database: POWER (not mounted)
RMAN> duplicate target database for standby nofilenamecheck dorecover;
Starting Duplicate Db at 01-OCT-08
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=104 devtype=DISK
contents of Memory Script:
{
set until scn 3950745;
restore clone standby controlfile;
sql clone 'alter database mount standby database';
}
executing Memory Script
executing command: SET until clause
Starting restore at 01-OCT-08
using channel ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: copied control file copy
input filename=/u01/app/oracle/oradata/POWER/auxpower.ctl
output filename=/u01/app/oracle/oradata/AUXPOWER/control01.ctl
output filename=/u01/app/oracle/oradata/AUXPOWER/control02.ctl
output filename=/u01/app/oracle/oradata/AUXPOWER/control03.ctl
Finished restore at 01-OCT-08
sql statement: alter database mount standby database
released channel: ORA_AUX_DISK_1
contents of Memory Script:
{
set until scn 3950745;
set newname for tempfile 1 to
"/u01/app/oracle/oradata/AUXPOWER/temp01.dbf";
switch clone tempfile all;
set newname for datafile 1 to
"/u01/app/oracle/oradata/AUXPOWER/system01.dbf";
set newname for datafile 2 to
"/u01/app/oracle/oradata/AUXPOWER/undotbs01.dbf";
set newname for datafile 3 to
"/u01/app/oracle/oradata/AUXPOWER/sysaux01.dbf";
set newname for datafile 4 to
"/u01/app/oracle/oradata/AUXPOWER/users01.dbf";
set newname for datafile 5 to
"/u01/app/oracle/oradata/AUXPOWER/example01.dbf";
restore
check readonly
clone database
;
}
executing Memory Script
executing command: SET until clause
executing command: SET NEWNAME
renamed temporary file 1 to /u01/app/oracle/oradata/AUXPOWER/temp01.dbf in control file
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting restore at 01-OCT-08
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=104 devtype=DISK
channel ORA_AUX_DISK_1: starting datafile backupset restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /u01/app/oracle/oradata/AUXPOWER/system01.dbf
restoring datafile 00002 to /u01/app/oracle/oradata/AUXPOWER/undotbs01.dbf
restoring datafile 00003 to /u01/app/oracle/oradata/AUXPOWER/sysaux01.dbf
restoring datafile 00004 to /u01/app/oracle/oradata/AUXPOWER/users01.dbf
restoring datafile 00005 to /u01/app/oracle/oradata/AUXPOWER/example01.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u01/app/oracle/POWER/flash_recovery_area/POWER/backupset/2008_10_01/o1_mf_nnndf_TAG20081001T144816_4g7o00mh_.bkp
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/u01/app/oracle/POWER/flash_recovery_area/POWER/backupset/2008_10_01/o1_mf_nnndf_TAG20081001T144816_4g7o00mh_.bkp tag=TAG20081001T144816
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:15
Finished restore at 01-OCT-08
contents of Memory Script:
{
switch clone datafile all;
}
executing Memory Script
datafile 1 switched to datafile copy
input datafile copy recid=8 stamp=666979072 filename=/u01/app/oracle/oradata/AUXPOWER/system01.dbf
datafile 2 switched to datafile copy
input datafile copy recid=9 stamp=666979072 filename=/u01/app/oracle/oradata/AUXPOWER/undotbs01.dbf
datafile 3 switched to datafile copy
input datafile copy recid=10 stamp=666979072 filename=/u01/app/oracle/oradata/AUXPOWER/sysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy recid=11 stamp=666979072 filename=/u01/app/oracle/oradata/AUXPOWER/users01.dbf
datafile 5 switched to datafile copy
input datafile copy recid=12 stamp=666979072 filename=/u01/app/oracle/oradata/AUXPOWER/example01.dbf
contents of Memory Script:
{
set until scn 3950745;
recover
standby
clone database
delete archivelog
;
}
executing Memory Script
executing command: SET until clause
Starting recover at 01-OCT-08
using channel ORA_AUX_DISK_1
starting media recovery
archive log thread 1 sequence 24 is already on disk as file /u01/app/oracle/POWER/flash_recovery_area/1_24_666695680.arc
archive log thread 1 sequence 25 is already on disk as file /u01/app/oracle/POWER/flash_recovery_area/1_25_666695680.arc
archive log thread 1 sequence 26 is already on disk as file /u01/app/oracle/POWER/flash_recovery_area/1_26_666695680.arc
archive log thread 1 sequence 27 is already on disk as file /u01/app/oracle/POWER/flash_recovery_area/1_27_666695680.arc
archive log thread 1 sequence 28 is already on disk as file /u01/app/oracle/POWER/flash_recovery_area/1_28_666695680.arc
archive log thread 1 sequence 29 is already on disk as file /u01/app/oracle/POWER/flash_recovery_area/1_29_666695680.arc
archive log thread 1 sequence 30 is already on disk as file /u01/app/oracle/POWER/flash_recovery_area/1_30_666695680.arc
archive log filename=/u01/app/oracle/POWER/flash_recovery_area/1_24_666695680.arc thread=1 sequence=24
archive log filename=/u01/app/oracle/POWER/flash_recovery_area/1_25_666695680.arc thread=1 sequence=25
archive log filename=/u01/app/oracle/POWER/flash_recovery_area/1_26_666695680.arc thread=1 sequence=26
archive log filename=/u01/app/oracle/POWER/flash_recovery_area/1_27_666695680.arc thread=1 sequence=27
archive log filename=/u01/app/oracle/POWER/flash_recovery_area/1_28_666695680.arc thread=1 sequence=28
archive log filename=/u01/app/oracle/POWER/flash_recovery_area/1_29_666695680.arc thread=1 sequence=29
archive log filename=/u01/app/oracle/POWER/flash_recovery_area/1_30_666695680.arc thread=1 sequence=30
media recovery complete, elapsed time: 00:00:02
Finished recover at 01-OCT-08
Finished Duplicate Db at 01-OCT-08
RMAN> exit
Recovery Manager complete.
-bash-3.00$ sqlplus '/as sysdba'
SQL*Plus: Release 10.2.0.4.0 - Production on Wed Oct 1 15:59:23 2008
Copyright (c) 1982, 2007, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select * from v$instance;
INSTANCE_NUMBER INSTANCE_NAME
--------------- ----------------
HOST_NAME
----------------------------------------------------------------
VERSION STARTUP_ STATUS PAR THREAD# ARCHIVE LOG_SWITCH_WAIT
----------------- -------- ------------ --- ---------- ------- ---------------
LOGINS SHU DATABASE_STATUS INSTANCE_ROLE ACTIVE_ST BLO
---------- --- ----------------- ------------------ --------- ---
1 AUXPOWER
afrodita
10.2.0.4.0 01/10/08 MOUNTED NO 1 STARTED
ALLOWED NO ACTIVE PRIMARY_INSTANCE NORMAL NO
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /u01/app/oracle/AUXPOWER/flash_recovery_area
Oldest online log sequence 23
Next log sequence to archive 0
Current log sequence 31
SQL>
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE NODELAY;
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE;
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE FINISH;
Database altered.
SQL> select * from v$instance;
INSTANCE_NUMBER INSTANCE_NAME
--------------- ----------------
HOST_NAME
----------------------------------------------------------------
VERSION STARTUP_ STATUS PAR THREAD# ARCHIVE LOG_SWITCH_WAIT
----------------- -------- ------------ --- ---------- ------- ---------------
LOGINS SHU DATABASE_STATUS INSTANCE_ROLE ACTIVE_ST BLO
---------- --- ----------------- ------------------ --------- ---
1 AUXPOWER
afrodita
10.2.0.4.0 01/10/08 MOUNTED NO 1 STARTED
ALLOWED NO ACTIVE PRIMARY_INSTANCE NORMAL NO
SQL> set line 300
SQL> /
SQL> SELECT * FROM V$DATAGUARD_STATS;
INSTANCE_NUMBER INSTANCE_NAME HOST_NAME VERSION STARTUP_ STATUS PAR THREAD# ARCHIVE LOG_SWITCH_WAIT LOGINS SHU DATABASE_STATUS INSTANCE_ROLE ACTIVE_ST BLO
--------------- ---------------- ---------------------------------------------------------------- ----------------- -------- ------------ --- ---------- ------- --------------- ---------- --- ----------------- ------------------ --------- ---
1 AUXPOWER afrodita 10.2.0.4.0 01/10/08 MOUNTED NO 1 STARTED ALLOWED NO ACTIVE PRIMARY_INSTANCE NORMAL NO
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /u01/app/oracle/AUXPOWER/flash_recovery_area
Oldest online log sequence 31
Next log sequence to archive 0
Current log sequence 31
SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-01154: database busy. Open, close, mount, and dismount not allowed now
SQL> ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE PERFORMANCE;
SQL> ALTER DATABASE ACTIVATE PHYSICAL STANDBY DATABASE;
SQL> SELECT PROTECTION_MODE FROM V$DATABASE;
SQL> SELECT * FROM V$DATAGUARD_STATS;
SQL> ALTER DATABASE OPEN READ ONLY;
Verify the new redo data was archived on the standby database.
SQL > SELECT SEQUENCE#, FIRST_TIME, NEXT_TIME FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;
SQL> SELECT NAME,OPEN_MODE,SWITCHOVER_STATUS,GUARD_STATUS,CURRENT_SCN,FLASHBACK_ON, DB_UNIQUE_NAME, STANDBY_BECAME_PRIMARY_SCN FROM V$DATABASE;
SQL > SELECT PROTECTION_MODE FROM V$DATABASE;
Verify that received redo has been applied.
SQL> SELECT SEQUENCE#,APPLIED FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#
SQL> SELECT MAX(SEQUENCE#), THREAD# FROM V$ARCHIVED_LOG GROUP BY THREAD#;
SQL> ALTER DATABASE ACTIVATE PHYSICAL STANDBY DATABASE;
SQL> ALTER DATABASE PREPARE TO SWITCHOVER TO LOGICAL STANDBY;
SQL> SELECT NAME,GUARD_STATUS,CURRENT_SCN,LAST_OPEN_INCARNATION#,SWITCHOVER_STATUS FROM V$DATABASE
SQL> ALTER DATABASE REGISTER PHYSICAL LOGFILE
SQL> SELECT * FROM V$MANAGED_STANDBY
jueves, 1 de octubre de 2009
RMAN on Windows
Another way to check the service name command is to use the SC command. Here is how
you can check the database service:
C:\>sc query OracleServiceMOBDB11
If the service is set to Manual, then you must start it. To start it, you can right-click the name of the service and click Start. Alternatively, you can execute the following command from the command prompt:
C:> net start OracleServiceMOBDB11
creating an Oracle service to starting/stopping and even removing the services.
Here is how you can start the Oracle service using this tool:
C:\> oradim -startup -sid MOBDB11 -starttype srvc,inst
You can also use the following command to see the users in the ORA_DBA group:
c:\work\orascripts>net localgroup ora_dba
Alias name ora_dba
Comment Oracle DBA Group
Members
-------------------------------------------------------------------------
arup
CORP\arupnan
NT AUTHORITY\SYSTEM
The command completed successfully.
you can check the database service:
C:\>sc query OracleServiceMOBDB11
If the service is set to Manual, then you must start it. To start it, you can right-click the name of the service and click Start. Alternatively, you can execute the following command from the command prompt:
C:> net start OracleServiceMOBDB11
creating an Oracle service to starting/stopping and even removing the services.
Here is how you can start the Oracle service using this tool:
C:\> oradim -startup -sid MOBDB11 -starttype srvc,inst
You can also use the following command to see the users in the ORA_DBA group:
c:\work\orascripts>net localgroup ora_dba
Alias name ora_dba
Comment Oracle DBA Group
Members
-------------------------------------------------------------------------
arup
CORP\arupnan
NT AUTHORITY\SYSTEM
The command completed successfully.
RMAN Using Recovery Advisor
Listing Failures
Problem
You suspect you have a media failure in your database. You want to use the Data Recovery Advisor to list media failures.
Solution
Use the list failure command as shown here:
RMAN> list failure;
Can determine the location of the base directory for the ADR by viewing the diagnostic_dest initialization parameter. You can view the names and values of directories in the ADR with this query:
SQL> select name, value from v$diag_info;
If you suspect there is a problem with your database and the Data Recovery Advisor is not reporting a failure, you can proactively initiate a database health check by running the following
RMAN> validate database;
RMAN> list failure 15 detail;
Table 20-1. Data Recovery Advisor List Failure Options Failure Type Description
ALL Lists all failures
CRITICAL Lists only critical failures with an OPEN status
HIGH Lists only high-priority failures with an OPEN status
LOW Lists only low-priority failures with an OPEN status CLOSED Lists failures with a CLOSED status
EXCLUDE FAILURE Excludes failures by a specified failure number
DETAIL Provides verbose description of the failure
If you want to see all failures that have been resolved and closed, then use the closed clause:
RMAN> list failure closed;
Getting Advice
Problem
You’ve experienced a media failure. You want to get advice from the Data Recovery Advisor about how to restore and recover your database.
Solution
First use the list failure command to display all failures (see recipe 20-1 for details). If you have only one failure associated with your database, then you can run the advise failure command without any parameters:
RMAN> advise failure;
RMAN> advise failure 15;
specifying one of the following keywords: ALL, CRITICAL, HIGH, or LOW. This example
displays advice about just the critical errors:
RMAN> advise failure critical;
Repairing Failures
Problem
You’ve experienced a media failure. You want to use the Data Recovery Advisor to perform a restore and recovery.
Solution
We recommend that you always run the following RMAN commands in this order:
1. list failure
2. advise failure
3. repair failure
By running list failure and advise failure, you will gain an understanding as to what
the problem is and how to fix it. You can use the repair failure command to run the repair script generated by the Data Recovery Advisor:
RMAN> repair failure;
You will be prompted to specify whether you want to run the repair script:
Do you really want to execute the above repair (enter YES or NO)?
RMAN> repair failure preview;
The preview clause instructs RMAN to display only the commands that it recommends be
run to resolve the failure. If you want to spool the output of a preview command to a file, then use the spool command:
RMAN> spool log to rmanout.txt;
RMAN> repair failure preview;
If you don’t want to be prompted during a repair session, then use the noprompt clause:
RMAN> repair failure noprompt;
Problem
You suspect you have a media failure in your database. You want to use the Data Recovery Advisor to list media failures.
Solution
Use the list failure command as shown here:
RMAN> list failure;
Can determine the location of the base directory for the ADR by viewing the diagnostic_dest initialization parameter. You can view the names and values of directories in the ADR with this query:
SQL> select name, value from v$diag_info;
If you suspect there is a problem with your database and the Data Recovery Advisor is not reporting a failure, you can proactively initiate a database health check by running the following
RMAN> validate database;
RMAN> list failure 15 detail;
Table 20-1. Data Recovery Advisor List Failure Options Failure Type Description
ALL Lists all failures
CRITICAL Lists only critical failures with an OPEN status
HIGH Lists only high-priority failures with an OPEN status
LOW Lists only low-priority failures with an OPEN status CLOSED Lists failures with a CLOSED status
EXCLUDE FAILURE Excludes failures by a specified failure number
DETAIL Provides verbose description of the failure
If you want to see all failures that have been resolved and closed, then use the closed clause:
RMAN> list failure closed;
Getting Advice
Problem
You’ve experienced a media failure. You want to get advice from the Data Recovery Advisor about how to restore and recover your database.
Solution
First use the list failure command to display all failures (see recipe 20-1 for details). If you have only one failure associated with your database, then you can run the advise failure command without any parameters:
RMAN> advise failure;
RMAN> advise failure 15;
specifying one of the following keywords: ALL, CRITICAL, HIGH, or LOW. This example
displays advice about just the critical errors:
RMAN> advise failure critical;
Repairing Failures
Problem
You’ve experienced a media failure. You want to use the Data Recovery Advisor to perform a restore and recovery.
Solution
We recommend that you always run the following RMAN commands in this order:
1. list failure
2. advise failure
3. repair failure
By running list failure and advise failure, you will gain an understanding as to what
the problem is and how to fix it. You can use the repair failure command to run the repair script generated by the Data Recovery Advisor:
RMAN> repair failure;
You will be prompted to specify whether you want to run the repair script:
Do you really want to execute the above repair (enter YES or NO)?
RMAN> repair failure preview;
The preview clause instructs RMAN to display only the commands that it recommends be
run to resolve the failure. If you want to spool the output of a preview command to a file, then use the spool command:
RMAN> spool log to rmanout.txt;
RMAN> repair failure preview;
If you don’t want to be prompted during a repair session, then use the noprompt clause:
RMAN> repair failure noprompt;
martes, 29 de septiembre de 2009
Installing the NetBackup Agent for Oracle
1. Make sure you have all the software for the installation:
•NetBackup license (you can’t install without one)
•NetBackup server software for your platform (the current version is 6.0)
•NetBackup agent for Oracle software
2. Prepare the necessary hardware for the installation:
•Master server
•Media server
•Tape library
3. Install the NetBackup software on the master server, the media servers, and the database
(client) server. Test the communication from the master server to the database
server by issuing the following command:
$ cd /usr/openv/netbackup/bin
$ ./bpclntcmd -pn
expecting response from server hounbupbs01-nbu
houcrspdb02-nbu.cce.star houcrspdb02-nbu 172.22.1.121 42546
$
The output shows that the master server (hounbupbs01-nbu) can be reached from the
client (houcrspdb02-nbu) where the database is running.
4. Check the master server and other parameters to make sure everything is correct:
$ cd /usr/openv/netbackup
$ ls
bin bp.conf client dbext ext help logs nblog.conf nblog.conf.template
$ cat bp.conf
SERVER = hounbupbs01-nbu
SERVER = hounbupbs01
MEDIA_SERVER = hounbupms01-nbu
SERVER = houjmp1w-nbu
SERVER = hounbupbs01-nbu.cce.starwoodhotels.com
MEDIA_SERVER = hounbupms02
CLIENT_NAME = houcrspdb02-nbu
5. Verify that the NetBackup daemons are running:
$ netstat -a | grep bpcd
tcp 0 0 *:bpcd *:* LISTEN
$ netstat -a | grep vnetd
tcp 0 0 *:vnetd *:* LISTEN
6. Verify that the licenses are all installed. Run the following command Grafic
$ /usr/openv/netbackup/bin/jnbSA
7. Insert the installation CD for NetBackup for Oracle, and mount the CD-ROM.
8. Log in as root on the database server.
9. Run the script ./install.
10. From the menu, choose the option NetBackup Database Agent.
11. When prompted, choose Y for local installation.
12. From the menu, choose NetBackup for Oracle.
13. Check the log files for any installation-related errors.
14. Now link Oracle to the NetBackup client. Log in to the database server box as the
Oracle software owner.
15. Shut down all the Oracle Databases running on the server under the Oracle Home.
16. Relink Oracle by running the script oracle_link:
$ cd /usr/openv/netbackup/bin
$ ./oracle_link
17. This creates an output in the file /tmp/make_trace.. Check the file for errors.
•NetBackup license (you can’t install without one)
•NetBackup server software for your platform (the current version is 6.0)
•NetBackup agent for Oracle software
2. Prepare the necessary hardware for the installation:
•Master server
•Media server
•Tape library
3. Install the NetBackup software on the master server, the media servers, and the database
(client) server. Test the communication from the master server to the database
server by issuing the following command:
$ cd /usr/openv/netbackup/bin
$ ./bpclntcmd -pn
expecting response from server hounbupbs01-nbu
houcrspdb02-nbu.cce.star houcrspdb02-nbu 172.22.1.121 42546
$
The output shows that the master server (hounbupbs01-nbu) can be reached from the
client (houcrspdb02-nbu) where the database is running.
4. Check the master server and other parameters to make sure everything is correct:
$ cd /usr/openv/netbackup
$ ls
bin bp.conf client dbext ext help logs nblog.conf nblog.conf.template
$ cat bp.conf
SERVER = hounbupbs01-nbu
SERVER = hounbupbs01
MEDIA_SERVER = hounbupms01-nbu
SERVER = houjmp1w-nbu
SERVER = hounbupbs01-nbu.cce.starwoodhotels.com
MEDIA_SERVER = hounbupms02
CLIENT_NAME = houcrspdb02-nbu
5. Verify that the NetBackup daemons are running:
$ netstat -a | grep bpcd
tcp 0 0 *:bpcd *:* LISTEN
$ netstat -a | grep vnetd
tcp 0 0 *:vnetd *:* LISTEN
6. Verify that the licenses are all installed. Run the following command Grafic
$ /usr/openv/netbackup/bin/jnbSA
7. Insert the installation CD for NetBackup for Oracle, and mount the CD-ROM.
8. Log in as root on the database server.
9. Run the script ./install.
10. From the menu, choose the option NetBackup Database Agent.
11. When prompted, choose Y for local installation.
12. From the menu, choose NetBackup for Oracle.
13. Check the log files for any installation-related errors.
14. Now link Oracle to the NetBackup client. Log in to the database server box as the
Oracle software owner.
15. Shut down all the Oracle Databases running on the server under the Oracle Home.
16. Relink Oracle by running the script oracle_link:
$ cd /usr/openv/netbackup/bin
$ ./oracle_link
17. This creates an output in the file /tmp/make_trace.
RMAN Troubleshooting
//VERITAS
The sbt function pointers are loaded from libobk.so library
$ORACLE_HOME/bin/sbttest /tmp/x.lst
Moving and/or Resizing the FRA
The following SQL statement uses the alter system command to move the flash recovery area to /orabackup02/FRA:
SQL> alter system set db_recovery_file_dest='/oraback02/FRA';
If disk space is available, you can increase the size of the flash recovery area to an appropriate value. This example changes the flash recovery area size to 100GB:
SQL> alter system set db_recovery_file_dest_size=100g;
Changing Retention Policy and Deleting Old Backups
RMAN> report obsolete;
This command will show the retention policy and which backups and archived redo log
files are obsolete. Here is what the output might look like:
RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 6
no obsolete backups found
In this example, no obsolete backups were reported. We’ll use the configure command to
change the retention policy from a redundancy policy of six down to two:
RMAN> configure retention policy to redundancy 2;
Now the report obsolete command shows that there are several obsolete files:
RMAN> report obsolete;
Dealing with the RMAN-06059 Error
RMAN> backup database plus archivelog;
Your backup process doesn’t get very far when RMAN throws this error:
RMAN-03002: failure of backup command ...
RMAN-06059: expected archived log not found, loss of archived log compromises
Solution
You must update RMAN’s repository to reflect that archived redo log files either have been physically deleted or have been moved to another location on disk. Use the crosscheck command
RMAN> crosscheck archivelog all;
If the archived redo log files have been physically moved to a different location on disk, then use the catalog command to update the RMAN repository with the new location of the files:
RMAN> catalog start with '/oradump01/oldarchive';
RMAN to back up any
archived redo log files that have an AVAILABLE status in the V$ARCHIVED_LOG view. You can query the STATUS column of V$ARCHIVED_LOG as follows:
SQL> select sequence#,
2 decode(status,'A','available','D','deleted','U','unavailable','X','expired')
3 from v$archived_log;
Using SQL to Terminate an RMAN Channel
Use the alter system kill session SQL statement to terminate a hung RMAN job. To do this, you need to first identify the serial ID and serial number:
SQL> SELECT
2 s.sid
3 ,s.serial#
4 ,p.spid
5 ,s.client_info
6 FROM v$process p,
7 v$session s
8 WHERE p.addr = s.paddr
9 AND client_info LIKE '%rman%';
SID SERIAL# SPID CLIENT_INFO
----- ---------- ------------ -------------------------
157 18030 7344 rman channel=ORA_DISK_1
SQL> alter system kill session '157,18030';
Diagnosing NLS Character Set Issues
Problem
You’re trying to connect to RMAN, and you get an NLS error similar to the following:
ORA-12705: Cannot access NLS data files or invalid environment specified
Solution
SQL> select value from v$nls_parameters where parameter = 'NLS_CHARACTERSET';
$ setenv NLS_LANG american_america.we8iso8859p1
In a Unix Korn shell environment, use the OS export command as follows:
$ export NLS_LANG=american_america.we8iso8859p1
V$NLS_VALID_VALUES Lists all valid values for NLS settings.
NLS_SESSION_PARAMETERS Contains NLS values for the current session.
V$NLS_PARAMETERS Contains current values of NLS parameters.
NLS_INSTANCE_PARAMETERS Contains NLS values set at the instance level. NLS_DATABASE_PARAMETERS Contains NLS values defined when your database was created.
These can be overridden by the instance, client OS, or client
session.
Logging RMAN Output
rman TARGET SYS/pwd debug trace=rman.trc log=rman.log
$ rman target / log=rman_output.log
From the RMAN Command Line
You can also spool the output to a log file from the RMAN command line, as shown here:
RMAN> spool log to rman_output.log
RMAN> set echo on
RMAN> backup database;
To turn off logging, use the log off parameter, as shown here:
RMAN> spool log off;
$ rman target / log=rman_output.log append
RMAN> spool log to rman_output.log append
RMAN> spool log to rman_output.log
RMAN> set echo on
RMAN> run{ allocate channel d1 type disk;
2> backup database;
3> release channel d1;
4> }
Viewing RMAN Command History
Solution
Use V$RMAN_OUTPUT to view the text messages that RMAN produces when performing
tasks. Run this query to view the historical RMAN command messages:
SQL> select
2 sid,
3 recid,
4 output
5 from v$rman_output
6 order by recid
7 /
Enabling RMAN’s Debug Output
From the OS Prompt
This first example enables all debugging and captures the output in a log file:
$ rman target / debug=all log=rman_output.log
The following example enables debugging just for I/O activities:
$ rman target / debug=io
When Configuring a Channel
This example configures a channel to debug and trace at level 5:
RMAN> configure channel device type disk debug=5 trace=5;
RMAN> spool log to rman_output.log
RMAN> debug on
RMAN> set echo on
RMAN> backup database;
RMAN> debug off
RMAN> spool log off
Enabling Granular Time Reporting
$ setenv NLS_DATE_FORMAT 'dd-mon-yyyy hh24:mi:ss'
In a Unix Korn shell environment, use the OS export command as follows:
$ export NLS_DATE_FORMAT='dd-mon-yyyy hh24:mi:ss'
In a Windows environment, use the set command as shown here:
c:\> set NLS_DATE_FORMAT=dd-mon-yyyy hh24:mi:ss
For example, if you wanted to just debug I/O-related operations when backing up your
users tablespace, then you would enable I/O debugging as shown here:
RMAN> spool log to rman_output.log
RMAN> set echo on
RMAN> debug io
RMAN> backup tablespace users;
RMAN> debug off
RMAN> spool log off
RMAN Compatibility Matrix
Target DB Auxiliary DB RMAN Executable Catalog DB Catalog Schema
8.1.7.4 8.1.7.4 8.1.7.4 >= 8.1.7 8.1.7.4 or >= 9.0.1.4
9.0.1 9.0.1 9.0.1 >= 8.1.7 >= RMAN executable
9.2.0 9.2.0 >= 9.0.1.3 and <= Target DB >= 8.1.7 >= RMAN executable
10.1.0 10.1.0 >= 9.0.1.3 and <= Target DB >= 9.0.1 >= RMAN executable
10.2.0 10.2.0 >= 9.0.1.3 and <= Target DB >= 9.0.1 >= RMAN executable
11.1.0 11.1.0 TBD TBD >= RMAN executable
Managing Files in an ASM Environment
C:\> asmcmd -p
You should now see the ASMCMD prompt:
ASMCMD [+]>
The -p option will set your prompt to display the current working directory as part of the
prompt. For example, the ASMCMD prompt changes as we use the cd command to change
the current directory:
ASMCMD [+] > cd +data/prmy/datafile
ASMCMD [+data/prmy/datafile] >
Command Description
cd Changes the current directory to the specified directory
du Displays the total disk space occupied by ASM files in the specified ASM
directory and all its subdirectories, recursively
exit Exits ASMCMD
find Lists the paths of all occurrences of the specified name (with wildcards) under
the specified directory help Displays the syntax and description of ASMCMD commands
ls Lists the contents of an ASM directory, the attributes of the specified file, or the names and attributes of all disk groups
lsct Lists information about current ASM clients
lsdg Lists all disk groups and their attributes
mkalias Creates an alias for a system-generated filename
mkdir Creates ASM directories
pwd Displays the path of the current ASM directory
rm Deletes the specified ASM files or directories
rmalias Deletes the specified alias, retaining the file to which the alias points
md_backup Creates a metadata backup script of mounted disk groups (Oracle Database
11g only)
md_restore Restores a disk group backup (Oracle Database 11g only)
lsdsk Lists the ASM disks (Oracle Database 11g only)
repair Repairs range of physical blocks on the ASM disk (Oracle Database 11g only)
with SQL*Plus, the following query is useful for viewing files within your ASM environment:
SQL> SELECT concat('+'||gname, sys_connect_by_path(aname, '/')) full_alias_path FROM
2 (SELECT g.name gname, a.parent_index pindex, a.name aname,
3 a.reference_index rindex FROM v$asm_alias a, v$asm_diskgroup g
4 WHERE a.group_number = g.group_number)
5 START WITH (mod(pindex, power(2, 24))) = 0
6 CONNECT BY PRIOR rindex = pindex;
Backup Validation with RMAN
You can run the BACKUP ... VALIDATE command to check datafiles for physical and logical corruption, or to confirm that all database files exist in the correct locations. No backup is taken, but all specified files are scanned to verify that they can be backed up. All corruptions are recorded in theV$DATABASE_BLOCK_CORRUPTION view.
The following example shows how to check your entire database and archived redo log files for physical and logical corruption:
BACKUP VALIDATE CHECK LOGICAL DATABASE ARCHIVELOG ALL;
You cannot use the MAXCORRUPT or PROXY parameters with the VALIDATE option.
# mark backup as unavailable in the repository so that RMAN does not attempt to
# restore it unless explicitly specified on the RESTORE command
RMAN> CHANGE BACKUP TAG 'db_archive_1' UNAVAILABLE;
RMAN> SQL 'ALTER DATABASE OPEN';
The sbt function pointers are loaded from libobk.so library
$ORACLE_HOME/bin/sbttest /tmp/x.lst
Moving and/or Resizing the FRA
The following SQL statement uses the alter system command to move the flash recovery area to /orabackup02/FRA:
SQL> alter system set db_recovery_file_dest='/oraback02/FRA';
If disk space is available, you can increase the size of the flash recovery area to an appropriate value. This example changes the flash recovery area size to 100GB:
SQL> alter system set db_recovery_file_dest_size=100g;
Changing Retention Policy and Deleting Old Backups
RMAN> report obsolete;
This command will show the retention policy and which backups and archived redo log
files are obsolete. Here is what the output might look like:
RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 6
no obsolete backups found
In this example, no obsolete backups were reported. We’ll use the configure command to
change the retention policy from a redundancy policy of six down to two:
RMAN> configure retention policy to redundancy 2;
Now the report obsolete command shows that there are several obsolete files:
RMAN> report obsolete;
Dealing with the RMAN-06059 Error
RMAN> backup database plus archivelog;
Your backup process doesn’t get very far when RMAN throws this error:
RMAN-03002: failure of backup command ...
RMAN-06059: expected archived log not found, loss of archived log compromises
Solution
You must update RMAN’s repository to reflect that archived redo log files either have been physically deleted or have been moved to another location on disk. Use the crosscheck command
RMAN> crosscheck archivelog all;
If the archived redo log files have been physically moved to a different location on disk, then use the catalog command to update the RMAN repository with the new location of the files:
RMAN> catalog start with '/oradump01/oldarchive';
RMAN to back up any
archived redo log files that have an AVAILABLE status in the V$ARCHIVED_LOG view. You can query the STATUS column of V$ARCHIVED_LOG as follows:
SQL> select sequence#,
2 decode(status,'A','available','D','deleted','U','unavailable','X','expired')
3 from v$archived_log;
Using SQL to Terminate an RMAN Channel
Use the alter system kill session SQL statement to terminate a hung RMAN job. To do this, you need to first identify the serial ID and serial number:
SQL> SELECT
2 s.sid
3 ,s.serial#
4 ,p.spid
5 ,s.client_info
6 FROM v$process p,
7 v$session s
8 WHERE p.addr = s.paddr
9 AND client_info LIKE '%rman%';
SID SERIAL# SPID CLIENT_INFO
----- ---------- ------------ -------------------------
157 18030 7344 rman channel=ORA_DISK_1
SQL> alter system kill session '157,18030';
Diagnosing NLS Character Set Issues
Problem
You’re trying to connect to RMAN, and you get an NLS error similar to the following:
ORA-12705: Cannot access NLS data files or invalid environment specified
Solution
SQL> select value from v$nls_parameters where parameter = 'NLS_CHARACTERSET';
$ setenv NLS_LANG american_america.we8iso8859p1
In a Unix Korn shell environment, use the OS export command as follows:
$ export NLS_LANG=american_america.we8iso8859p1
V$NLS_VALID_VALUES Lists all valid values for NLS settings.
NLS_SESSION_PARAMETERS Contains NLS values for the current session.
V$NLS_PARAMETERS Contains current values of NLS parameters.
NLS_INSTANCE_PARAMETERS Contains NLS values set at the instance level. NLS_DATABASE_PARAMETERS Contains NLS values defined when your database was created.
These can be overridden by the instance, client OS, or client
session.
Logging RMAN Output
rman TARGET SYS/pwd debug trace=rman.trc log=rman.log
$ rman target / log=rman_output.log
From the RMAN Command Line
You can also spool the output to a log file from the RMAN command line, as shown here:
RMAN> spool log to rman_output.log
RMAN> set echo on
RMAN> backup database;
To turn off logging, use the log off parameter, as shown here:
RMAN> spool log off;
$ rman target / log=rman_output.log append
RMAN> spool log to rman_output.log append
RMAN> spool log to rman_output.log
RMAN> set echo on
RMAN> run{ allocate channel d1 type disk;
2> backup database;
3> release channel d1;
4> }
Viewing RMAN Command History
Solution
Use V$RMAN_OUTPUT to view the text messages that RMAN produces when performing
tasks. Run this query to view the historical RMAN command messages:
SQL> select
2 sid,
3 recid,
4 output
5 from v$rman_output
6 order by recid
7 /
Enabling RMAN’s Debug Output
From the OS Prompt
This first example enables all debugging and captures the output in a log file:
$ rman target / debug=all log=rman_output.log
The following example enables debugging just for I/O activities:
$ rman target / debug=io
When Configuring a Channel
This example configures a channel to debug and trace at level 5:
RMAN> configure channel device type disk debug=5 trace=5;
RMAN> spool log to rman_output.log
RMAN> debug on
RMAN> set echo on
RMAN> backup database;
RMAN> debug off
RMAN> spool log off
Enabling Granular Time Reporting
$ setenv NLS_DATE_FORMAT 'dd-mon-yyyy hh24:mi:ss'
In a Unix Korn shell environment, use the OS export command as follows:
$ export NLS_DATE_FORMAT='dd-mon-yyyy hh24:mi:ss'
In a Windows environment, use the set command as shown here:
c:\> set NLS_DATE_FORMAT=dd-mon-yyyy hh24:mi:ss
For example, if you wanted to just debug I/O-related operations when backing up your
users tablespace, then you would enable I/O debugging as shown here:
RMAN> spool log to rman_output.log
RMAN> set echo on
RMAN> debug io
RMAN> backup tablespace users;
RMAN> debug off
RMAN> spool log off
RMAN Compatibility Matrix
Target DB Auxiliary DB RMAN Executable Catalog DB Catalog Schema
8.1.7.4 8.1.7.4 8.1.7.4 >= 8.1.7 8.1.7.4 or >= 9.0.1.4
9.0.1 9.0.1 9.0.1 >= 8.1.7 >= RMAN executable
9.2.0 9.2.0 >= 9.0.1.3 and <= Target DB >= 8.1.7 >= RMAN executable
10.1.0 10.1.0 >= 9.0.1.3 and <= Target DB >= 9.0.1 >= RMAN executable
10.2.0 10.2.0 >= 9.0.1.3 and <= Target DB >= 9.0.1 >= RMAN executable
11.1.0 11.1.0 TBD TBD >= RMAN executable
Managing Files in an ASM Environment
C:\> asmcmd -p
You should now see the ASMCMD prompt:
ASMCMD [+]>
The -p option will set your prompt to display the current working directory as part of the
prompt. For example, the ASMCMD prompt changes as we use the cd command to change
the current directory:
ASMCMD [+] > cd +data/prmy/datafile
ASMCMD [+data/prmy/datafile] >
Command Description
cd Changes the current directory to the specified directory
du Displays the total disk space occupied by ASM files in the specified ASM
directory and all its subdirectories, recursively
exit Exits ASMCMD
find Lists the paths of all occurrences of the specified name (with wildcards) under
the specified directory help Displays the syntax and description of ASMCMD commands
ls Lists the contents of an ASM directory, the attributes of the specified file, or the names and attributes of all disk groups
lsct Lists information about current ASM clients
lsdg Lists all disk groups and their attributes
mkalias Creates an alias for a system-generated filename
mkdir Creates ASM directories
pwd Displays the path of the current ASM directory
rm Deletes the specified ASM files or directories
rmalias Deletes the specified alias, retaining the file to which the alias points
md_backup Creates a metadata backup script of mounted disk groups (Oracle Database
11g only)
md_restore Restores a disk group backup (Oracle Database 11g only)
lsdsk Lists the ASM disks (Oracle Database 11g only)
repair Repairs range of physical blocks on the ASM disk (Oracle Database 11g only)
with SQL*Plus, the following query is useful for viewing files within your ASM environment:
SQL> SELECT concat('+'||gname, sys_connect_by_path(aname, '/')) full_alias_path FROM
2 (SELECT g.name gname, a.parent_index pindex, a.name aname,
3 a.reference_index rindex FROM v$asm_alias a, v$asm_diskgroup g
4 WHERE a.group_number = g.group_number)
5 START WITH (mod(pindex, power(2, 24))) = 0
6 CONNECT BY PRIOR rindex = pindex;
Backup Validation with RMAN
You can run the BACKUP ... VALIDATE command to check datafiles for physical and logical corruption, or to confirm that all database files exist in the correct locations. No backup is taken, but all specified files are scanned to verify that they can be backed up. All corruptions are recorded in theV$DATABASE_BLOCK_CORRUPTION view.
The following example shows how to check your entire database and archived redo log files for physical and logical corruption:
BACKUP VALIDATE CHECK LOGICAL DATABASE ARCHIVELOG ALL;
You cannot use the MAXCORRUPT or PROXY parameters with the VALIDATE option.
# mark backup as unavailable in the repository so that RMAN does not attempt to
# restore it unless explicitly specified on the RESTORE command
RMAN> CHANGE BACKUP TAG 'db_archive_1' UNAVAILABLE;
RMAN> SQL 'ALTER DATABASE OPEN';
lunes, 28 de septiembre de 2009
RMAN Tuning
Views for RMAN Performance Tuning
V$RMAN_BACKUP_JOB_DETAILS Reports information about backup jobs
V$BACKUP_ASYNC_IO Displays RMAN asynchronous I/O performance information for currently running and recently completed backup and restore operations
V$BACKUP_SYNC_IO Displays RMAN synchronous I/O performance information for currently running and recently completed backup and restore operations
V$PROCESS Lists currently active processes
V$SESSION Displays session information for current sessions
V$SESSION_LONGOPS Shows progress of RMAN backup, restore, and
recovery operations
V$RECOVERY_PROGRESS Shows progress of RMAN or user-managed recovery operations
V$SESSION_WAIT Displays events or resources for which sessions are
currently waiting
Identifying RMAN Processes
SQL> SELECT b.sid, b.serial#, a.spid, b.client_info
2 FROM v$process a, v$session b
3 WHERE a.addr = b.paddr
4 AND b.client_info LIKE '%rman%';
This output shows that there is currently one RMAN channel allocated:
SID SERIAL# SPID CLIENT_INFO
---------- ---------- ------------ -------------------------
146 29 4376 rman channel=ORA_DISK_1
Measuring Backup Performance
SQL> SELECT session_recid, input_bytes_per_sec_display,
2 output_bytes_per_sec_display,
3 time_taken_display, end_time
4 FROM v$rman_backup_job_details
5 ORDER BY end_time;
Y
ou should see output similar to the following:
SESSION_RECID INPUT_BYTES_PER OUTPUT_BYTES_PE TIME_TAKEN_DISPLAY END_TIME
------------- --------------- --------------- -------------------- ---------
1096 8.60M 7.69M 00:14:25 20-DEC-06
1101 1.88M 1.78M 00:42:03 21-DEC-06
1110 9.59M 8.56M 00:14:56 22-DEC-06
1114 9.75M 8.71M 00:14:52 23-DEC-06
1116 10.73M 9.58M 00:14:31 24-DEC-06
View Name Recovery Catalog View
V$RMAN_BACKUP_SUBJOB_DETAILS RC_RMAN_BACKUP_SUBJOB_DETAILS
V$BACKUP_SET RC_BACKUP_SET
V$BACKUP_SET_DETAILS RC_BACKUP_SET_DETAILS
V$BACKUP_SET_SUMMARY RC_BACKUP_SET_SUMMARY
V$BACKUP_PIECE RC_BACKUP_PIECE
V$BACKUP_PIECE_DETAILS RC_BACKUP_PIECE_DETAILS
V$BACKUP_DATAFILE RC_BACKUP_DATAFILE
V$BACKUP_DATAFILE_DETAILS RC_BACKUP_DATAFILE_DETAILS
V$BACKUP_DATAFILE_SUMMARY RC_BACKUP_DATAFILE_SUMMARY
V$BACKUP_FILES RC_BACKUP_FILES
V$BACKUP_COPY_DETAILS RC_BACKUP_COPY_DETAILS
V$BACKUP_COPY_SUMMARY RC_BACKUP_COPY_SUMMARY
V$BACKUP_REDOLOG RC_BACKUP_REDOLOG
V$BACKUP_ARCHIVELOG_DETAILS RC_BACKUP_ARCHIVELOG_DETAILS
V$BACKUP_ARCHIVELOG_SUMMARY RC_BACKUP_ARCHIVELOG_SUMMARY
V$BACKUP_CONTROLFILE_DETAILS RC_BACKUP_CONTROLFILE_DETAILS
V$BACKUP_CONTROLFILE_SUMMARY RC_BACKUP_CONTROLFILE_SUMMARY
V$BACKUP_SPFILE RC_BACKUP_SPFILE
V$BACKUP_SPFILE_DETAILS RC_BACKUP_SPFILE_DETAILS
V$BACKUP_SPFILE_SUMMARY RC_BACKUP_SPFILE_SUMMARY
Monitoring RMAN Job Progress
SQL>gt; select sid, serial#, sofar, totalwork, opname,
2 round(sofar/totalwork*100,2) "% Complete"
3 from v$session_longops
4 where opname LIKE 'RMAN%'
5 and opname NOT LIKE '%aggregate%'
6 and totalwork != 0
7 and sofar <> totalwork;
SID SERIAL# SOFAR TOTALWORK OPNAME % Complete
---------- ---------- ---------- ---------- ---------------------------------------------------------------- ----------
2838 43105 902382 902956 RMAN: archived log backup 99,94
Oracle also provides a view, V$RECOVERY_PROGRESS, that reports on just the recovery
operations (either RMAN or user-managed). This view is a subview of the V$SESSION_
LONGOPS view. To report on the progress of a recover command, you can run a SQL
query as shown here:
SQL> select type, item, units, sofar, total from v$recovery_progress;
TYPE ITEM UNITS SOFAR TOTAL
--------------- ------------------------- ---------- ---------- ----------
Media Recovery Log Files Files 3 229
Media Recovery Active Apply Rate KB/sec 3425 0
Media Recovery Average Apply Rate KB/sec 3861 0
Media Recovery Redo Applied Megabytes 449 0
Media Recovery Last Applied Redo SCN+Time 1415101 0
Media Recovery Active Time Seconds 81 0
Media Recovery Apply Time per Log Seconds 0 0
Media Recovery Checkpoint Time per Log Seconds 0 0
Media Recovery Elapsed Time Seconds 119 0
The V$SESSION_LONGOPS view contains information about long-running jobs (SQL statements,RMAN operations, and so on) in your database. You can use this view to monitor the progress of RMAN backup, restore, and recovery operations.
select s.client_info,
sl.opname,
sl.message,
sl.sid, sl.serial#, p.spid,
sl.sofar, sl.totalwork,
round(sl.sofar/sl.totalwork*100,2) "% Complete"
from v$session_longops sl, v$session s, v$process p
where p.addr = s.paddr
and sl.sid=s.sid
and sl.serial#=s.serial#
and opname LIKE 'RMAN%'
and opname NOT LIKE '%aggregate%'
and totalwork != 0
and sofar <> totalwork;
If your backup or restore command is interacting with several backup sets, then you may want to report at an aggregate level. To report at the aggregate level, run a query similar to the one shown next:
SQL> select sid, serial#, sofar, totalwork,opname,
2 round(sofar/totalwork*100,2) "% Complete"
3 from v$session_longops
4 where opname LIKE 'RMAN%aggregate%'
5 and totalwork != 0
6 and sofar <> totalwork;
Identifying I/O Bottlenecks
SQL> SELECT sid, serial, filename, type, elapsed_time, effective_bytes_per_second
2 FROM v$backup_async_io
3 WHERE close_time > sysdate – 7;
If you have identified your SID and SERIAL number (see recipe 16-1), you can specifically query for records associated with your current session:
SQL> SELECT filename, sid, serial, close_time, long_waits/io_count as ratio
2 FROM v$backup_async_io
3 WHERE type != 'AGGREGATE'
4 AND SID = &SID
5 AND SERIAL = &SERIAL
6 ORDER BY ratio desc;
Improving Tape I/O Performance
We have two recommendations for improving RMAN’s I/O performance with tape devices:
• Use an incremental backup strategy with block change tracking.
• Adjust multiplexing of backup sets.
The block change tracking feature enables RMAN to quickly identify which blocks have
changed since the last incremental backup. This feature can significantly improve the performance of incremental backups.
Also, consider altering the default multiplexing behavior of RMAN. Setting filesperset high and maxopenfiles low may increase the efficiency of writing to your tape device. You can also use the diskratio parameter to instruct RMAN to balance the load if datafiles are distributed across several different disks. See recipe 16-6 for details on how to adjust the multiplexing of backup sets.
Maximizing Throughput to Backup Device
Solution
You can tune the throughput to backup devices by adjusting RMAN’s level of multiplexing. RMAN multiplexing is controlled by three parameters:
• filesperset
• maxopenfiles
• diskratio
Using filesperset Use the fileperset clause of the backup command to limit the number of datafiles in each backup set. For example, if you wanted to limit the number of files being written to a backup set to only two files, you would use filesperset, as shown here:
RMAN> backup database filesperset 2;
Using maxopenfiles Use the maxopenfiles clause of the configure channel command or the allocate channel command to limit the number of files that can be simultaneously open for reads during a backup. If you want to limit the number of files being read by a channel to two files, use maxopenfiles as follows:
RMAN> configure channel 1 device type disk maxopenfiles 2;
To reset the channel maxopenfiles back to the default setting, use the clear parameter as shown here:
RMAN> configure channel 1 device type disk clear;
Using diskratio The diskratio parameter of the backup command instructs RMAN to read datafiles from a specified number of disks. For example, if you wanted RMAN to include datafiles located on at least four different disks into one backup set, then use diskratio as follows:
RMAN> backup database diskratio 4;
If you specify filesperset, and not diskratio, then diskratio will default to the value of filesperset. The diskratio parameter works only on operating systems that can provide RMAN with information such as disk contention and node affinity.
The value of filesperset specifies the maximum number of files in each backup
set. The default value of filesperset is as follows:
MIN(64, # of files to be backed up divided by the numbers of channels allocated)
The default value of maxopenfiles is as follows:
MIN(8, # files being backed up)
Setting Large Pool Memory Size
Problem
You’re using I/O slaves, and you’re aware that RMAN can take advantage of memory in the large pool when using I/O slaves. You want to ensure that the large pool is sized correctly.
Solution
Use the Automatic Shared Memory Management (ASMM) feature to have Oracle automatically manage the allocation of memory pools. To enable ASMM, do the following:
1. Ensure that the initialization parameter statistics_level is set to TYPICAL (the
default) or ALL.
2. Set sga_target to an appropriate nonzero value for your database not exceeding the
sga_max_size.
3. Set the following initialization parameters to zero:
• shared_pool_size
• large_pool_size
• java_pool_size
• db_cache_size
• streams_pool_size
Once you enable ASMM, Oracle will automatically size and adjust those memory pools
for you. You can set any of these values manually to enforce a minimum amount of memory used for the specified pool.
If you want to manually set the large pool size, here is Oracle’s recommended formula for sizing it:
large_pool_size = num_of_allocated_channels * (16 MB + (4 * size_of_tape_buffer ))
Tuning Media Recovery
Problem
You want to manually adjust the degree of parallelism that Oracle uses for media recovery to match the number of CPUs on your database server.
Solution
Starting with Oracle Database 10g, when you issue an RMAN recover command from either
within RMAN or within SQL*Plus, Oracle’s default behavior is to automatically perform media recovery operations in parallel. However, if you want to override this default behavior, you can use the recover parallel or recover noparallel command. This next line of code instructs
Oracle to spawn four parallel processes to apply redo:
RMAN> recover database parallel 4;
If you don’t want Oracle to recover in parallel, then specify the noparallel clause as shown here:
RMAN> recover database noparallel;
Tuning Crash Recovery
Problem
You want to ensure that your database comes up as efficiently as possible after you issue a shutdown abort command or experience a hard crash. You want to specify a target duration time for any crash recovery that is needed as a result of an instance crash or a shutdown abort command.
Solution
The fast_start_mttr_target initialization parameter allows you to specify a target value in seconds that denotes the amount of time that you want Oracle to take to perform crash recovery.
To determine an appropriate value for this parameter, follow this procedure:
1. Disable the initialization parameters that interfere with fast_start_mttr_target.
2. Determine the lower bound for fast_start_mttr_target.
3. Determine the upper bound for fast_start_mttr_target.
4. Select a value within the upper and lower bounds.
5. Monitor and adjust.
Note Although you can specify a target duration using fast_start_mttr_target, be aware that the database software treats that target as a “best-effort” target. Depending upon the circumstances, the actual time to perform crash recovery might be more or less than the target.
Step 1:Disable Parameters
Ensure that fast_start_io_target, log_checkpoint_interval, and log_checkpoint_timeout are all set to 0. These parameters will interfere with fast_start_mttr_target.
Step 2: Determine the Lower Bound Set fast_start_mttr_target to a value of 1, and then stop and start your database. This example
assumes you are using an spfile; if you aren’t, then you will have to manually modify your init.ora file.
SQL> alter system set fast_start_mttr_target=1;
SQL> shutdown immediate;
SQL> startup;
Immediately query the TARGET_MTTR value from V$INSTANCE_RECOVERY, as shown
here:
SQL> select target_mttr from v$instance_recovery;
TARGET_MTTR
-----------
52
Step 3: Determine the Upper Bound
Set fast_start_mttr_target to a value of 3600, and then stop and start your database. This example assumes you are using an spfile; if you aren’t, then you will have to manually modify your init.ora file.
SQL> alter system set fast_start_mttr_target=3600;
SQL> shutdown immediate;
SQL> startup;
Immediately query the TARGET_MTTR value from V$INSTANCE_RECOVERY, as shown
here:
SQL> select target_mttr from v$instance_recovery;
After your database has experienced a normal amount of activity, you can query
V$MTTR_TARGET_ADVICE as follows:
SQL> SELECT
2 mttr_target_for_estimate, advice_status, estd_cache_writes, estd_total_ios
3 from v$mttr_target_advice
4 order by 1;
The following output shows values of writes and I/O for each estimated value of
fast_start_mttr_target:
MTTR_TARGET_FOR_ESTIMATE ADVIC ESTD_CACHE_WRITES ESTD_TOTAL_IOS
------------------------ ----- ----------------- --------------
52 ON 1811 11030
130 ON 1575 10794
209 ON 1575 10794
288 ON 1575 10794
377 ON 1575 10794
Problem
You’ve noticed that your application performance degrades when the RMAN backups are running. You want to reduce RMAN’s I/O rate so that it spreads out its impact on the system over a period of time.
Solution
Use one of the following to control RMAN’s I/O rate:
• The backup duration ... minimize load command
• The rate clause of the allocate channel or configure channel command
Using backup duration ... minimize load
Use the backup duration ... minimize load command to evenly distribute RMAN I/O
over a period of time. This example shows how to spread the I/O of an RMAN backup over a
45-minute period:
RMAN> backup duration 00:45 minimize load database;
RMAN will report the time taken for the backup operation in the output, as shown in this
snippet:
channel ORA_DISK_1: throttle time: 0:44:43
Finished backup at 10-MAR-07
Using rate
You can also use the rate clause of the allocate channel command or the configure channel command to control RMAN’s I/O rate. This example configures channel 1 to have a maximum read rate of 5MB per second:
RMAN> configure channel 1 device type disk rate=5M;
RMAN {
2> backup duration 1:00 partial minimize load database;
3> backup archivelog all;
3> backup current controlfile;
If you want to force RMAN to include only one datafile per backup set, then you can use the filesperset parameter as shown here
RMAN> backup duration 01:00 minimize load database filesperset 1;
Improving Performance Through Parallelism
Solution
Use the parallel clause of the configure command to instruct RMAN to allocate multiple channels for backup and restore operations. The following command instructs RMAN to automatically allocate four channels for the default disk device:
RMAN> configure device type disk parallelism 4;
RMAN> show device type;
using target database control file instead of recovery catalog
RMAN configuration parameters are:
CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO BACKUPSET PARALLELISM 2;
Managing Backup Performance with MINIMIZE TIME and MINIMIZE LOAD
When using DURATION you can run the backup with the maximum possible performance, or run as slowly as possible while still finishing within the allotted time, to minimize the performance impact of backup tasks. To maximize performance, use the MINIMIZE TIME option with DURATION, as shown in this example:
BACKUP DURATION 4:00 PARTIAL MINIMIZE TIME DATABASE FILESPERSET 1;
To extend the backup to use the full time available, use the MINIMIZE LOAD option, as in this example:
BACKUP DURATION 4:00 PARTIAL MINIMIZE LOAD DATABASE FILESPERSET 1;
RMAN monitors the progress of the running backup, and periodically estimates how long the backup will take to complete at its present rate. If RMAN estimates that the backup will finish before the end of the backup window, it slows down the rate of backup so that the full available duration will be used. This reduces the overhead on the database associated with the backup.
Configuring Backup Optimization
Run the CONFIGURE command to enable and disable backup optimization. Backup optimization skips the backup of files in certain circumstances if the identical file or an identical version of the file has already been backed up. Full details on the backup optimization algorithm are provided in "Backup Optimization".
Note that backup optimization applies only to the following commands:
•BACKUP DATABASE
•BACKUP ARCHIVELOG with ALL or LIKE options
•BACKUP BACKUPSET ALL
You can override optimization at any time by specifying the FORCE option on the BACKUP command. For example, you can run:
BACKUP DATABASE FORCE;
BACKUP ARCHIVELOG ALL FORCE;
By default, backup optimization is configured to OFF. To enable backup optimization, run the following command:
CONFIGURE BACKUP OPTIMIZATION ON;
To disable backup optimization, run the following command:
CONFIGURE BACKUP OPTIMIZATION OFF;
To clear the current backup optimization setting, that is, return backup optimization to its default setting of OFF, run this command:
CONFIGURE BACKUP OPTIMIZATION CLEAR;
Configuring Tablespaces for Exclusion from Whole Database Backups
You can run CONFIGURE EXCLUDE FOR TABLESPACE to exempt the specified tablespace from the BACKUP DATABASE command. The exclusion condition applies to any datafiles that you add to this tablespace in the future.
This tablespace exclusion feature is useful when you do not want to make a specified tablespace part of the regular backup schedule, as in these cases:
•A tablespace is easy to rebuild, so it is more cost-effective to rebuild it than back it up every day.
•A tablespace contains temporary or test data that you do not need to back up.
•A tablespace does not change often and therefore should be backed up on a different schedule from other backups.
For example, you can exclude testing tablespaces cwmlite and example from whole database backups as follows:
CONFIGURE EXCLUDE FOR TABLESPACE cwmlite;
CONFIGURE EXCLUDE FOR TABLESPACE example;
If you run the following command, then RMAN backs up all tablespaces in the database except cwmlite and example:
BACKUP DATABASE;
You can still back up the configured tablespaces by explicitly specifying them in a BACKUP command or by specifying the NOEXCLUDE option on a BACKUP DATABASE command. For example, you can enter one of the following commands:
# backs up the whole database, including cwmlite and example
BACKUP DATABASE NOEXCLUDE;
BACKUP TABLESPACE cwmlite, example; # backs up only cwmlite and example
You can disable the exclusion feature for cwmlite and example as follows:
CONFIGURE EXCLUDE FOR TABLESPACE cwmlite CLEAR;
CONFIGURE EXCLUDE FOR TABLESPACE example CLEAR;
RMAN includes these tablespaces in future whole database backups.
Showing the Tablespaces Excluded from Backups
SHOW EXCLUDE shows how you have used the CONFIGURE EXCLUDE command to exclude tablespaces from whole database backups.
After connecting to the target database and recovery catalog (if you use one), run the SHOW EXCLUDE command. For example, enter:
RMAN> SHOW EXCLUDE; # shows the CONFIGURE EXCLUDE setting
Sample output for SHOW EXCLUDE follows:
RMAN configuration parameters are:
CONFIGURE EXCLUDE FOR TABLESPACE 'OLD_ACCOUNTS';
V$RMAN_BACKUP_JOB_DETAILS Reports information about backup jobs
V$BACKUP_ASYNC_IO Displays RMAN asynchronous I/O performance information for currently running and recently completed backup and restore operations
V$BACKUP_SYNC_IO Displays RMAN synchronous I/O performance information for currently running and recently completed backup and restore operations
V$PROCESS Lists currently active processes
V$SESSION Displays session information for current sessions
V$SESSION_LONGOPS Shows progress of RMAN backup, restore, and
recovery operations
V$RECOVERY_PROGRESS Shows progress of RMAN or user-managed recovery operations
V$SESSION_WAIT Displays events or resources for which sessions are
currently waiting
Identifying RMAN Processes
SQL> SELECT b.sid, b.serial#, a.spid, b.client_info
2 FROM v$process a, v$session b
3 WHERE a.addr = b.paddr
4 AND b.client_info LIKE '%rman%';
This output shows that there is currently one RMAN channel allocated:
SID SERIAL# SPID CLIENT_INFO
---------- ---------- ------------ -------------------------
146 29 4376 rman channel=ORA_DISK_1
Measuring Backup Performance
SQL> SELECT session_recid, input_bytes_per_sec_display,
2 output_bytes_per_sec_display,
3 time_taken_display, end_time
4 FROM v$rman_backup_job_details
5 ORDER BY end_time;
Y
ou should see output similar to the following:
SESSION_RECID INPUT_BYTES_PER OUTPUT_BYTES_PE TIME_TAKEN_DISPLAY END_TIME
------------- --------------- --------------- -------------------- ---------
1096 8.60M 7.69M 00:14:25 20-DEC-06
1101 1.88M 1.78M 00:42:03 21-DEC-06
1110 9.59M 8.56M 00:14:56 22-DEC-06
1114 9.75M 8.71M 00:14:52 23-DEC-06
1116 10.73M 9.58M 00:14:31 24-DEC-06
View Name Recovery Catalog View
V$RMAN_BACKUP_SUBJOB_DETAILS RC_RMAN_BACKUP_SUBJOB_DETAILS
V$BACKUP_SET RC_BACKUP_SET
V$BACKUP_SET_DETAILS RC_BACKUP_SET_DETAILS
V$BACKUP_SET_SUMMARY RC_BACKUP_SET_SUMMARY
V$BACKUP_PIECE RC_BACKUP_PIECE
V$BACKUP_PIECE_DETAILS RC_BACKUP_PIECE_DETAILS
V$BACKUP_DATAFILE RC_BACKUP_DATAFILE
V$BACKUP_DATAFILE_DETAILS RC_BACKUP_DATAFILE_DETAILS
V$BACKUP_DATAFILE_SUMMARY RC_BACKUP_DATAFILE_SUMMARY
V$BACKUP_FILES RC_BACKUP_FILES
V$BACKUP_COPY_DETAILS RC_BACKUP_COPY_DETAILS
V$BACKUP_COPY_SUMMARY RC_BACKUP_COPY_SUMMARY
V$BACKUP_REDOLOG RC_BACKUP_REDOLOG
V$BACKUP_ARCHIVELOG_DETAILS RC_BACKUP_ARCHIVELOG_DETAILS
V$BACKUP_ARCHIVELOG_SUMMARY RC_BACKUP_ARCHIVELOG_SUMMARY
V$BACKUP_CONTROLFILE_DETAILS RC_BACKUP_CONTROLFILE_DETAILS
V$BACKUP_CONTROLFILE_SUMMARY RC_BACKUP_CONTROLFILE_SUMMARY
V$BACKUP_SPFILE RC_BACKUP_SPFILE
V$BACKUP_SPFILE_DETAILS RC_BACKUP_SPFILE_DETAILS
V$BACKUP_SPFILE_SUMMARY RC_BACKUP_SPFILE_SUMMARY
Monitoring RMAN Job Progress
SQL>gt; select sid, serial#, sofar, totalwork, opname,
2 round(sofar/totalwork*100,2) "% Complete"
3 from v$session_longops
4 where opname LIKE 'RMAN%'
5 and opname NOT LIKE '%aggregate%'
6 and totalwork != 0
7 and sofar <> totalwork;
SID SERIAL# SOFAR TOTALWORK OPNAME % Complete
---------- ---------- ---------- ---------- ---------------------------------------------------------------- ----------
2838 43105 902382 902956 RMAN: archived log backup 99,94
Oracle also provides a view, V$RECOVERY_PROGRESS, that reports on just the recovery
operations (either RMAN or user-managed). This view is a subview of the V$SESSION_
LONGOPS view. To report on the progress of a recover command, you can run a SQL
query as shown here:
SQL> select type, item, units, sofar, total from v$recovery_progress;
TYPE ITEM UNITS SOFAR TOTAL
--------------- ------------------------- ---------- ---------- ----------
Media Recovery Log Files Files 3 229
Media Recovery Active Apply Rate KB/sec 3425 0
Media Recovery Average Apply Rate KB/sec 3861 0
Media Recovery Redo Applied Megabytes 449 0
Media Recovery Last Applied Redo SCN+Time 1415101 0
Media Recovery Active Time Seconds 81 0
Media Recovery Apply Time per Log Seconds 0 0
Media Recovery Checkpoint Time per Log Seconds 0 0
Media Recovery Elapsed Time Seconds 119 0
The V$SESSION_LONGOPS view contains information about long-running jobs (SQL statements,RMAN operations, and so on) in your database. You can use this view to monitor the progress of RMAN backup, restore, and recovery operations.
select s.client_info,
sl.opname,
sl.message,
sl.sid, sl.serial#, p.spid,
sl.sofar, sl.totalwork,
round(sl.sofar/sl.totalwork*100,2) "% Complete"
from v$session_longops sl, v$session s, v$process p
where p.addr = s.paddr
and sl.sid=s.sid
and sl.serial#=s.serial#
and opname LIKE 'RMAN%'
and opname NOT LIKE '%aggregate%'
and totalwork != 0
and sofar <> totalwork;
If your backup or restore command is interacting with several backup sets, then you may want to report at an aggregate level. To report at the aggregate level, run a query similar to the one shown next:
SQL> select sid, serial#, sofar, totalwork,opname,
2 round(sofar/totalwork*100,2) "% Complete"
3 from v$session_longops
4 where opname LIKE 'RMAN%aggregate%'
5 and totalwork != 0
6 and sofar <> totalwork;
Identifying I/O Bottlenecks
SQL> SELECT sid, serial, filename, type, elapsed_time, effective_bytes_per_second
2 FROM v$backup_async_io
3 WHERE close_time > sysdate – 7;
If you have identified your SID and SERIAL number (see recipe 16-1), you can specifically query for records associated with your current session:
SQL> SELECT filename, sid, serial, close_time, long_waits/io_count as ratio
2 FROM v$backup_async_io
3 WHERE type != 'AGGREGATE'
4 AND SID = &SID
5 AND SERIAL = &SERIAL
6 ORDER BY ratio desc;
Improving Tape I/O Performance
We have two recommendations for improving RMAN’s I/O performance with tape devices:
• Use an incremental backup strategy with block change tracking.
• Adjust multiplexing of backup sets.
The block change tracking feature enables RMAN to quickly identify which blocks have
changed since the last incremental backup. This feature can significantly improve the performance of incremental backups.
Also, consider altering the default multiplexing behavior of RMAN. Setting filesperset high and maxopenfiles low may increase the efficiency of writing to your tape device. You can also use the diskratio parameter to instruct RMAN to balance the load if datafiles are distributed across several different disks. See recipe 16-6 for details on how to adjust the multiplexing of backup sets.
Maximizing Throughput to Backup Device
Solution
You can tune the throughput to backup devices by adjusting RMAN’s level of multiplexing. RMAN multiplexing is controlled by three parameters:
• filesperset
• maxopenfiles
• diskratio
Using filesperset Use the fileperset clause of the backup command to limit the number of datafiles in each backup set. For example, if you wanted to limit the number of files being written to a backup set to only two files, you would use filesperset, as shown here:
RMAN> backup database filesperset 2;
Using maxopenfiles Use the maxopenfiles clause of the configure channel command or the allocate channel command to limit the number of files that can be simultaneously open for reads during a backup. If you want to limit the number of files being read by a channel to two files, use maxopenfiles as follows:
RMAN> configure channel 1 device type disk maxopenfiles 2;
To reset the channel maxopenfiles back to the default setting, use the clear parameter as shown here:
RMAN> configure channel 1 device type disk clear;
Using diskratio The diskratio parameter of the backup command instructs RMAN to read datafiles from a specified number of disks. For example, if you wanted RMAN to include datafiles located on at least four different disks into one backup set, then use diskratio as follows:
RMAN> backup database diskratio 4;
If you specify filesperset, and not diskratio, then diskratio will default to the value of filesperset. The diskratio parameter works only on operating systems that can provide RMAN with information such as disk contention and node affinity.
The value of filesperset specifies the maximum number of files in each backup
set. The default value of filesperset is as follows:
MIN(64, # of files to be backed up divided by the numbers of channels allocated)
The default value of maxopenfiles is as follows:
MIN(8, # files being backed up)
Setting Large Pool Memory Size
Problem
You’re using I/O slaves, and you’re aware that RMAN can take advantage of memory in the large pool when using I/O slaves. You want to ensure that the large pool is sized correctly.
Solution
Use the Automatic Shared Memory Management (ASMM) feature to have Oracle automatically manage the allocation of memory pools. To enable ASMM, do the following:
1. Ensure that the initialization parameter statistics_level is set to TYPICAL (the
default) or ALL.
2. Set sga_target to an appropriate nonzero value for your database not exceeding the
sga_max_size.
3. Set the following initialization parameters to zero:
• shared_pool_size
• large_pool_size
• java_pool_size
• db_cache_size
• streams_pool_size
Once you enable ASMM, Oracle will automatically size and adjust those memory pools
for you. You can set any of these values manually to enforce a minimum amount of memory used for the specified pool.
If you want to manually set the large pool size, here is Oracle’s recommended formula for sizing it:
large_pool_size = num_of_allocated_channels * (16 MB + (4 * size_of_tape_buffer ))
Tuning Media Recovery
Problem
You want to manually adjust the degree of parallelism that Oracle uses for media recovery to match the number of CPUs on your database server.
Solution
Starting with Oracle Database 10g, when you issue an RMAN recover command from either
within RMAN or within SQL*Plus, Oracle’s default behavior is to automatically perform media recovery operations in parallel. However, if you want to override this default behavior, you can use the recover parallel or recover noparallel command. This next line of code instructs
Oracle to spawn four parallel processes to apply redo:
RMAN> recover database parallel 4;
If you don’t want Oracle to recover in parallel, then specify the noparallel clause as shown here:
RMAN> recover database noparallel;
Tuning Crash Recovery
Problem
You want to ensure that your database comes up as efficiently as possible after you issue a shutdown abort command or experience a hard crash. You want to specify a target duration time for any crash recovery that is needed as a result of an instance crash or a shutdown abort command.
Solution
The fast_start_mttr_target initialization parameter allows you to specify a target value in seconds that denotes the amount of time that you want Oracle to take to perform crash recovery.
To determine an appropriate value for this parameter, follow this procedure:
1. Disable the initialization parameters that interfere with fast_start_mttr_target.
2. Determine the lower bound for fast_start_mttr_target.
3. Determine the upper bound for fast_start_mttr_target.
4. Select a value within the upper and lower bounds.
5. Monitor and adjust.
Note Although you can specify a target duration using fast_start_mttr_target, be aware that the database software treats that target as a “best-effort” target. Depending upon the circumstances, the actual time to perform crash recovery might be more or less than the target.
Step 1:Disable Parameters
Ensure that fast_start_io_target, log_checkpoint_interval, and log_checkpoint_timeout are all set to 0. These parameters will interfere with fast_start_mttr_target.
Step 2: Determine the Lower Bound Set fast_start_mttr_target to a value of 1, and then stop and start your database. This example
assumes you are using an spfile; if you aren’t, then you will have to manually modify your init.ora file.
SQL> alter system set fast_start_mttr_target=1;
SQL> shutdown immediate;
SQL> startup;
Immediately query the TARGET_MTTR value from V$INSTANCE_RECOVERY, as shown
here:
SQL> select target_mttr from v$instance_recovery;
TARGET_MTTR
-----------
52
Step 3: Determine the Upper Bound
Set fast_start_mttr_target to a value of 3600, and then stop and start your database. This example assumes you are using an spfile; if you aren’t, then you will have to manually modify your init.ora file.
SQL> alter system set fast_start_mttr_target=3600;
SQL> shutdown immediate;
SQL> startup;
Immediately query the TARGET_MTTR value from V$INSTANCE_RECOVERY, as shown
here:
SQL> select target_mttr from v$instance_recovery;
After your database has experienced a normal amount of activity, you can query
V$MTTR_TARGET_ADVICE as follows:
SQL> SELECT
2 mttr_target_for_estimate, advice_status, estd_cache_writes, estd_total_ios
3 from v$mttr_target_advice
4 order by 1;
The following output shows values of writes and I/O for each estimated value of
fast_start_mttr_target:
MTTR_TARGET_FOR_ESTIMATE ADVIC ESTD_CACHE_WRITES ESTD_TOTAL_IOS
------------------------ ----- ----------------- --------------
52 ON 1811 11030
130 ON 1575 10794
209 ON 1575 10794
288 ON 1575 10794
377 ON 1575 10794
Problem
You’ve noticed that your application performance degrades when the RMAN backups are running. You want to reduce RMAN’s I/O rate so that it spreads out its impact on the system over a period of time.
Solution
Use one of the following to control RMAN’s I/O rate:
• The backup duration ... minimize load command
• The rate clause of the allocate channel or configure channel command
Using backup duration ... minimize load
Use the backup duration ... minimize load command to evenly distribute RMAN I/O
over a period of time. This example shows how to spread the I/O of an RMAN backup over a
45-minute period:
RMAN> backup duration 00:45 minimize load database;
RMAN will report the time taken for the backup operation in the output, as shown in this
snippet:
channel ORA_DISK_1: throttle time: 0:44:43
Finished backup at 10-MAR-07
# Backup completo con impacto mínimo en la BD y una duración máxima de 30 minutosBACKUP AS BACKUPSET DURATION 00:30 MINIMIZE LOAD PARTIAL DATABASE;# Backup completo minimizando el tiempo de ejecucion y una duración máximo de 15 minutos# Hemos eliminado PARTIAL para que en caso de que no se complete, se considere FALLIDOBACKUP AS BACKUPSET DURATION 00:15 MINIMIZE TIME DATABASE;Using rate
You can also use the rate clause of the allocate channel command or the configure channel command to control RMAN’s I/O rate. This example configures channel 1 to have a maximum read rate of 5MB per second:
RMAN> configure channel 1 device type disk rate=5M;
RMAN {
2> backup duration 1:00 partial minimize load database;
3> backup archivelog all;
3> backup current controlfile;
If you want to force RMAN to include only one datafile per backup set, then you can use the filesperset parameter as shown here
RMAN> backup duration 01:00 minimize load database filesperset 1;
Improving Performance Through Parallelism
Solution
Use the parallel clause of the configure command to instruct RMAN to allocate multiple channels for backup and restore operations. The following command instructs RMAN to automatically allocate four channels for the default disk device:
RMAN> configure device type disk parallelism 4;
RMAN> show device type;
using target database control file instead of recovery catalog
RMAN configuration parameters are:
CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO BACKUPSET PARALLELISM 2;
Managing Backup Performance with MINIMIZE TIME and MINIMIZE LOAD
When using DURATION you can run the backup with the maximum possible performance, or run as slowly as possible while still finishing within the allotted time, to minimize the performance impact of backup tasks. To maximize performance, use the MINIMIZE TIME option with DURATION, as shown in this example:
BACKUP DURATION 4:00 PARTIAL MINIMIZE TIME DATABASE FILESPERSET 1;
To extend the backup to use the full time available, use the MINIMIZE LOAD option, as in this example:
BACKUP DURATION 4:00 PARTIAL MINIMIZE LOAD DATABASE FILESPERSET 1;
RMAN monitors the progress of the running backup, and periodically estimates how long the backup will take to complete at its present rate. If RMAN estimates that the backup will finish before the end of the backup window, it slows down the rate of backup so that the full available duration will be used. This reduces the overhead on the database associated with the backup.
Configuring Backup Optimization
Run the CONFIGURE command to enable and disable backup optimization. Backup optimization skips the backup of files in certain circumstances if the identical file or an identical version of the file has already been backed up. Full details on the backup optimization algorithm are provided in "Backup Optimization".
Note that backup optimization applies only to the following commands:
•BACKUP DATABASE
•BACKUP ARCHIVELOG with ALL or LIKE options
•BACKUP BACKUPSET ALL
You can override optimization at any time by specifying the FORCE option on the BACKUP command. For example, you can run:
BACKUP DATABASE FORCE;
BACKUP ARCHIVELOG ALL FORCE;
By default, backup optimization is configured to OFF. To enable backup optimization, run the following command:
CONFIGURE BACKUP OPTIMIZATION ON;
To disable backup optimization, run the following command:
CONFIGURE BACKUP OPTIMIZATION OFF;
To clear the current backup optimization setting, that is, return backup optimization to its default setting of OFF, run this command:
CONFIGURE BACKUP OPTIMIZATION CLEAR;
Configuring Tablespaces for Exclusion from Whole Database Backups
You can run CONFIGURE EXCLUDE FOR TABLESPACE to exempt the specified tablespace from the BACKUP DATABASE command. The exclusion condition applies to any datafiles that you add to this tablespace in the future.
This tablespace exclusion feature is useful when you do not want to make a specified tablespace part of the regular backup schedule, as in these cases:
•A tablespace is easy to rebuild, so it is more cost-effective to rebuild it than back it up every day.
•A tablespace contains temporary or test data that you do not need to back up.
•A tablespace does not change often and therefore should be backed up on a different schedule from other backups.
For example, you can exclude testing tablespaces cwmlite and example from whole database backups as follows:
CONFIGURE EXCLUDE FOR TABLESPACE cwmlite;
CONFIGURE EXCLUDE FOR TABLESPACE example;
If you run the following command, then RMAN backs up all tablespaces in the database except cwmlite and example:
BACKUP DATABASE;
You can still back up the configured tablespaces by explicitly specifying them in a BACKUP command or by specifying the NOEXCLUDE option on a BACKUP DATABASE command. For example, you can enter one of the following commands:
# backs up the whole database, including cwmlite and example
BACKUP DATABASE NOEXCLUDE;
BACKUP TABLESPACE cwmlite, example; # backs up only cwmlite and example
You can disable the exclusion feature for cwmlite and example as follows:
CONFIGURE EXCLUDE FOR TABLESPACE cwmlite CLEAR;
CONFIGURE EXCLUDE FOR TABLESPACE example CLEAR;
RMAN includes these tablespaces in future whole database backups.
Showing the Tablespaces Excluded from Backups
SHOW EXCLUDE shows how you have used the CONFIGURE EXCLUDE command to exclude tablespaces from whole database backups.
After connecting to the target database and recovery catalog (if you use one), run the SHOW EXCLUDE command. For example, enter:
RMAN> SHOW EXCLUDE; # shows the CONFIGURE EXCLUDE setting
Sample output for SHOW EXCLUDE follows:
RMAN configuration parameters are:
CONFIGURE EXCLUDE FOR TABLESPACE 'OLD_ACCOUNTS';
Transporting Tablespaces on the Same OS Platform
In the following example, the transportable
tablespace set consists of two tablespaces—test1 and test2. Use the transport_set_check procedure of the DBMS_TTS package to verify whether the two tablespaces are selfcontained, as shown here:
SQL> execute sys.dbms_tts.transport_set_check('test1, test2',TRUE);
PL/SQL procedure successfully completed.
RMAN> transport tablespace test1,test2
2> tablespace destination '/u05/app/oracle/transportdest'
3> auxiliary destination '/u05/app/oracle/auxdest';
You can also use the transport tablespace command to perform a tablespace transport
to a past point in time. Simply add the unitl scn clause to the transport tablespace command, as shown here:
RMAN> transport tablespace test1,test2
2> tablespace destination '/u05/app/oracle/transportdest'
3> auxiliary destination '/u05/app/oracle/auxdest'
4> until SCN 259386;
Transporting Tablespaces Across Different Operating
System Platforms
To find out the endian formats of the two platforms, use the following query:
SQL> select platform_name, endian_format from
2* v$transportable_platform;
1. Place the tablespaces you want to transport in read-only mode:
SQL> alter tablespace myspace read only;
Tablespace altered.
SQL>
2. Use the convert tablespace command to convert the source (HP-UX in this case)
datafiles in the transportable tablespace set to the target (Linux in this case) platform:
RMAN> convert tablespace myspace
2> to platform 'Linux IA (32-bit)'
3> format='/tmp/dba/%U';
3. Verify that you have the two datafiles that are part of the myspace tablespace in the
/tmp/dba directory:
$ ls –altr /tmp/dba
data_D-PASU_I-877170026_TS-MYSPACE_FNO-64_02i6g1vs
data_D-PASU_I-877170026_TS-MYSPACE_FNO-66_03i6g200
4. Use the Data Pump Export utility to create the export dump file with the metadata for the myspace tablespace:
$ expdp pasowner/orbiter1 directory=direct1 transport_tablespaces=myspace
5. Move both the converted datafiles from step 2 and the export dump file
(myspace.dmp) from step 3 to the target host, as shown here:
$ rcp data_D-PASU_I-877170026_TS-MYSPACE_FNO-64_02i6g1vs prod1:/tmp/dba
$ rcp data_D-PASU_I-877170026_TS-MYSPACE_FNO-66_03i6g200 prod1:/tmp/dba
$ rcp myspace.dmp prod1:/tmp/dba
6. Import the tablespace metadata for the transported tablespaces into the target database,
as shown here:
$ impdp system/sammyy1 directory=data_dump_dir2
dumpfile='myspace2.dmp'
transport_datafiles='/u05/app/oracle/data_D-PASU_I-877170026_TS-YSPACE_FNO-➥
64_02i6g1v,
'/u05/app/oracle/ data_D-PASU_I-877170026_TS-MYSPACE_FNO-66_03i6g200'
RMAN> connect target /
RMAN> convert datafile=
'/u01/transport_solaris/sales/sales01.dbf',
'/u01/transport_solaris/sales/sales02.dbf'
from platform 'Solaris[tm] OE (32-bit)'
db_file_name_convert
'/u01/transport_solaris/sales','/u05/newdb/sales';
Transporting an Entire Database to a Different Platform
Problem
You want to transport an entire Oracle database to another host that is using a different operating system platform.
Solution
Use the convert database command to move an Oracle database from one platform to
another. The only requirement is that the two platforms share an identical endian format. You can perform the convert database operation on the source platform or the destination platform.
The following are the steps to transport an Oracle database from a Windows XP platform
to the Linux platform:
1. Make sure the source database is eligible for transporting to the destination operating system platform by executing the dbms_tdb.check_db procedure, as shown here. The source database is running on a Windows XP platform, and the target database is running on a Linux 32-bit platform.
SQL> connect sys/sammyy1 as sysdba
Connected.
SQL> set serveroutput on
SQL> declare
2> db_ready boolean;
3> begin
4> db_ready := dbms_tdb.check_db('Linux IA(32-bit)',
dbms_tdb.skip_readonly);
5* end;
SQL> /
PL/SQL procedure successfully completed.
SQL>
If you see the message “PL/SQL procedure successfully completed,” as is the case in
this example, it means you can migrate from the specified operating system platform
to the destination platform.
2. Since external tables aren’t automatically transported to the target platform, you must invoke the dbms_tdb.check_db procedure again to get a list of the external tables, which you can then use to re-create those tables on the destination platform after the database transportation.
SQL> declare
2> external boolean;
3> begin
4> external :=dbms_tdb.check_external;
5* end;
SQL> /
PL/SQL procedure successfully completed.
SQL>
3. Put the target database in the read-only mode after shutting it down first and restarting it in mount state:
SQL> connect sys/sammyy1 as sysdba
Connected.
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>
SQL> startup mount;
ORACLE instance started.
Total System Global Area 612368384 bytes
Fixed Size 1250452 bytes
Variable Size 180357996 bytes
Database Buffers 427819008 bytes
Redo Buffers 2940928 bytes
Database mounted.
SQL> alter database open read only;
Database altered.
SQL>
RMAN> convert database new database 'mydb'
2> transport script 'c:\temp\mydb_script'
3> to platform 'Linux IA (32-bit)'
4> db_file_name_convert 'c:\oracle\product\11.1.0\oradata\nick\'
'c:\temp\';
5. On the target platform, first set the ORACLE_SID environment variable pointing to the
new database:
$ export ORACLE_SID=newdb
The ORACLE_HOME environment variable must point to the same version of Oracle
software as on the source platform.
Execute the mydb_script file after logging in to SQL*Plus as the user sys:
$ sqlplus /nolog
SQL> connect sys/sammyy1 as sysdgba
Connected to an idle instance.
SQL> @mydb
ORACLE instance started.
Total System Global Area 243269632 bytes
Fixed Size 1218748 bytes
Variable Size 79693636 bytes
Database Buffers 159383552 bytes
Redo Buffers 2973696 bytes
Control file created.
Database altered.
Tablespace altered.
6. Check to make sure there are no invalidated objects left in the database:
SQL> select count(*) from dba_objects where
status='INVALID';
Transporting a Database by Converting Datafiles on the
Target Platform
1. Make sure the source database is eligible for transporting to the destination operating system platform by executing the dbms_tdb.check_db procedure, as shown here. The source database is running on a Windows XP platform, and the target database is running on a Linux 32-bit platform.
SQL> connect sys/sammyy1 as sysdba
Connected.
SQL> set serveroutput on
SQL> declare
2> db_ready boolean;
3> begin
4> db_ready := dbms_tdb.check_db('Linux IA(32-bit)',
5> dbms_tdb.skip_readonly);
6* end;
SQL> /
PL/SQL procedure successfully completed.
SQL>
2. Since external tables aren’t automatically transported to the target platform, you must invoke the dbms_tdb.check_external procedure again to get a list of the external tables that you can then use to re-create those tables on the destination platform after the database transportation.
SQL> declare
2> external boolean;
3> begin
4> external :=dbms_tdb.check_external;
5> end;
6> /
PL/SQL procedure successfully completed.
3. Put the target database in read-only mode after shutting it down first and restarting it in the mount state:
SQL> connect sys/sammyy1 as sysdba
Connected.
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>
SQL> startup mount;
ORACLE instance started.
Total System Global Area 612368384 bytes
Fixed Size 1250452 bytes
Variable Size 180357996 bytes
Database Buffers 427819008 bytes
Redo Buffers 2940928 bytes
Database mounted.
SQL> alter database open read only;
Database altered.
SQL>
4. Execute the convert database command on the source database platform with the on
target platform clause, as shown here:
RMAN> convert database on target platform
2> convert script 'c:\temp\convert\convertscript.rman'
3> transport script 'c:\temp\convert\transportscript.sql'
4> new database 'youdb'
5> format 'c:\temp\convert\%U'
6> ;
5. Copy the datafiles of the source database while that database is still in the read-only mode and move them to the target database platform.
6. Run the convertscript.rman script on the target database after first transporting all the source database files to the target platform. Once you copy the necessary files, you can put the source database in a read-write mode again.
7. You use a separate convert datafile command for each datafile you need to convert
from the source to the target platform. The format parameter of the convert datafile
command specifies the location of each file on the target platform.
$ rman target / cmdfile=CONVERTSCRIPT.RMAN
8. Make the necessary changes in the pfile and the transportscript.sql script produced
by the convert database script. Execute the transportscript.sql script from SQL*Plus
to produce a new database instance, and create the new database (named youdb in
the example):
$ sqlplus /nolog
SQL> @transportscript
tablespace set consists of two tablespaces—test1 and test2. Use the transport_set_check procedure of the DBMS_TTS package to verify whether the two tablespaces are selfcontained, as shown here:
SQL> execute sys.dbms_tts.transport_set_check('test1, test2',TRUE);
PL/SQL procedure successfully completed.
RMAN> transport tablespace test1,test2
2> tablespace destination '/u05/app/oracle/transportdest'
3> auxiliary destination '/u05/app/oracle/auxdest';
You can also use the transport tablespace command to perform a tablespace transport
to a past point in time. Simply add the unitl scn clause to the transport tablespace command, as shown here:
RMAN> transport tablespace test1,test2
2> tablespace destination '/u05/app/oracle/transportdest'
3> auxiliary destination '/u05/app/oracle/auxdest'
4> until SCN 259386;
Transporting Tablespaces Across Different Operating
System Platforms
To find out the endian formats of the two platforms, use the following query:
SQL> select platform_name, endian_format from
2* v$transportable_platform;
1. Place the tablespaces you want to transport in read-only mode:
SQL> alter tablespace myspace read only;
Tablespace altered.
SQL>
2. Use the convert tablespace command to convert the source (HP-UX in this case)
datafiles in the transportable tablespace set to the target (Linux in this case) platform:
RMAN> convert tablespace myspace
2> to platform 'Linux IA (32-bit)'
3> format='/tmp/dba/%U';
3. Verify that you have the two datafiles that are part of the myspace tablespace in the
/tmp/dba directory:
$ ls –altr /tmp/dba
data_D-PASU_I-877170026_TS-MYSPACE_FNO-64_02i6g1vs
data_D-PASU_I-877170026_TS-MYSPACE_FNO-66_03i6g200
4. Use the Data Pump Export utility to create the export dump file with the metadata for the myspace tablespace:
$ expdp pasowner/orbiter1 directory=direct1 transport_tablespaces=myspace
5. Move both the converted datafiles from step 2 and the export dump file
(myspace.dmp) from step 3 to the target host, as shown here:
$ rcp data_D-PASU_I-877170026_TS-MYSPACE_FNO-64_02i6g1vs prod1:/tmp/dba
$ rcp data_D-PASU_I-877170026_TS-MYSPACE_FNO-66_03i6g200 prod1:/tmp/dba
$ rcp myspace.dmp prod1:/tmp/dba
6. Import the tablespace metadata for the transported tablespaces into the target database,
as shown here:
$ impdp system/sammyy1 directory=data_dump_dir2
dumpfile='myspace2.dmp'
transport_datafiles='/u05/app/oracle/data_D-PASU_I-877170026_TS-YSPACE_FNO-➥
64_02i6g1v,
'/u05/app/oracle/ data_D-PASU_I-877170026_TS-MYSPACE_FNO-66_03i6g200'
RMAN> connect target /
RMAN> convert datafile=
'/u01/transport_solaris/sales/sales01.dbf',
'/u01/transport_solaris/sales/sales02.dbf'
from platform 'Solaris[tm] OE (32-bit)'
db_file_name_convert
'/u01/transport_solaris/sales','/u05/newdb/sales';
Transporting an Entire Database to a Different Platform
Problem
You want to transport an entire Oracle database to another host that is using a different operating system platform.
Solution
Use the convert database command to move an Oracle database from one platform to
another. The only requirement is that the two platforms share an identical endian format. You can perform the convert database operation on the source platform or the destination platform.
The following are the steps to transport an Oracle database from a Windows XP platform
to the Linux platform:
1. Make sure the source database is eligible for transporting to the destination operating system platform by executing the dbms_tdb.check_db procedure, as shown here. The source database is running on a Windows XP platform, and the target database is running on a Linux 32-bit platform.
SQL> connect sys/sammyy1 as sysdba
Connected.
SQL> set serveroutput on
SQL> declare
2> db_ready boolean;
3> begin
4> db_ready := dbms_tdb.check_db('Linux IA(32-bit)',
dbms_tdb.skip_readonly);
5* end;
SQL> /
PL/SQL procedure successfully completed.
SQL>
If you see the message “PL/SQL procedure successfully completed,” as is the case in
this example, it means you can migrate from the specified operating system platform
to the destination platform.
2. Since external tables aren’t automatically transported to the target platform, you must invoke the dbms_tdb.check_db procedure again to get a list of the external tables, which you can then use to re-create those tables on the destination platform after the database transportation.
SQL> declare
2> external boolean;
3> begin
4> external :=dbms_tdb.check_external;
5* end;
SQL> /
PL/SQL procedure successfully completed.
SQL>
3. Put the target database in the read-only mode after shutting it down first and restarting it in mount state:
SQL> connect sys/sammyy1 as sysdba
Connected.
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>
SQL> startup mount;
ORACLE instance started.
Total System Global Area 612368384 bytes
Fixed Size 1250452 bytes
Variable Size 180357996 bytes
Database Buffers 427819008 bytes
Redo Buffers 2940928 bytes
Database mounted.
SQL> alter database open read only;
Database altered.
SQL>
RMAN> convert database new database 'mydb'
2> transport script 'c:\temp\mydb_script'
3> to platform 'Linux IA (32-bit)'
4> db_file_name_convert 'c:\oracle\product\11.1.0\oradata\nick\'
'c:\temp\';
5. On the target platform, first set the ORACLE_SID environment variable pointing to the
new database:
$ export ORACLE_SID=newdb
The ORACLE_HOME environment variable must point to the same version of Oracle
software as on the source platform.
Execute the mydb_script file after logging in to SQL*Plus as the user sys:
$ sqlplus /nolog
SQL> connect sys/sammyy1 as sysdgba
Connected to an idle instance.
SQL> @mydb
ORACLE instance started.
Total System Global Area 243269632 bytes
Fixed Size 1218748 bytes
Variable Size 79693636 bytes
Database Buffers 159383552 bytes
Redo Buffers 2973696 bytes
Control file created.
Database altered.
Tablespace altered.
6. Check to make sure there are no invalidated objects left in the database:
SQL> select count(*) from dba_objects where
status='INVALID';
Transporting a Database by Converting Datafiles on the
Target Platform
1. Make sure the source database is eligible for transporting to the destination operating system platform by executing the dbms_tdb.check_db procedure, as shown here. The source database is running on a Windows XP platform, and the target database is running on a Linux 32-bit platform.
SQL> connect sys/sammyy1 as sysdba
Connected.
SQL> set serveroutput on
SQL> declare
2> db_ready boolean;
3> begin
4> db_ready := dbms_tdb.check_db('Linux IA(32-bit)',
5> dbms_tdb.skip_readonly);
6* end;
SQL> /
PL/SQL procedure successfully completed.
SQL>
2. Since external tables aren’t automatically transported to the target platform, you must invoke the dbms_tdb.check_external procedure again to get a list of the external tables that you can then use to re-create those tables on the destination platform after the database transportation.
SQL> declare
2> external boolean;
3> begin
4> external :=dbms_tdb.check_external;
5> end;
6> /
PL/SQL procedure successfully completed.
3. Put the target database in read-only mode after shutting it down first and restarting it in the mount state:
SQL> connect sys/sammyy1 as sysdba
Connected.
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>
SQL> startup mount;
ORACLE instance started.
Total System Global Area 612368384 bytes
Fixed Size 1250452 bytes
Variable Size 180357996 bytes
Database Buffers 427819008 bytes
Redo Buffers 2940928 bytes
Database mounted.
SQL> alter database open read only;
Database altered.
SQL>
4. Execute the convert database command on the source database platform with the on
target platform clause, as shown here:
RMAN> convert database on target platform
2> convert script 'c:\temp\convert\convertscript.rman'
3> transport script 'c:\temp\convert\transportscript.sql'
4> new database 'youdb'
5> format 'c:\temp\convert\%U'
6> ;
5. Copy the datafiles of the source database while that database is still in the read-only mode and move them to the target database platform.
6. Run the convertscript.rman script on the target database after first transporting all the source database files to the target platform. Once you copy the necessary files, you can put the source database in a read-write mode again.
7. You use a separate convert datafile command for each datafile you need to convert
from the source to the target platform. The format parameter of the convert datafile
command specifies the location of each file on the target platform.
$ rman target / cmdfile=CONVERTSCRIPT.RMAN
8. Make the necessary changes in the pfile and the transportscript.sql script produced
by the convert database script. Execute the transportscript.sql script from SQL*Plus
to produce a new database instance, and create the new database (named youdb in
the example):
$ sqlplus /nolog
SQL> @transportscript
RMAN Duplicating Databases and Transporting Data
Renaming Files in a Duplicate Database
db_file_name_convert and the log_file_name_convert
Once you specify the spfile parameter during the database duplication, you can provide your list of initialization parameters and the values for them through the parameter_value_convert clause and the set clause. It’s easiest to use the parameter_value_convert clause in the duplicate database command to specify all parameters that specify a directory path. You can specify all such directory-related parameter values through the parameter_value_convert parameter, except for the db_file_name_convert and log_file_name_convert parameters.
Here’s an example showing how to use the parameter_value_convert clause and the set clause to specify various initialization parameter values for the duplicate instance right when you issue the duplicate database command:
duplicate target database
to dupdb
from active database spfile
parameter_value_convert '/a01', '/a20'
set sga_max_size = 800m
set sga_target = 700m
set log_file_name_convert = '/a01','/a20',
db_file_name_convert '/a01','/a20';
RMAN> run
{
set newname for datafile 1 to '/u01/app/oracle/testdata/file1.dbf';
set newname for datafile 2 to '/u01/app/oracle/testdata/file2.dbf';
...
duplicate target database to newdb nofilenamecheck;
}
Creating a Duplicate Database on the Same Host
1. Back up the target database as follows:
RMAN> connect target /
RMAN> backup database plus archivelog;
You’ll use these backups as the source for the database duplication later. Of course, if you already have made backups of the source database, you can skip this step.
2. Use a dedicated listener configuration for RMAN by making the following additions to your listener.ora file:
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = prod1)
(ORACLE_HOME = /u01/app/oracle/product/11g/)
(SID_NAME =prod1)
)
(SID_DESC =
(GLOBAL_DBNAME = test1)
(ORACLE_HOME = /u01/app/oracle/product/11g/)
(SID_NAME =test1)
)
)
3. Add the following information to the tnsnames.ora file, located in the
$ORACLE_HOME/network/admin directory:
test1 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = prod1)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = test1)
)
)
4. Create the init.ora file for the new duplicate database, test1. During the database duplication process, RMAN will create the control files, the data files, and the redo log files for the duplicate database with the filename structure you provide through the db_file_name_convert and log_file_name_convert initialization parameters. The database duplication process will create a control file for the new duplicate database in the location specified by the control_files initialization parameter.
db_name = test1
db_block_size = 8192
compatible = 11.1.0.1.0
remote_login_passwordfile = exclusive
control_files = ('/u01/app/oracle/test1/control01.ctl',
'/u01/app/oracle/test1/control02.ctl')
db_file_name_convert = ('/u01/app/oracle/oradata/prod1',
'/u05/app/oracle/oradata/test1')
log_file_name_convert = ('/u01/app/oracle/oradata/prod1',
'/u05/app/oracle/oradata/test1')
5. Start the new auxiliary database (duplicate database) instance. You must start the
new instance in nomount mode since you don’t have a control file for this new
database yet.
$ export ORACLE_SID=test1
$ sqlplus /nolog
SQL> connect / as sysdba
Connected to an idle instance
SQL> startup nomount pfile=$ORACLE_HOME/dbs/inittest1.ora
Oracle Instance started.
Total System Global Area 113246208 bytes
Fixed Size 1218004 bytes
Variable Size 58722860 bytes
6. Start RMAN, and connect to the target database after making sure you first set the
ORACLE_SID environmental variable to the source database, prod1. Note that the target
database can be mounted or open.
$ rman
Recovery Manager: Release 11.1.0.1.0 - Beta on Sat Jun 9 14:03:42 2007
Copyright (c) 1982, 2005, Oracle. All rights reserved.
RMAN> connect target
connected to target database: prod1 (DBID=2561840016)
7. Connect to the duplicate database using the keyword auxiliary through a SQL*Net
connection:
RMAN> connect auxiliary sys/@test1
connected to auxiliary database: test1 (not mounted)
RMAN>
Database Buffers 50331648 bytes
Redo Buffers 2973696 bytes
SQL> exit
8. Issue the duplicate target database command to start the database duplication
process:
RMAN> duplicate target database to test1;
SQL> select parameter, value from nls_database_parameters
where parameter in
('NLS_LANGUAGE','NLS_TERRITORY','NLS_CHARACTERSET'
,'NLS_NCHAR_CHARACTERSET');
Duplicating a Database Without Any RMAN Backups
1. Use a dedicated listener configuration for RMAN by making the following additions to
your listener.ora file:
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = prod1)
(ORACLE_HOME = /u01/app/oracle/product/11g/)
(SID_NAME =prod1)
)
(SID_DESC =
(GLOBAL_DBNAME = test1)
(ORACLE_HOME = /u01/app/oracle/product/11g/)
(SID_NAME =test1)
)
)
2. Add the following information to the tnsnames.ora file, located in the
$ORACLE_HOME/network/admin directory:
test1=
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = prod1)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = test1)
)
)
3. Create a password file for connecting remotely to the duplicate database with the
sysdba privilege. This is because when you perform active database duplication, the
target database instance must connect directly to the auxiliary database instance. Note
that the password file connection requires the same sysdba password as that of the
source database. Create the password file manually with the orapwd utility, as shown
here, with just a single password to start the auxiliary instance:
$ orapwd password= file=orapwtest1 entries=20
4. Start the auxiliary database (duplicate database) instance. You must start the new
instance in nomount mode since you don’t have a control file for this new database yet.
$ export ORACLE_SID=test1
$ sqlplus /nolog
SQL> connect / as sysdba
Connected to an idle instance
SQL> startup nomount
Oracle Instance started.
Total System Global Area 113246208 bytes
Fixed Size 218004 bytes
Variable Size 58722860 bytes
Database Buffers 50331648 bytes
Redo Buffers 2973696 bytes
SQL> exit
$rman target sys/sammyy1@eleven
RMAN> connect auxiliary sys/sammyy1@auxdb
connected to auxiliary database: AUXDB (not mounted)
RMAN> duplicate target database
2> to auxdb
3> from active database
4> spfile
5> parameter_value_convert =
'/u01/app/oracle/eleven/eleven','/u01/app/oracle/eleven/auxdb'
6> set log_file_name_convert =
'/u05/app/oracle/eleven/eleven','/u05/app/oracle/eleven/auxdb'
7> db_file_name_convert =
'/u05/app/oracle/eleven/eleven','/u05/app/oracle/eleven/auxdb';
RMAN> duplicate database
to newdb
from active database
spfile
nofilenamecheck;
If you’d rather create a standby database instead of a duplicate database, all you have to do is replace the to auxdb part of the duplicate database command with the for standby clause, as shown here:
RMAN> duplicate target database
for standby
from active database
spfile
It’s easy to duplicate a non-ASM file based database to an ASM file system–based database. Here we’ll show you a simple example to demonstrate how to do this. First create an ASM disk group, named +DISK1. Here’s the database duplication command to create an ASM file system–based duplicate database:
RMAN> duplicate target database
to newdb
from active database
spfile
parameter_value_convert
'/u01/app/oracle/oradata/sourcedb/','+DISK1'
set db_create_file_dest = +DISK1;
Creating a Duplicate Database on a Remote Host with the
Same File Structure
Solution
Let’s call our primary database PROD, the duplicate database AUX, and the RMAN catalog
database CATDB (the catalog is purely optional). Here are the steps to duplicate the primary
database on a different server:
1. Back up the primary database. You must take a full backup and include all the archive logs as well as the control file.
[oracle@linux] rman target=/ catalog rman/rman@catdb
RMAN> run {
allocate channel d1 type disk;
backup format '/backups/PROD/df_t%t_s%s_p%p' database;
backup format '/backups/PROD/al_t%t_s%s_p%p' archivelog all;
release channel d1;
}
2. Ensure that the source database backups are available for the duplication process. You can get a complete list of the necessary backups by running the list backup command, as shown here:
RMAN>list backup;
3. Create the necessary directories for the duplicate database, and then create the initialization
parameter file for the duplicate database, as shown in the following example:
audit_file_dest =/oradata/AUX/adump
background_dump_dest =/oradata/AUX/bdump
core_dump_dest =/oradata/AUX/cdump
user_dump_dest =/oradata/AUX/udump
db_name ="AUX"
instance_name =AUX
control_files =('/oradata/AUX/control01.ctl',
'/oradata/AUX/control02.ctl','/oradata/AUX/control03.ctl')
4. Start up the auxiliary instance in nomount mode:
$ export ORACLE_SID=AUX
$ sqlplus '/as sysdba'
SQL> startup nomount;
5. Check the Oracle Net connections to the primary database and the recovery catalog.
The production database can be open or in a mounted state. The catalog database, if
you’re using it, must be open. Make sure you can connect to the primary database on
server A from the target server. Make sure you can also connect to the RMAN catalog
from the target server..
$ sqlplus 'sys/oracle@PROD as sysdba'
$ rman catalog rman/rman@catdb # not mandatory
$ export ORACLE_SID=AUX
$ rman target sys/sys@PROD catalog rman/rman@catdb auxiliary /
RMAN> duplicate target database to AUX
nofilenamecheck;
SQL> select DF.TOTAL/1048576 "DataFile Size Mb",
LOG.TOTAL/1048576 "Redo Log Size Mb",
CONTROL.TOTAL/1048576 "Control File Size Mb",
(DF.TOTAL + LOG.TOTAL + CONTROL.TOTAL)/1048576 "Total Size Mb" from dual,
(select sum(a.bytes) TOTAL from dba_data_files a) DF,
(select sum(b.bytes) TOTAL from v$log b) LOG,
(select sum((cffsz+1)*cfbsz) TOTAL from x$kcccf c) CONTROL;
DataFile Size Mb Redo Log Size Mb Control File Size Mb Total Size Mb
---------------- ---------------- -------------------- -------------
900 150 20.34375 1070.34375
Duplicating a Database with Several Directories
Problem
You want to duplicate a source database with data spread out over several directories.
Solution
If the source database files are spread over multiple directories, you must use the set newname parameter instead of the db_file_name_convert parameter to rename the files in the duplicate database.
The following example shows how to create a duplicate database when the target database uses several different directories:
RMAN> run
{set newname for datafile 1 to '/u01/app/oracle/testdata/system01.dbf';
set newname for datafile 2 to '/u01/app/oracle/testdata/sysaux01.dbf';
set newname for datafile 3 to '/u01/app/oracle/testdata/data01.dbf';
set newname for datafile 4 to '/u01/app/oracle/testdata/index01.dbf';
set newname for datafile 5 to '/u01/app/oracle/testdata/undotbs01.dbf';
duplicate target database to newdb
logfile
group 1 ('/u01/app/oracle/testdata/logs/redo01a.log',
('/u01/app/oracle/testdata/logs/redo01b.log') size 10m reuse,
group 2 ('/u01/app/oracle/testdata/logs/redo02a.log',
('/u01/app/oracle/testdata/logs/redo02b.log') size 10m reuse;
}
Creating a Standby Database on a New Host
1. Perform a full backup of the primary database, including all the archive logs and the current control file.
2. Calculate the disk space necessary for the standby database by summing up the size of all the datafiles in the database.
3. Ensure there is enough space on the target host to accommodate the standby database by using an operating system command such as df –kh.
4. Back up the target database as shown here with the 'backup current controlfile for
standby format' command:
RMAN> run {
allocate channel d1 type disk;
backup format '/backups/PROD/df_t%t_s%s_p%p' database;
sql 'alter system archive log current';
backup format '/backups/PROD/al_t%t_s%s_p%p' archivelog all;
backup current controlfile for standby format '/backups/PROD/sb_t%t_s%s_p%p';
release channel d1;
}
5. Copy the backups from Host A to Host B to make them available to the standby creation process. Make sure you place the backups in identically named directories on
Host B. For example, if your source backup files are in /backups/PROD, those backup
files must be copied to the /backups/PROD directory on Host B. If you decide to place
them in a different directory, as explained at the beginning of this chapter, you must run the catalog command ("catalog start with") to update the source
database control file with the location of the backups. For the catalog command to
work, make sure you have the different directory structure on the source database
as well. You must also move the archive log backups to the target server. If you’re performing a point-in-time recovery, you may need only some of the archived redo logs:
RMAN> list backup;
List of Backup Sets
6. Create an initialization file (init.ora) for the standby database in the $ORACLE_HOME/dbs directory. Use the primary database’s initialization file as the source for the initialization
parameter settings:
audit_file_dest =/apps/oracle/admin/PROD/adump
background_dump_dest =/apps/oracle/admin/PROD/bdump
core_dump_dest =/apps/oracle/admin/PROD/cdump
user_dump_dest =/apps/oracle/admin/PROD/udump
db_name ="PROD"
instance_name =PROD
# Set the following to the location of the standby clone control file.
control_files=('/u01/PROD/control01.ctl','/u02/PROD/control02.ctl',
'/u03/PROD/control03.ctl')
# Set the following for the from and to location for all data files / redo
# logs to be cloned. This is set if the location differs from Primary.
db_file_name_convert =("/u01/oradata/PROD","/u02/oradata/PROD")
log_file_name_convert =("/u01/oradata/PROD","/u02/oradata/PROD")
#Set the following to the same as the production target
undo_management =AUTO
undo_retention =10800
undo_tablespace =UNDOTBS1
db_block_size = 8192
compatible = 11.1.0.1.0
7. Run the following command on the standby database server to start the auxiliary
instance in nomount state:
$ export ORACLE_SID=AUX
$ sqlplus '/ as sysdba'
SQL> startup nomount;
8. Test the SQL*Net connections to the primary database and the RMAN catalog. The
production database must be open or mounted, and the recovery catalog must be
open. Run the following commands on the standby database server:
$ sqlplus 'sys/oracle@prod1 as sysdba'
$ sqlplus rman/rman@catdb
Test that you’re connecting to the correct SID/service_name and the hostname by executing
the tnsping command for both the prod and rman connections.
9. Connect to the production database (target) and the auxiliary instance, and run the
RMAN duplicate command for the standby database, as shown here (again, you’ll be
running these commands on the standby database server):
$ export ORACLE_SID=PROD
$ rman target sys/sys@PROD auxiliary /
RMAN> run {
allocate channel C1 device type disk;
allocate auxiliary channel C2 device type disk;
duplicate target database for standby nofilenamecheck;
}
Duplicating a Database to a Past Point in Time
RMAN> connect target sys/@targdb
RMAN> connect auxiliary sys/ RMAN> duplicate target database
to dupdb
spfile
nofilenamecheck
until time 'sysdate-1';
run
{
allocate channel C1 device type disk;
allocate auxiliary channel C2 device type disk
set until time "to_date('July 16 2007 12:00:00','Mon DD YYYY HH24:MI:SS')";
duplicate target database to aux;
}
Skipping Tablespaces During Database Duplication
run
{
allocate channel C1 device type disk;
allocate auxiliary channel C2 device type disk;
duplicate database to aux
skip tablespace users, tools;
}
Duplicating a Database with a Specific Backup Tag
ProblemYou want to specify a particular backup tag during the duplication of a database.
Solution
You can “force” RMAN to use a specific backup during a database duplication process by simply making other backups unavailable. Here are the steps to follow:
1. Use the list backup of database command to find out the primary key of the backup
set you plan to use in the duplication process:
RMAN> list backup of database;
2. Make all the backup sets except the one you choose unavailable to RMAN during the
database duplication process by using the following command for each of the backups
you want to make inaccessible to RMAN:
RMAN> change backupset unavailable;
3. Follow the steps in recipe 15-2 or recipe 15-3 to duplicate the source database.
4. Once the database duplication is finished, make all the backups available to RMAN
again by issuing the following command for each of the backup sets you made unavailable
prior to the database duplication:
RMAN> change backupset available;
All the backup sets are once again “available” for use by RMAN.
RMAN> connect target /
RMAN> connect catalog rman/cat@catdb
RMAN> connect auxiliary sys/sammyy1@dupdb
RMAN> run {
configure auxname for datafile 1 to '/oradata1/system01.dbf';
configure auxname for datafile 2 to '/oradata2/sysaux01.dbf';
configure auxname for datafile 3 to '/oradata3/undotbs01.dbf';
configure auxname for datafile 4 to '/oradata4/drsys01';
configure auxname for datafile 5 to '/oradata5/example01.dbf';
configure auxname for datafile 6 to '/oradata6/indx01.dbf';
configure auxname for datafile 7 to '/oradata7/users01.dbf';
}
Synchronize the duplicate database with the source database by periodically executing
the duplicate target database command to re-create the duplicate database. For example:
RMAN> connect target /
RMAN> connect catalog rman/cat@catdb
RMAN> connect auxiliary sys/sammyy1@dupdb
RMAN> duplicate target database to dupdb
logfile
group 1 ('/duplogs/redo01a.log',
'/duplogs/redo01b.log') size 200k reuse,
group 2 ('/duplogs/redo02a.log',
'/duplogs/redo02b.log') size 200k reuse;
db_file_name_convert and the log_file_name_convert
Once you specify the spfile parameter during the database duplication, you can provide your list of initialization parameters and the values for them through the parameter_value_convert clause and the set clause. It’s easiest to use the parameter_value_convert clause in the duplicate database command to specify all parameters that specify a directory path. You can specify all such directory-related parameter values through the parameter_value_convert parameter, except for the db_file_name_convert and log_file_name_convert parameters.
Here’s an example showing how to use the parameter_value_convert clause and the set clause to specify various initialization parameter values for the duplicate instance right when you issue the duplicate database command:
duplicate target database
to dupdb
from active database spfile
parameter_value_convert '/a01', '/a20'
set sga_max_size = 800m
set sga_target = 700m
set log_file_name_convert = '/a01','/a20',
db_file_name_convert '/a01','/a20';
RMAN> run
{
set newname for datafile 1 to '/u01/app/oracle/testdata/file1.dbf';
set newname for datafile 2 to '/u01/app/oracle/testdata/file2.dbf';
...
duplicate target database to newdb nofilenamecheck;
}
Creating a Duplicate Database on the Same Host
1. Back up the target database as follows:
RMAN> connect target /
RMAN> backup database plus archivelog;
You’ll use these backups as the source for the database duplication later. Of course, if you already have made backups of the source database, you can skip this step.
2. Use a dedicated listener configuration for RMAN by making the following additions to your listener.ora file:
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = prod1)
(ORACLE_HOME = /u01/app/oracle/product/11g/)
(SID_NAME =prod1)
)
(SID_DESC =
(GLOBAL_DBNAME = test1)
(ORACLE_HOME = /u01/app/oracle/product/11g/)
(SID_NAME =test1)
)
)
3. Add the following information to the tnsnames.ora file, located in the
$ORACLE_HOME/network/admin directory:
test1 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = prod1)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = test1)
)
)
4. Create the init.ora file for the new duplicate database, test1. During the database duplication process, RMAN will create the control files, the data files, and the redo log files for the duplicate database with the filename structure you provide through the db_file_name_convert and log_file_name_convert initialization parameters. The database duplication process will create a control file for the new duplicate database in the location specified by the control_files initialization parameter.
db_name = test1
db_block_size = 8192
compatible = 11.1.0.1.0
remote_login_passwordfile = exclusive
control_files = ('/u01/app/oracle/test1/control01.ctl',
'/u01/app/oracle/test1/control02.ctl')
db_file_name_convert = ('/u01/app/oracle/oradata/prod1',
'/u05/app/oracle/oradata/test1')
log_file_name_convert = ('/u01/app/oracle/oradata/prod1',
'/u05/app/oracle/oradata/test1')
5. Start the new auxiliary database (duplicate database) instance. You must start the
new instance in nomount mode since you don’t have a control file for this new
database yet.
$ export ORACLE_SID=test1
$ sqlplus /nolog
SQL> connect / as sysdba
Connected to an idle instance
SQL> startup nomount pfile=$ORACLE_HOME/dbs/inittest1.ora
Oracle Instance started.
Total System Global Area 113246208 bytes
Fixed Size 1218004 bytes
Variable Size 58722860 bytes
6. Start RMAN, and connect to the target database after making sure you first set the
ORACLE_SID environmental variable to the source database, prod1. Note that the target
database can be mounted or open.
$ rman
Recovery Manager: Release 11.1.0.1.0 - Beta on Sat Jun 9 14:03:42 2007
Copyright (c) 1982, 2005, Oracle. All rights reserved.
RMAN> connect target
connected to target database: prod1 (DBID=2561840016)
7. Connect to the duplicate database using the keyword auxiliary through a SQL*Net
connection:
RMAN> connect auxiliary sys/
connected to auxiliary database: test1 (not mounted)
RMAN>
Database Buffers 50331648 bytes
Redo Buffers 2973696 bytes
SQL> exit
8. Issue the duplicate target database command to start the database duplication
process:
RMAN> duplicate target database to test1;
SQL> select parameter, value from nls_database_parameters
where parameter in
('NLS_LANGUAGE','NLS_TERRITORY','NLS_CHARACTERSET'
,'NLS_NCHAR_CHARACTERSET');
Duplicating a Database Without Any RMAN Backups
1. Use a dedicated listener configuration for RMAN by making the following additions to
your listener.ora file:
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = prod1)
(ORACLE_HOME = /u01/app/oracle/product/11g/)
(SID_NAME =prod1)
)
(SID_DESC =
(GLOBAL_DBNAME = test1)
(ORACLE_HOME = /u01/app/oracle/product/11g/)
(SID_NAME =test1)
)
)
2. Add the following information to the tnsnames.ora file, located in the
$ORACLE_HOME/network/admin directory:
test1=
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = prod1)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = test1)
)
)
3. Create a password file for connecting remotely to the duplicate database with the
sysdba privilege. This is because when you perform active database duplication, the
target database instance must connect directly to the auxiliary database instance. Note
that the password file connection requires the same sysdba password as that of the
source database. Create the password file manually with the orapwd utility, as shown
here, with just a single password to start the auxiliary instance:
$ orapwd password=
4. Start the auxiliary database (duplicate database) instance. You must start the new
instance in nomount mode since you don’t have a control file for this new database yet.
$ export ORACLE_SID=test1
$ sqlplus /nolog
SQL> connect / as sysdba
Connected to an idle instance
SQL> startup nomount
Oracle Instance started.
Total System Global Area 113246208 bytes
Fixed Size 218004 bytes
Variable Size 58722860 bytes
Database Buffers 50331648 bytes
Redo Buffers 2973696 bytes
SQL> exit
$rman target sys/sammyy1@eleven
RMAN> connect auxiliary sys/sammyy1@auxdb
connected to auxiliary database: AUXDB (not mounted)
RMAN> duplicate target database
2> to auxdb
3> from active database
4> spfile
5> parameter_value_convert =
'/u01/app/oracle/eleven/eleven','/u01/app/oracle/eleven/auxdb'
6> set log_file_name_convert =
'/u05/app/oracle/eleven/eleven','/u05/app/oracle/eleven/auxdb'
7> db_file_name_convert =
'/u05/app/oracle/eleven/eleven','/u05/app/oracle/eleven/auxdb';
RMAN> duplicate database
to newdb
from active database
spfile
nofilenamecheck;
If you’d rather create a standby database instead of a duplicate database, all you have to do is replace the to auxdb part of the duplicate database command with the for standby clause, as shown here:
RMAN> duplicate target database
for standby
from active database
spfile
It’s easy to duplicate a non-ASM file based database to an ASM file system–based database. Here we’ll show you a simple example to demonstrate how to do this. First create an ASM disk group, named +DISK1. Here’s the database duplication command to create an ASM file system–based duplicate database:
RMAN> duplicate target database
to newdb
from active database
spfile
parameter_value_convert
'/u01/app/oracle/oradata/sourcedb/','+DISK1'
set db_create_file_dest = +DISK1;
Creating a Duplicate Database on a Remote Host with the
Same File Structure
Solution
Let’s call our primary database PROD, the duplicate database AUX, and the RMAN catalog
database CATDB (the catalog is purely optional). Here are the steps to duplicate the primary
database on a different server:
1. Back up the primary database. You must take a full backup and include all the archive logs as well as the control file.
[oracle@linux] rman target=/ catalog rman/rman@catdb
RMAN> run {
allocate channel d1 type disk;
backup format '/backups/PROD/df_t%t_s%s_p%p' database;
backup format '/backups/PROD/al_t%t_s%s_p%p' archivelog all;
release channel d1;
}
2. Ensure that the source database backups are available for the duplication process. You can get a complete list of the necessary backups by running the list backup command, as shown here:
RMAN>list backup;
3. Create the necessary directories for the duplicate database, and then create the initialization
parameter file for the duplicate database, as shown in the following example:
audit_file_dest =/oradata/AUX/adump
background_dump_dest =/oradata/AUX/bdump
core_dump_dest =/oradata/AUX/cdump
user_dump_dest =/oradata/AUX/udump
db_name ="AUX"
instance_name =AUX
control_files =('/oradata/AUX/control01.ctl',
'/oradata/AUX/control02.ctl','/oradata/AUX/control03.ctl')
4. Start up the auxiliary instance in nomount mode:
$ export ORACLE_SID=AUX
$ sqlplus '/as sysdba'
SQL> startup nomount;
5. Check the Oracle Net connections to the primary database and the recovery catalog.
The production database can be open or in a mounted state. The catalog database, if
you’re using it, must be open. Make sure you can connect to the primary database on
server A from the target server. Make sure you can also connect to the RMAN catalog
from the target server..
$ sqlplus 'sys/oracle@PROD as sysdba'
$ rman catalog rman/rman@catdb # not mandatory
$ export ORACLE_SID=AUX
$ rman target sys/sys@PROD catalog rman/rman@catdb auxiliary /
RMAN> duplicate target database to AUX
nofilenamecheck;
SQL> select DF.TOTAL/1048576 "DataFile Size Mb",
LOG.TOTAL/1048576 "Redo Log Size Mb",
CONTROL.TOTAL/1048576 "Control File Size Mb",
(DF.TOTAL + LOG.TOTAL + CONTROL.TOTAL)/1048576 "Total Size Mb" from dual,
(select sum(a.bytes) TOTAL from dba_data_files a) DF,
(select sum(b.bytes) TOTAL from v$log b) LOG,
(select sum((cffsz+1)*cfbsz) TOTAL from x$kcccf c) CONTROL;
DataFile Size Mb Redo Log Size Mb Control File Size Mb Total Size Mb
---------------- ---------------- -------------------- -------------
900 150 20.34375 1070.34375
Duplicating a Database with Several Directories
Problem
You want to duplicate a source database with data spread out over several directories.
Solution
If the source database files are spread over multiple directories, you must use the set newname parameter instead of the db_file_name_convert parameter to rename the files in the duplicate database.
The following example shows how to create a duplicate database when the target database uses several different directories:
RMAN> run
{set newname for datafile 1 to '/u01/app/oracle/testdata/system01.dbf';
set newname for datafile 2 to '/u01/app/oracle/testdata/sysaux01.dbf';
set newname for datafile 3 to '/u01/app/oracle/testdata/data01.dbf';
set newname for datafile 4 to '/u01/app/oracle/testdata/index01.dbf';
set newname for datafile 5 to '/u01/app/oracle/testdata/undotbs01.dbf';
duplicate target database to newdb
logfile
group 1 ('/u01/app/oracle/testdata/logs/redo01a.log',
('/u01/app/oracle/testdata/logs/redo01b.log') size 10m reuse,
group 2 ('/u01/app/oracle/testdata/logs/redo02a.log',
('/u01/app/oracle/testdata/logs/redo02b.log') size 10m reuse;
}
Creating a Standby Database on a New Host
1. Perform a full backup of the primary database, including all the archive logs and the current control file.
2. Calculate the disk space necessary for the standby database by summing up the size of all the datafiles in the database.
3. Ensure there is enough space on the target host to accommodate the standby database by using an operating system command such as df –kh.
4. Back up the target database as shown here with the 'backup current controlfile for
standby format' command:
RMAN> run {
allocate channel d1 type disk;
backup format '/backups/PROD/df_t%t_s%s_p%p' database;
sql 'alter system archive log current';
backup format '/backups/PROD/al_t%t_s%s_p%p' archivelog all;
backup current controlfile for standby format '/backups/PROD/sb_t%t_s%s_p%p';
release channel d1;
}
5. Copy the backups from Host A to Host B to make them available to the standby creation process. Make sure you place the backups in identically named directories on
Host B. For example, if your source backup files are in /backups/PROD, those backup
files must be copied to the /backups/PROD directory on Host B. If you decide to place
them in a different directory, as explained at the beginning of this chapter, you must run the catalog command ("catalog start with
database control file with the location of the backups. For the catalog command to
work, make sure you have the different directory structure on the source database
as well. You must also move the archive log backups to the target server. If you’re performing a point-in-time recovery, you may need only some of the archived redo logs:
RMAN> list backup;
List of Backup Sets
6. Create an initialization file (init.ora) for the standby database in the $ORACLE_HOME/dbs directory. Use the primary database’s initialization file as the source for the initialization
parameter settings:
audit_file_dest =/apps/oracle/admin/PROD/adump
background_dump_dest =/apps/oracle/admin/PROD/bdump
core_dump_dest =/apps/oracle/admin/PROD/cdump
user_dump_dest =/apps/oracle/admin/PROD/udump
db_name ="PROD"
instance_name =PROD
# Set the following to the location of the standby clone control file.
control_files=('/u01/PROD/control01.ctl','/u02/PROD/control02.ctl',
'/u03/PROD/control03.ctl')
# Set the following for the from and to location for all data files / redo
# logs to be cloned. This is set if the location differs from Primary.
db_file_name_convert =("/u01/oradata/PROD","/u02/oradata/PROD")
log_file_name_convert =("/u01/oradata/PROD","/u02/oradata/PROD")
#Set the following to the same as the production target
undo_management =AUTO
undo_retention =10800
undo_tablespace =UNDOTBS1
db_block_size = 8192
compatible = 11.1.0.1.0
7. Run the following command on the standby database server to start the auxiliary
instance in nomount state:
$ export ORACLE_SID=AUX
$ sqlplus '/ as sysdba'
SQL> startup nomount;
8. Test the SQL*Net connections to the primary database and the RMAN catalog. The
production database must be open or mounted, and the recovery catalog must be
open. Run the following commands on the standby database server:
$ sqlplus 'sys/oracle@prod1 as sysdba'
$ sqlplus rman/rman@catdb
Test that you’re connecting to the correct SID/service_name and the hostname by executing
the tnsping command for both the prod and rman connections.
9. Connect to the production database (target) and the auxiliary instance, and run the
RMAN duplicate command for the standby database, as shown here (again, you’ll be
running these commands on the standby database server):
$ export ORACLE_SID=PROD
$ rman target sys/sys@PROD auxiliary /
RMAN> run {
allocate channel C1 device type disk;
allocate auxiliary channel C2 device type disk;
duplicate target database for standby nofilenamecheck;
}
Duplicating a Database to a Past Point in Time
RMAN> connect target sys/
RMAN> connect auxiliary sys/
to dupdb
spfile
nofilenamecheck
until time 'sysdate-1';
run
{
allocate channel C1 device type disk;
allocate auxiliary channel C2 device type disk
set until time "to_date('July 16 2007 12:00:00','Mon DD YYYY HH24:MI:SS')";
duplicate target database to aux;
}
Skipping Tablespaces During Database Duplication
run
{
allocate channel C1 device type disk;
allocate auxiliary channel C2 device type disk;
duplicate database to aux
skip tablespace users, tools;
}
Duplicating a Database with a Specific Backup Tag
ProblemYou want to specify a particular backup tag during the duplication of a database.
Solution
You can “force” RMAN to use a specific backup during a database duplication process by simply making other backups unavailable. Here are the steps to follow:
1. Use the list backup of database command to find out the primary key of the backup
set you plan to use in the duplication process:
RMAN> list backup of database;
2. Make all the backup sets except the one you choose unavailable to RMAN during the
database duplication process by using the following command for each of the backups
you want to make inaccessible to RMAN:
RMAN> change backupset
3. Follow the steps in recipe 15-2 or recipe 15-3 to duplicate the source database.
4. Once the database duplication is finished, make all the backups available to RMAN
again by issuing the following command for each of the backup sets you made unavailable
prior to the database duplication:
RMAN> change backupset
All the backup sets are once again “available” for use by RMAN.
RMAN> connect target /
RMAN> connect catalog rman/cat@catdb
RMAN> connect auxiliary sys/sammyy1@dupdb
RMAN> run {
configure auxname for datafile 1 to '/oradata1/system01.dbf';
configure auxname for datafile 2 to '/oradata2/sysaux01.dbf';
configure auxname for datafile 3 to '/oradata3/undotbs01.dbf';
configure auxname for datafile 4 to '/oradata4/drsys01';
configure auxname for datafile 5 to '/oradata5/example01.dbf';
configure auxname for datafile 6 to '/oradata6/indx01.dbf';
configure auxname for datafile 7 to '/oradata7/users01.dbf';
}
Synchronize the duplicate database with the source database by periodically executing
the duplicate target database command to re-create the duplicate database. For example:
RMAN> connect target /
RMAN> connect catalog rman/cat@catdb
RMAN> connect auxiliary sys/sammyy1@dupdb
RMAN> duplicate target database to dupdb
logfile
group 1 ('/duplogs/redo01a.log',
'/duplogs/redo01b.log') size 200k reuse,
group 2 ('/duplogs/redo02a.log',
'/duplogs/redo02b.log') size 200k reuse;
Suscribirse a:
Entradas (Atom)
