jueves, 15 de octubre de 2009

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;

No hay comentarios: