51上操作:
RMAN> show all;
RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/db/oracle10g/%F';
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '/db/oracle10g/bakup/%U';
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/db/oracle10g/product/10.2.0/db/dbs/snapcf_peak.f'; # default
RMAN>backup database;
Starting backup at 13-MAY-12
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=307 devtype=DISK
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/db/oracle10g/oradata/peak/system01.dbf
input datafile fno=00003 name=/db/oracle10g/oradata/peak/sysaux01.dbf
input datafile fno=00002 name=/db/oracle10g/oradata/peak/undotbs01.dbf
input datafile fno=00005 name=/db/oracle10g/oradata/test/test01.dbf
input datafile fno=00004 name=/db/oracle10g/oradata/peak/users01.dbf
channel ORA_DISK_1: starting piece 1 at 13-MAY-12
channel ORA_DISK_1: finished piece 1 at 13-MAY-12
piece handle=/db/oracle10g/bakup/05narvr6_1_1 tag=TAG20120513T070406 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:35
Finished backup at 13-MAY-12
Starting Control File Autobackup at 13-MAY-12
piece handle=/db/oracle10g/c-1833158544-20120513-01 comment=NONE
Finished Control File Autobackup at 13-MAY-12
53上操作:
[oracle@node53 db]$ mkdir -p /db/oracle10g/bakup/
[oracle@node53 db]$ cd /db/oracle10g/bakup/
[oracle@node53 bakup]$pwd
/db/oracle10g/bakup/
[oracle@node53 bakup]$
[oracle@node53 bakup]$ ll
总计 0
复制备份集到53服务器的相应目录下:
[oracle@node53 bakup]$scp 192.168.11.51:/db/oracle10g/bakup/05narvr6_1_1 .
oracle@192.168.11.51'spassword:
05narvr6_1_1 100% 527MB 6.8MB/s 01:17
[oracle@node53 bakup]$ls
05narvr6_1_1
[oracle@node53 bakup]$ cd /db/oracle10g/
[oracle@node53 oracle10g]$ll
总计 20
drwxr-x--- 3 oracle oinstall 4096 05-13 05:44 admin
drwxr-x--- 3 oracle oinstall 4096 05-13 05:44 flash_recovery_area
drwxr-x--- 3 oracle oinstall 4096 05-13 05:44 oradata
drwxr-x--- 6 oracle oinstall 4096 05-13 05:44 oraInventory
drwxr-xr-x 3 oracle oinstall 4096 05-13 05:44 product
复制控制文件的备份集到53服务上的相应目录下:
[oracle@node53 oracle10g]$ scp 192.168.11.51:/db/oracle10g/c-1833158544-20120513-01 .
oracle@192.168.11.51'spassword:
c-1833158544-20120512-01 100% 6976KB 6.8MB/s 00:01
[oracle@node53 oracle10g]$ ll
总计 7008
drwxr-x--- 3 oracle oinstall 4096 05-13 05:44 admin
-rw-r----- 1 oracle oinstall 7143424 05-13 05:52 c-1833158544-20120512-01
drwxr-x--- 3 oracle oinstall 4096 05-13 05:44 flash_recovery_area
drwxr-x--- 3 oracle oinstall 4096 05-13 05:44 oradata
drwxr-x--- 6 oracle oinstall 4096 05-13 05:44 oraInventory
drwxr-xr-x 3 oracle oinstall 4096 05-13 05:44 product
[oracle@node53 dbs]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Sun May 13 06:02:08 2012
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL>select tablespace_name from dba_tablespaces;
TABLESPACE_NAME
------------------------------
SYSTEM
UNDOTBS1
SYSAUX
TEMP
USERS
#这里没有TEST表空间
SQL> archive log list;
Database log mode No Archive Mode
Automatic archival Disabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 1
Current log sequence 2
SQL>
SQL>shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>
SQL> startup mount;
ORACLE instance started.
Total System Global Area 285212672 bytes
Fixed Size 1218992 bytes
Variable Size 75499088 bytes
Database Buffers 205520896 bytes
Redo Buffers 2973696 bytes
Database mounted.
SQL> alter database archivelog;
Database altered.
SQL>alter database open;
Database altered.
SQL>archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 1
Next log sequence to archive 2
Current log sequence 2
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
[oracle@node53 oracle10g]$rman target /
Recovery Manager: Release 10.2.0.1.0 - Production on Sun May 13 05:54:19 2012
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: PEAK (DBID=1833158544)
RMAN> exit
Recovery Manager complete.
[oracle@node53 oracle10g]$cd product/10.2.0/db/dbs/
[oracle@node53 dbs]$ll
总计 48
-rw-r----- 1 oracle oinstall 1544 05-13 05:45 hc_peak.dat
-rw-r----- 1 oracle oinstall 12920 05-13 05:45 initdw.ora
-rw-r----- 1 oracle oinstall 8385 05-13 05:45 init.ora
-rw-r--r-- 1 oracle oinstall 991 05-13 05:45 initpeak.ora
-rw-r----- 1 oracle oinstall 24 05-13 05:45 lkPEAK
-rw-r----- 1 oracle oinstall 1536 05-13 05:45 orapwpeak
-rw-r----- 1 oracle oinstall 2560 05-13 05:53 spfilepeak.ora
[oracle@node53 dbs]$sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Sun May 13 05:55:26 2012
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL>create pfile from spfile;
File created.
SQL>exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
[oracle@node53 dbs]$ ll
总计 48
-rw-r----- 1 oracle oinstall 1544 05-13 05:45 hc_peak.dat
-rw-r----- 1 oracle oinstall 12920 05-13 05:45 initdw.ora
-rw-r----- 1 oracle oinstall 8385 05-13 05:45 init.ora
-rw-r--r-- 1 oracle oinstall 991 05-13 05:55 initpeak.ora
-rw-r----- 1 oracle oinstall 24 05-13 05:45 lkPEAK
-rw-r----- 1 oracle oinstall 1536 05-13 05:45 orapwpeak
-rw-r----- 1 oracle oinstall 2560 05-13 05:53 spfilepeak.ora
[oracle@node53 dbs]$
#要注意,备份控制文件的时候用的SID,在备库上也要用同样的SID.
[oracle@node53 dbs]$sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Sun May 13 05:55:32 2012
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>
SQL>startup nomount pfile='/db/oracle10g/product/10.2.0/db/dbs/initpeak.ora';
ORACLE instance started.
Total System Global Area 285212672 bytes
Fixed Size 1218992 bytes
Variable Size 75499088 bytes
Database Buffers 205520896 bytes
Redo Buffers 2973696 bytes
SQL>exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
[oracle@node53 dbs]$ rman target /
Recovery Manager: Release 10.2.0.1.0 - Production on Sun May 13 05:57:13 2012
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: peak (not mounted)
RMAN>restore controlfile to '/db/oracle10g/oradata/peak/control01.ctl' from '/db/oracle10g/c-1833158544-20120512-01';
#注意:from后面就是从51拷贝过来的控制文件的备份集。to后面的那句可以不写,有时写了反而麻烦。
#可直接写为restore controlfile from '/db/oracle10g/c-1833158544-20120512-01';
Starting restore at 13-MAY-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=321 devtype=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:02
Finished restore at 13-MAY-12
RMAN> alter database mount;
database mounted
released channel: ORA_DISK_1
#向控制文件中加载备份集:
RMAN> catalog start with '/db/oracle10g/c-1833158544-20120512-01';
Starting implicit crosscheck backup at 13-MAY-12
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=321 devtype=DISK
Crosschecked 1 objects
Finished implicit crosscheck backup at 13-MAY-12
Starting implicit crosscheck copy at 13-MAY-12
using channel ORA_DISK_1
Crosschecked 2 objects
Finished implicit crosscheck copy at 13-MAY-12
searching for all files in the recovery area
cataloging files...
no files cataloged
searching for all files that match the pattern /db/oracle10g/c-1833158544-20120512-01
List of Files Unknown to the Database
=====================================
File Name: /db/oracle10g/c-1833158544-20120512-01
Do you really want to catalog the above files (enter YES or NO)? yes
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: /db/oracle10g/c-1833158544-20120512-01
RMAN> crosscheck backup ;
using channel ORA_DISK_1
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/db/oracle10g/bakup/05narvr6_1_1 recid=1 stamp=783113788
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/db/oracle10g/c-1833158544-20120512-01 recid=2 stamp=783151167
Crosschecked 2 objects
RMAN> report schema;
RMAN-06139: WARNING: control file is not current for REPORT SCHEMA
Report of database schema
List of Permanent Datafiles
===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1 480 SYSTEM *** /db/oracle10g/oradata/peak/system01.dbf
2 25 UNDOTBS1 *** /db/oracle10g/oradata/peak/undotbs01.dbf
3 240 SYSAUX *** /db/oracle10g/oradata/peak/sysaux01.dbf
4 5 USERS *** /db/oracle10g/oradata/peak/users01.dbf
5 0 TEST *** /db/oracle10g/oradata/test/test01.dbf
List of Temporary Files
=======================
File Size(MB) Tablespace Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1 20 TEMP 32767 /db/oracle10g/oradata/peak/temp01.dbf
RMAN>
RMAN>run
2> {
3> set newname for datafile 1 to '/db/oracle10g/oradata/peak/system01.dbf';
4> set newname for datafile 2 to '/db/oracle10g/oradata/peak/undotbs01.dbf';
5> set newname for datafile 3 to '/db/oracle10g/oradata/peak/sysaux01.dbf';
6> set newname for datafile 4 to '/db/oracle10g/oradata/peak/users01.dbf';
set newname for datafile 5 to '/db/oracle10g/oradata/test/test01.dbf';
8> restore database;
9> switch datafile all;
10> }
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting restore at 13-MAY-12
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /db/oracle10g/oradata/peak/system01.dbf
restoring datafile 00002 to /db/oracle10g/oradata/peak/undotbs01.dbf
restoring datafile 00003 to /db/oracle10g/oradata/peak/sysaux01.dbf
restoring datafile 00004 to /db/oracle10g/oradata/peak/users01.dbf
restoring datafile 00005 to /db/oracle10g/oradata/test/test01.dbf
channel ORA_DISK_1: reading from backup piece /db/oracle10g/bakup/05narvr6_1_1
channel ORA_DISK_1: restored backup piece 1
piece handle=/db/oracle10g/bakup/05narvr6_1_1 tag=TAG20120512T193628
channel ORA_DISK_1: restore complete, elapsed time: 00:00:36
Finished restore at 13-MAY-12
RMAN> alter database open resetlogs;
database opened
RMAN>
RMAN> exit
Recovery Manager complete.
[oracle@node53 dbs]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Sun May 13 06:02:08 2012
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL>select tablespace_name from dba_tablespaces;
TABLESPACE_NAME
------------------------------
SYSTEM
UNDOTBS1
SYSAUX
TEMP
USERS
TEST
#这里有TEST表空间,恢复成功
6 rows selected.
SQL>