How use the backupset of RMAN to restore and recover on a new machine.
— backup database on source database.
run {allocate channel c1 device type disk; backup incremental level 0 format '/u02/rman/db_full_%U.bkp' tag 'level0' database plus archivelog; backup current controlfile format '/u02/rman/ctl .bak'; backup spfile format '/u02/rman/spfile.bak'; release channel c1; }
–make the directory on target database servers
cd /u01/app/oracle/admin/trsendb mkdir {adump,bdump,cdump,dpdump,udump,pfile} mkdir -p /u02/oradata/trsendb mkdir -p /u02/fra mkdir -p /u02/rman
–query the DBID parameter on source target database.
SQL> select dbid from v$database; DBID ---------- 701555330
–copy the password file and backup files from source database servers to the target
–Begin the restore and recover actions.
1.startup nomount;
[oracle@scmadmin dbs]$ more inittrsendb.ora db_name=trsendb [oracle@scmadmin dbs]$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.4.0 Production on Tue Jun 13 17:51:54 2017 Copyright (c) 1982, 2013, Oracle. All rights reserved. Connected to an idle instance. SQL> startup nomount; ORACLE instance started. Total System Global Area 263090176 bytes Fixed Size 2252256 bytes Variable Size 205521440 bytes Database Buffers 50331648 bytes Redo Buffers 4984832 bytes
2.set DBID on the rman command.
RMAN> set dbid 701555330 executing command: SET DBID
3.restore spfile from backup files
RMAN> restore spfile from '/u02/rman/spfile.bak'; Starting restore at 13-JUN-17 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=429 device type=DISK channel ORA_DISK_1: restoring spfile from AUTOBACKUP /u02/rman/spfile.bak channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete Finished restore at 13-JUN-17 [oracle@scmadmin dbs]$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.4.0 Production on Tue Jun 13 17:54:45 2017 Copyright (c) 1982, 2013, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL> create pfile from spfile; File created.
4.restore ctl file from backup files
RMAN> startup force nomount; Oracle instance started Total System Global Area 2137886720 bytes Fixed Size 2254952 bytes Variable Size 704645016 bytes Database Buffers 1426063360 bytes Redo Buffers 4923392 bytes RMAN> restore controlfile from '/u02/rman/ctl .bak'; Starting restore at 13-JUN-17 allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=467 device type=DISK channel ORA_DISK_1: restoring control file channel ORA_DISK_1: restore complete, elapsed time: 00:01:05 output file name=/u02/oradata/trsendb/control01.ctl output file name=/u02/oradata/trsendb/control02.ctl output file name=/u02/oradata/trsendb/control03.ctl Finished restore at 13-JUN-17 RMAN> startup mount; database is already started database mounted released channel: ORA_DISK_1
5.restore database files from backup files.
RMAN> restore database; Starting restore at 14-JUN-17 Starting implicit crosscheck backup at 14-JUN-17 allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=699 device type=DISK Crosschecked 200 objects Finished implicit crosscheck backup at 14-JUN-17 Starting implicit crosscheck copy at 14-JUN-17 using channel ORA_DISK_1 Finished implicit crosscheck copy at 14-JUN-17 searching for all files in the recovery area cataloging files... no files cataloged using channel ORA_DISK_1 channel ORA_DISK_1: starting datafile backup set restore channel ORA_DISK_1: specifying datafile(s) to restore from backup set channel ORA_DISK_1: restoring datafile 00001 to /u02/oradata/trsendb/system01.dbf ...... channel ORA_DISK_1: restoring datafile 00042 to /u02/oradata/trsendb/INSAGTIDX01.DBF channel ORA_DISK_1: reading from backup piece /u02/rman/db_full_ras6mv30_1_1.bkp channel ORA_DISK_1: piece handle=/u02/rman/db_full_ras6mv30_1_1.bkp tag=LEVEL0 channel ORA_DISK_1: restored backup piece 1 channel ORA_DISK_1: restore complete, elapsed time: 00:39:09 Finished restore at 14-JUN-17
5.restore archivelog files from backup files.
RMAN> restore archivelog all; Starting restore at 14-JUN-17 using channel ORA_DISK_1 channel ORA_DISK_1: starting archived log restore to default destination channel ORA_DISK_1: restoring archived log archived log thread=1 sequence=672 channel ORA_DISK_1: restoring archived log ...... channel ORA_DISK_1: restoring archived log archived log thread=1 sequence=727 channel ORA_DISK_1: reading from backup piece /u02/rman/db_full_r9s6mv25_1_1.bkp channel ORA_DISK_1: piece handle=/u02/rman/db_full_r9s6mv25_1_1.bkp tag=LEVEL0 channel ORA_DISK_1: restored backup piece 1 channel ORA_DISK_1: restore complete, elapsed time: 00:03:16 channel ORA_DISK_1: starting archived log restore to default destination channel ORA_DISK_1: restoring archived log archived log thread=1 sequence=728 channel ORA_DISK_1: reading from backup piece /u02/rman/db_full_rcs6mv4p_1_1.bkp channel ORA_DISK_1: piece handle=/u02/rman/db_full_rcs6mv4p_1_1.bkp tag=LEVEL0 channel ORA_DISK_1: restored backup piece 1 channel ORA_DISK_1: restore com
6.recover database
RMAN> recover database; Starting recover at 14-JUN-17 using channel ORA_DISK_1 starting media recovery archived log for thread 1 with sequence 728 is already on disk as file /u02/arch/trsendb/1_728_900862466.dbf archived log file name=/u02/arch/trsendb/1_728_900862466.dbf thread=1 sequence=728 unable to find archived log archived log thread=1 sequence=729 RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03002: failure of recover command at 06/14/2017 09:45:30 RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 729 and starting SCN of 30373588 RMAN> recover database until scn 30373588;--这个scn点的数据是不包括在内的 Starting recover at 14-JUN-17 using channel ORA_DISK_1 starting media recovery media recovery complete, elapsed time: 00:00:01 Finished recover at 14-JUN-17
7.open database
SQL> select open_mode from v$database; OPEN_MODE -------------------- MOUNTED SQL> alter database open; alter database open * ERROR at line 1: ORA-01589: must use RESETLOGS or NORESETLOGS option for database open SQL> alter database open resetlogs; Database altered.