Use this way: different machine recovery, similar to the hand-built library : The difference is that, before the data is there, instead of using a backup script before the backup file is the use of control
Heterogeneous recovery scenarios: A: G dozens of test library, you need to complete the test data replication, migration to another database, using RMAN and Data Pump / exp, has obvious advantages, the use of this scene quickly erected
B: disaster recovery Walkthrough: backup, restore, by way of different machines, verify the availability of backup
Backup distinguished : A full backup archive log transfer transmission + + + Control parameter file + password file password file
B All libraries 0 backup + incremental backup ----
The experimental tests: A / B A- 0 all equipment used: a manner similar to the full backup, restore different machines
BA experiment is successful , delete the backup of all data and information, and start again, using a full backup +1 level incremental backup test
Heterogeneous recovery process:
Source:
Experimental environment: 10.2.0.4
Full backup: parameter files - Control files - data files - archive log files
Transmission : backup information from the source - to copy - the destination end
End goal:
Creating preparation: create the appropriate directory: password file: change the name of the parameter file
Modify the parameter file:
Parameter file is used to start Nomount state
RMAN: control files backup, restore restored to the parameters specified by the control file file name, path
RMAN: Register backup piece: data files, archive log files Registration
RMAN: restore application to back up, restore data files, set to modify the data file directory structure
RMAN: recover Application log recovery: open to open the database
Test : A
# Enable Block Tracking, this incremental backup
# Enable archive mode:
archive log list
Database log mode No Archive Mode
[oracle@jiu ~]$ mkdir -p ./rman/arch
[oracle@jiu ~]$ mkdir -p ./rman/data
SQL> alter system set log_archive_dest_1="location=/home/oracle/rman/arch";
SQL> shutdown immediate;
SQL> startup mount;
SQL> alter database archivelog;
SQL> alter database open;
# Enable Block Tracking
SQL> select status,filename from v$block_change_tracking; DISABLED
[oracle@jiu ~]$ mkdir ./rman/block_trc
SQL> alter database enable block change tracking using file '/home/oracle/rman/block_trc/blk.trc';
# Backup command:
RMAN> run{
allocate channel c1 type disk;
allocate channel c2 type disk;
sql 'alter system switch logfile';
crosscheck archivelog all;
delete noprompt expired archivelog all;
backup incremental level 0 database format '/home/oracle/rman/data/%U.bak' include current controlfile plus archivelog format '/home/oracle/rman/arch/%U.bk';
}
# Query control file backup: backup piece
RMAN> list backup of controlfile;
/home/oracle/rman/data/05sv2o0d_1_1.bak
prkc-1024
# Transmission: save time:
#data
[oracle@jiu data]$ scp * 192.168.20.55:/home/oracle/rman/data/.
#arch
[oracle@jiu arch]$ scp *.bk 192.168.20.55:/home/oracle/rman/arch/.
# Create a new pfile file [If the target end, choose a different sid, need to change the name]
SQL> create pfile from spfile;
$ cd $ORACLE_HOME/dbs
$ Scp orapwjiu 192.168.20.55:/u02/app/oracle/10.2.0.4/dbhome_1/dbs/.
$ Scp initjiu.ora 192.168.20.55:/u02/app/oracle/10.2.0.4/dbhome_1/dbs/.
# End goal:
# Create a directory structure to store the backup file source
mkdir -p ./rman/arch
mkdir -p ./rman/data
# Modify the parameter file:
#before fixing
*.audit_file_dest='/picclife/app/oracle/admin/jiu/adump'
# Modify A: Different OACLE_BASE, better: Replace
%s#/picclife#/u02#g
After replacing #
audit_file_dest='/u02/app/oracle/admin/jiu/adump'
*.background_dump_dest='/u02/app/oracle/admin/jiu/bdump'
*.control_files='/u02/app/oracle/oradata/jiu/control01.ctl','
/u02/app/oracle/oradata/jiu/control02.ctl','/u02/app/oracle/o
radata/jiu/control03.ctl'
*.core_dump_dest='/u02/app/oracle/admin/jiu/cdump'
#*.local_listener='LISTENER_JIU'
*.db_name='ceshi'
*.db_recovery_file_dest='/u02/app/oracle/flash_recovery_area
*.log_archive_dest_1='location=/home/oracle/rman/arch'
*.user_dump_dest='/u02/app/oracle/admin/jiu/udump'
Create a path: all paths listed above
mkdir -p /u02/app/oracle/admin/jiu/adump
# Start to nomount stages:
SQL> startup nomount;
# Source and Sink: to make an inquiry, the state started to Mount
RMAN> restore controlfile from '/home/oracle/rman/data/05sv2o0d_1_1.bak';
SQL> alter database mount;
# Due to the different ends of environment directory, you need to modify the log file and datafile file path to the file name
SQL> select name from v$datafile
union
select member from v$logfile;
/picclife/app/oracle/oradata/jiu/redo03.log
/picclife/app/oracle/oradata/jiu/sysaux01.dbf
# Missteps: Can not modify rename datafile NO: The failure
select 'alter database rename file '''||name||''' to '||'''/u02/app/oracle/oradata/jiu/'||substr(name,instr(name,'/','-1')+1)||'''' ||';' from v$datafile;
# Log file OK
select 'alter database rename file '''||member||''' to '||'''/u02/app/oracle/oradata/jiu/'||substr(member,instr(member,'/','-1')+1)||''''||';' from v$logfile;
# Data files: Modify the query statement:
SQL> select 'set newname for datafile '||file#||' to "/u02/app/oracle/oradata/jiu/'||substr(name,instr(name,'/','-1')+1)||'";' from v$datafile;
# Sign backup set: the transmission source library backup set is not registered can not be used
RMAN> catalog start with '/home/oracle';
# If the above: rename datafile and logfile can use the following, otherwise, can not be used
run{
allocate channel ch00 type disk;
allocate channel ch01 type disk;
set newname for database to '/u02/app/oracle/oradata/jiu/%b';
restore database;
release channel ch00;
release channel ch01;
}
###### The use of this method:
RMAN> run{
set newname for datafile 1 to "/u02/app/oracle/oradata/jiu/system01.dbf";
set newname for datafile 2 to "/u02/app/oracle/oradata/jiu/undotbs01.dbf";
set newname for datafile 3 to "/u02/app/oracle/oradata/jiu/sysaux01.dbf";
set newname for datafile 4 to "/u02/app/oracle/oradata/jiu/users01.dbf";
set newname for datafile 5 to "/u02/app/oracle/oradata/jiu/example01.dbf";
restore database;
switch datafile all;
}
#RESTORE NEXT RECOVER
RMAN> recover database;
RMAN-06054: media recovery requesting unknown log: thread 1 seq 8 lowscn 599018
# Source query: In fact, the best beginning queries
SQL> select NAME,FIRST_CHANGE#,NEXT_CHANGE# from V$ARCHIVED_LOG order by NEXT_CHANGE#;
/home/oracle/rman/arch/1_7_971921498.dbf
598918599018-- source database queries: the last one archived log SCN
#OPEN database
RMAN> alter database open resetlogs;
ORA-19750: change tracking file: '/home/oracle/rman/block_trc/blk.trc'
# The test environment: Because the control file, the record opening blocks tracking, this solution idea, the source trace file transmission block
mkdir -p ./rman/block_trc/
]$ scp blk.trc 192.168.20.55:/home/oracle/rman/block_trc/.
#???????
RMAN> alter database open;
# Delete create a new temporary table space
SQL> create temporary tablespace temp001 tempfile '/u02/app/oracle/oradata/jiu/temp.dbf' size 20m autoextend on;
SQL> alter database default temporary tablespace temp001
SQL> select tablespace_name,CONTENTS from dba_tablespaces where contents='TEMPORARY';
TABLESPACE_NAME CONTENTS
------------------------------ ---------
TEMP TEMPORARY
TEMP001 TEMPORARY
SQL> drop tablespace temp;
B: 0 using the full backup backup + incremental backup heterogeneous recovery
# A test environment of use, empty the environment, to avoid interference:
# Delete content:
Block tracking files, data files, control files, log files,
# In order to facilitate this, test, parameter files unmodified, in order to achieve test results
Source library, create a new table space, create a test table, already in the system table space, create a test table, simulate changes
Archive switching times
# Simulation environment
SQL> create tablespace ceshi datafile '/home/oracle/ceshi.dbf' size 20m;
SQL> create table a tablespace system as select * from dba_objects;
SQL>
1* alter system switch logfile
r
r
r
r
SQL> create table b tablespace ceshi as select * from dba_objects;
SQL> alter system switch logfile;
# Backup command: backup of the original 0
RMAN> run{
allocate channel c1 type disk;
allocate channel c2 type disk;
sql 'alter system switch logfile';
crosscheck archivelog all;
delete noprompt expired archivelog all;
backup incremental level 0 database format '/home/oracle/rman/data/%U.bak' include current controlfile plus archivelog format '/home/oracle/rman/arch/%U.bk';
}
#RMAN> list backup;
The latest BS 6
# Backup instruction: Level 1 backup now, in order to distinguish identifier: name prefix value
RMAN> run{
allocate channel c1 type disk;
allocate channel c2 type disk;
sql 'alter system switch logfile';
crosscheck archivelog all;
delete noprompt expired archivelog all;
backup incremental level 1 database format '/home/oracle/rman/data/20180414%U.bak' include current controlfile plus archivelog format '/home/oracle/rman/arch/20180414%U.bk';
}
RMAN> list backup of controlfile;
Piece Name: /home/oracle/rman/data/201804140lsv2uij_1_1.bak
# Backup archive detection effectiveness:
- detect all the backup level
RMAN> crosscheck backup; RMAN> crosscheck archivelog all; - detecting Archive
- enumerate all valid backup sets
RMAN> list expired backup; RMAN> list expired archivelog all; - Query Archive
- Remove all invalid archive
RMAN> delete noprompt expired archivelog all;
#transmission:
$ scp 20180414* 192.168.20.55:/home/oracle/rman/arch/.
$ scp 201804140* 192.168.20.55:/home/oracle/rman/data/.
End goal:
Modify the password file, parameter file
SQL> startup nomount;
Start database to mount state:
RMAN> restore controlfile from '/home/oracle/rman/data/201804140lsv2uij_1_1.bak';
SQL> alter database mount;
Sign backup set:
RMAN> catalog start with '/home/oracle';
# Modify the log files, data files path: rename the file if the data is not specified by RMAN RUN block alter rename
# Log file OK
select 'alter database rename file '''||member||''' to '||'''/u02/app/oracle/oradata/jiu/'||substr(member,instr(member,'/','-1')+1)||''''||';' from v$logfile;
# Data files: Modify the query statement:
SQL> select 'set newname for datafile '||file#||' to "/u02/app/oracle/oradata/jiu/'||substr(name,instr(name,'/','-1')+1)||'";' from v$datafile;
# Using the latest control file, after the discovery, there is a new data file name of the record:
RMAN> run{
set newname for datafile 1 to "/u02/app/oracle/oradata/jiu/system01.dbf";
set newname for datafile 2 to "/u02/app/oracle/oradata/jiu/undotbs01.dbf";
set newname for datafile 3 to "/u02/app/oracle/oradata/jiu/sysaux01.dbf";
set newname for datafile 4 to "/u02/app/oracle/oradata/jiu/users01.dbf";
set newname for datafile 5 to "/u02/app/oracle/oradata/jiu/example01.dbf";
set newname for datafile 6 to "/u02/app/oracle/oradata/jiu/ceshi.dbf";
restore database;
switch datafile all;
}
# Test does not block tracking file, you can open the library
RMAN> recover database;
# Missing blocks in the trace file, recover session recovery off: can not continue
channel ORA_DISK_1: reading from backup piece /home/oracle/rman/arch/201804140hsv2uic_1_1.bk
channel ORA_DISK_1: restored backup piece 1
piece handle=/home/oracle/rman/arch/201804140hsv2uic_1_1.bk tag=TAG20180330T111315
channel ORA_DISK_1: restore complete, elapsed time: 00:00:02
archive log filename=/home/oracle/rman/arch/1_8_971921498.dbf thread=1 sequence=8
ORA-00283: recovery session canceled due to errors
RMAN-11003: failure during parse/execution of SQL statement: alter database recover logfile '/home/oracle/rman/arch/1_8_971921498.dbf'
ORA-00283: recovery session canceled due to errors
ORA-19755: could not open change tracking file
ORA-19750: change tracking file: '/home/oracle/rman/block_trc/blk.trc'
# Do not think
]$ scp blk.trc 192.168.20.55:/home/oracle/rman/block_trc/.
Case # conditional, restored to the last number 22
RMAN> recover database;
archive log filename=/home/oracle/rman/arch/1_22_971921498.dbf thread=1 sequence=22
unable to find archive log
archive log thread=1 sequence=23
RMAN-06054: media recovery requesting unknown log: thread 1 seq 23 lowscn 603484
SQL> select sequence#,FIRST_CHANGE#,NEXT_CHANGE# from V$ARCHIVED_LOG order by NEXT_CHANGE# ;
SEQUENCE# FIRST_CHANGE# NEXT_CHANGE#
---------- ------------- ------------
7 598918 599018
8 599018 603069
9 603069 603071
10 603071 603080
@@@@ omitted 9 archive
20 603400 603454
21 603454 603470
22 603470 603484
Queries create change # # number of table space test
SQL> select name,CREATION_CHANGE# from v$datafile;
/home/oracle/ceshi.dbf
602971
# Query Validation: Before you recover database, resume interrupted because of the lack of block trace files can not be recovered, and archive log breakpoint when the create tablespace SCN
Guess: detecting read archive log, to read the serial number 8, found space to create a table of action, lack of block trace files can not be restored
#OPEN Database: can not directly open
#RMAN> alter database open;
RMAN> alter database open resetlogs;
# Usual, you modify the temporary table space ---