Environment Introduction:
Operating system version: RHEL5.4 32-bit
Oracle version: 10.2.0.1 32-bit
Oracle_SID: orcl
The operating system of the source server and target server is consistent with that of oracle.
Source server: 192.168.227.20
Target Server: 192.168.227.30. You only need to install the oracle software.
I. Use rman on the source server to back up the database, including data files, archived log files, control files, and parameter files.
- [oracle@orcl ~]$ mkdir /u01/backup
- [oracle@orcl ~]$ rman target /
- Recovery Manager: Release 10.2.0.1.0 - Production on Tue Sep 6 16:04:53 2011
- Copyright (c) 1982, 2005, Oracle. All rights reserved.
- connected to target database: ORCL (DBID=1287906064)
-
- RMAN> run {
- 2> allocate channel c1 device type disk;
- 3> backup incremental level 0
- 4> format '/u01/backup/db_full_%U.bkp'
- 5> tag '2011-09-06-FULL'
- 6> database plus archivelog;
- 7> release channel c1;
- 8> }
- RMAN> backup current controlfile format '/u01/backup/control20110906.bak';
- RMAN> backup spfile format '/u01/backup/spfile20110906.bak';
2. Copy the backup data on the target server and prepare the relevant directories.
- [oracle@orcl ~]$ mkdir /u01/backup
- [oracle@orcl ~]$ scp -rp 192.168.227.20:/u01/backup/* /u01/backup/
- oracle@192.168.227.20's password:
- control20110906.bak 100% 6944KB 1.7MB/s 00:04
- db_full_0fmlsmdt_1_1.bkp 100% 97MB 4.4MB/s 00:22
- db_full_0gmlsme5_1_1.bkp 100% 593MB 9.1MB/s 01:05
- db_full_0hmlsmg7_1_1.bkp 100% 6656 6.5KB/s 00:00
- spfile20110906.bak 100% 96KB 96.0KB/s 00:00
-
- [oracle@orcl ~]$ mkdir -p /u01/app/oracle/admin/orcl/{adump,bdump,cdump,dpdump,udump,pfile}
- [oracle@orcl ~]$ mkdir -p /u01/app/oracle/oradata/orcl
- [oracle@orcl ~]$ mkdir -p /u01/app/oracle/flash_recover_area/ORCL
Iii. recovery on the target server
- [Oracle @ orcl ~] $ Echo'Db_name=Orcl'>$ ORACLE_HOME/dbs/initorcl. ora
- [Oracle @ orcl ~] $ ExportORACLE_SID=Orcl
- [Oracle @ orcl ~] $ Rman target/
- Recovery Manager: Release 10.2.0.1.0-Production on Tue Sep 6 16:18:19 2011
- Copyright (c) 1982,200 5, Oracle. All rights reserved.
- Connected to target database (not started)
-
- RMAN>Set dbid 1287906064; // specify the DBID, which must be consistent with the DBID of the source server.
- RMAN>Startup nomount; // start the database to the nomount state. here you need to create the initorcl. ora file before, or an error will be reported.
- RMAN>Restore spfile from '/u01/backup/spfile20110906.bak'; // restore the parameter file
- RMAN>Startup nomount force; // restart the instance to the nomout status.
- RMAN>Restore controlfile from '/u01/backup/control20110906.bak'; // restore control file
- RMAN>Recover database; // Restore database files
- RMAN>Recover database; // restore the database file. An error is reported here.
- RMAN-03002: failure of recover command at 17:03:51
- RMAN-06054: media recovery requesting unknown log: thread 1 seq 15 lowscn 547974
- RMAN>Exit
-
- [Oracle @ orcl ~] $ Sqlplus/nolog // perform the until cancel Operation on the database in sqlplus and enable it in resetlogs mode.
- SQL * Plus: Release 10.2.0.1.0-Production on Tue Sep 6 17:04:22 2011
- Copyright (c) 1982,200 5, Oracle. All rights reserved.
-
- SQL>Conn/as sysdba
- Connected.
- SQL>Recover database using backup controlfile until cancel;
- ORA-00279: change 547974 generated at 16:49:11 needed for thread 1
- ORA-00289: suggestion:
- /U01/app/oracle/flash_recovery_area/ORCL/archivelog/20151109_06/o2017mf_000015 _ % u _. ar
- C
- ORA-00280: change 547974 for thread 1 is in sequence #15
-
-
- Specify log :{<RET>= Suggested | filename | AUTO | CANCEL}
- Cancel
- Media recovery canceled.
- SQL>Alter database open resetlogs;
Iv. Test
- SQL> select member from v$logfile;
-
- MEMBER
- --------------------------------------------------------------------------------
- /u01/app/oracle/oradata/orcl/redo03.log
- /u01/app/oracle/oradata/orcl/redo02.log
- /u01/app/oracle/oradata/orcl/redo01.log
-
- SQL> select file_name from dba_data_files;
-
- FILE_NAME
- --------------------------------------------------------------------------------
- /u01/app/oracle/oradata/orcl/users01.dbf
- /u01/app/oracle/oradata/orcl/sysaux01.dbf
- /u01/app/oracle/oradata/orcl/undotbs01.dbf
- /u01/app/oracle/oradata/orcl/system01.dbf
- /u01/app/oracle/oradata/orcl/example01.dbf
- /u01/app/oracle/oradata/orcl/tbs_apple01.dbf
- 6 rows selected.
-
-
- SQL> select count(*) from dba_temp_files;
- COUNT(*)
- ----------
- 1
-
- SQL> select count(*) from hr.employees;
-
- COUNT(*)
- ----------
- 107
5. Notes
- RMAN>List incarnation; // generate a new incarnation
- Using target database control file instead of recovery catalog
-
- List of Database Incarnations
- DB Key Inc Key DB Name db id status Reset SCN Reset Time
- -------------------------------------------------------------
- 1 1 ORCL 1287906064 PARENT 1 2005-06-30: 19: 09: 40
- 2 2 ORCL 1287906064 PARENT 446075: 17: 55: 31
- 3 3 ORCL 1287906064 CURRENT 547975 2011-09-06: 17: 07: 09
-
- [Oracle @ orcl ~] $ Emctl start dbconsole // dbconsole needs to be reconfigured, And the orapwd file also needs to be created
- TZ set to PRC
- Productname Configuration issue./u01/app/oracle/product/10.2.0/db_1/Solaris/j2ee/OC4J_DBConsole_orcl.herostart.com_orcl not found
Vi. Incremental Backup Recovery from different machines
1: source server
- SQL> create user rman_inr identified by "123456" default tablespace users;
- User created.
- SQL> grant connect,resource to rman_inr;
- Grant succeeded.
- SQL> create table rman_inr.test as select * from dba_source;
- Table created.
-
- RMAN> backup incremental level 1
- 2> format '/u01/backup/inr1_db_%U' tag 'inr_1'
- 3> database plus archivelog;
-
- [oracle@orcl ~]$ rman target /
- RMAN> backup incremental level 1
- 2> format '/u01/backup/inr1_db_%U' tag 'inr_1'
- 3> database plus archivelog;
-
- RMAN> backup current controlfile format '/u01/backup/control02.bak';
-
- [oracle@orcl ~]$ ls -lh /u01/backup/inr1_db_1*
- -rw-r----- 1 oracle oinstall 53M Sep 8 16:34 /u01/backup/inr1_db_1omm1ud0_1_1
- -rw-r----- 1 oracle oinstall 51M Sep 8 16:35 /u01/backup/inr1_db_1pmm1udk_1_1
- -rw-r----- 1 oracle oinstall 6.9M Sep 8 16:35 /u01/backup/inr1_db_1qmm1uf2_1_1
- -rw-r----- 1 oracle oinstall 11K Sep 8 16:35 /u01/backup/inr1_db_1rmm1uf5_1_1
-
- [oracle@orcl ~]$ scp /u01/backup/inr1_db_1* 192.168.227.30:/u01/backup/
- [oracle@orcl ~]$ scp /u01/backup/control02.bak 192.168.227.30:/u01/backup/
2: Target Server
- [oracle@orcl ~]$ sqlplus /nolog
- SQL> conn /as sysdba
- Connected.
- SQL> shutdown immediate;
-
- RMAN> set dbid=1287906064;
- RMAN> startup nomount;
- RMAN> restore controlfile from '/u01/backup/control02.bak';
- RMAN> startup mount force;
-
- RMAN> restore database;
- RMAN> recover database;
- RMAN-03002: failure of recover command at 09/08/2011 16:46:44
- RMAN-06054: media recovery requesting unknown log: thread 1 seq 45 lowscn 598452
- RMAN> exit
-
- [oracle@orcl ~]$ sqlplus /nolog
- SQL> conn /as sysdba
-
- SQL> recover database using backup controlfile until cancel;
- ORA-00279: change 598452 generated at 09/08/2011 16:35:49 needed for thread 1
- ORA-00289: suggestion : /u01/arch/orcl/1_45_760125331.arc
- ORA-00280: change 598452 for thread 1 is in sequence #45
-
- Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
- cancel
- Media recovery cancelled.
-
- SQL> alter database open resetlogs;
- Database altered.
3: Test
- SQL> conn rman_inr/123456
- Connected
-
- SQL> select count(*) from test;
-
- COUNT(*)
- ----------
- 292428