实验环境
a:oraclelinux6.5
ip地址:192.168.6.245
oracle版本:11.2.0.3
建库
b:oraclelinux6.5
ip地址:192.168.6.200
oracle版本:11.2.0.3
只安装oracle的软件,不建库
a备份==>b恢复
在a服务器上操作:
首先在a服务器上做0级备份
RMAN> run {
2> backup incremental level 0 database include current controlfile;
3> sql 'alter system archive log current';
4> backup archivelog all delete input;
5> }
Starting backup at 06-JUL-16
using channel ORA_DISK_1
using channel ORA_DISK_2
channel ORA_DISK_1: starting incremental level 0 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00005 name=/u01/clsp01.dbf
input datafile file number=00003 name=/u01/oracle/oradata/pu/undotbs01.dbf
input datafile file number=00004 name=/u01/oracle/oradata/pu/users01.dbf
channel ORA_DISK_1: starting piece 1 at 06-JUL-16
channel ORA_DISK_2: starting incremental level 0 datafile backup set
channel ORA_DISK_2: specifying datafile(s) in backup set
input datafile file number=00002 name=/u01/oracle/oradata/pu/sysaux01.dbf
input datafile file number=00001 name=/u01/oracle/oradata/pu/system01.dbf
input datafile file number=00006 name=/u01/salary01.dbf
input datafile file number=00007 name=/u01/TEST01.DBF
channel ORA_DISK_2: starting piece 1 at 06-JUL-16
channel ORA_DISK_1: finished piece 1 at 06-JUL-16
piece handle=/u01/oracle/fast_recovery_area/PU/backupset/2016_07_06/o1_mf_nnnd0_TAG20160706T111222_cqrxrq9o_.bkp tag=TAG20160706T111222 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:27
channel ORA_DISK_1: starting incremental level 0 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
channel ORA_DISK_1: starting piece 1 at 06-JUL-16
channel ORA_DISK_1: finished piece 1 at 06-JUL-16
piece handle=/u01/oracle/fast_recovery_area/PU/backupset/2016_07_06/o1_mf_ncnn0_TAG20160706T111222_cqrxvpr1_.bkp tag=TAG20160706T111222 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:20
channel ORA_DISK_2: finished piece 1 at 06-JUL-16
piece handle=/u01/oracle/fast_recovery_area/PU/backupset/2016_07_06/o1_mf_nnnd0_TAG20160706T111222_cqrxrr22_.bkp tag=TAG20160706T111222 comment=NONE
channel ORA_DISK_2: backup set complete, elapsed time: 00:02:43
Finished backup at 06-JUL-16
Starting Control File and SPFILE Autobackup at 06-JUL-16
piece handle=/u01/rmanbackup/controlfile_c-2744947428-20160706-03 comment=NONE
Finished Control File and SPFILE Autobackup at 06-JUL-16
sql statement: alter system archive log current
Starting backup at 06-JUL-16
current log archived
using channel ORA_DISK_1
using channel ORA_DISK_2
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=412 RECID=365 STAMP=916485310
channel ORA_DISK_1: starting piece 1 at 06-JUL-16
channel ORA_DISK_2: starting archived log backup set
channel ORA_DISK_2: specifying archived log(s) in backup set
input archived log thread=1 sequence=413 RECID=366 STAMP=916485311
channel ORA_DISK_2: starting piece 1 at 06-JUL-16
channel ORA_DISK_1: finished piece 1 at 06-JUL-16
piece handle=/u01/oracle/fast_recovery_area/PU/backupset/2016_07_06/o1_mf_annnn_TAG20160706T111511_cqrxy08q_.bkp tag=TAG20160706T111511 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
channel ORA_DISK_1: deleting archived log(s)
archived log file name=/u01/oracle/fast_recovery_area/PU/archivelog/2016_07_06/o1_mf_1_412_cqrxxyh8_.arc RECID=365 STAMP=916485310
channel ORA_DISK_2: finished piece 1 at 06-JUL-16
piece handle=/u01/oracle/fast_recovery_area/PU/backupset/2016_07_06/o1_mf_annnn_TAG20160706T111511_cqrxy0dx_.bkp tag=TAG20160706T111511 comment=NONE
channel ORA_DISK_2: backup set complete, elapsed time: 00:00:01
channel ORA_DISK_2: deleting archived log(s)
archived log file name=/u01/oracle/fast_recovery_area/PU/archivelog/2016_07_06/o1_mf_1_413_cqrxxzb3_.arc RECID=366 STAMP=916485311
Finished backup at 06-JUL-16
Starting Control File and SPFILE Autobackup at 06-JUL-16
piece handle=/u01/rmanbackup/controlfile_c-2744947428-20160706-04 comment=NONE
Finished Control File and SPFILE Autobackup at 06-JUL-16
RMAN> exit
Recovery Manager complete.
创建pfile文件
[oracle@oracle2 ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.3.0 Production on Wed Jul 6 11:20:55 2016
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP, Data Mining,
Oracle Database Vault and Real Application Testing options
SQL> create pfile from spfile;
File created.
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 412
Next log sequence to archive 414
Current log sequence 414
到备份目录下拷贝备份片和pfile文件到b服务器(记得全部拷贝)
[root@oracle2 2016_07_06]# scp * [email protected]:/u01
The authenticity of host '192.168.6.200 (192.168.6.200)' can't be established.
RSA key fingerprint is 1e:70:87:a4:a9:ac:58:97:e4:31:ac:f5:f5:2f:6d:70.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.6.200' (RSA) to the list of known hosts.
[email protected]'s password:
o1_mf_annnn_TAG20160706T111511_cqrxy08q_.bkp 100% 47KB 46.5KB/s 00:00
o1_mf_annnn_TAG20160706T111511_cqrxy0dx_.bkp 100% 2560 2.5KB/s 00:00
o1_mf_ncnn0_TAG20160706T111222_cqrxvpr1_.bkp 100% 9888KB 9.7MB/s 00:00
o1_mf_nnnd0_TAG20160706T111222_cqrxrq9o_.bkp 100% 613MB 25.6MB/s 00:24
o1_mf_nnnd0_TAG20160706T111222_cqrxrr22_.bkp 100% 1390MB 26.2MB/s 00:53
[root@oracle2 2016_07_06]# cd /u01/11
11.bad 11g/ 11.log 11.txt
[root@oracle2 2016_07_06]# cd /u01/11
11.bad 11g/ 11.log 11.txt
[root@oracle2 2016_07_06]# cd /u01/11g/
apex/ clone/ cv/ dv/ install/ jdev/ md/ odbc/ ord/ precomp/ slax/ timingframework/ xdk/
assistants/ config/ dbs/ emcli/ instantclient/ jdk/ mesg/ olap/ oui/ racg/ sqldeveloper/ ucp/
bin/ crs/ dc_ocm/ EMStage/ inventory/ jlib/ mgw/ OPatch/ owb/ rdbms/ sqlj/ uix/
ccr/ csmig/ deinstall/ has/ j2ee/ ldap/ network/ opmn/ owm/ relnotes/ sqlplus/ usm/
cdata/ css/ demo/ hs/ javavm/ lib/ nls/ oracore/ perl/ root.sh srvm/ utl/
cfgtoollogs/ ctx/ diagnostics/ ide/ jdbc/ log/ oc4j/ oraInst.loc plsql/ scheduler/ sysman/ wwg/
[root@oracle2 2016_07_06]# cd /u01/11g/dbs/
hc_pu.dat init.ora initpu.ora lkPU orapwpu snapcf_pu.f spfilepu.ora
[root@oracle2 2016_07_06]# cd /u01/11g/dbs/
[root@oracle2 dbs]# ls
hc_pu.dat init.ora initpu.ora lkPU orapwpu snapcf_pu.f spfilepu.ora
[root@oracle2 dbs]# scp initpu.ora [email protected]:/u01
[email protected]'s password:
initpu.ora 100% 2266 2.2KB/s 00:00
[root@oracle2 dbs]#
记录dbid(恢复的controlfile中会记录dbid,这里我们可以提前记录dbid)
SQL> select dbid from v$database;
DBID
----------
2744947428
在b服务器上操作:
创建a服务器上的目录
[oracle@localhost oracle]$ grep / /u01/initpu.ora
zhphpgg.__oracle_base='/u01/oracle'#ORACLE_BASE set from environment
pu.__oracle_base='/u01/oracle'#ORACLE_BASE set from environment
*.audit_file_dest='/u01/oracle/admin/pu/adump'
*.control_files='/u01/oracle/oradata/pu/control01.ctl','/u01/oracle/fast_recovery_area/pu/control02.ctl'
*.db_file_name_convert='/u01/oracle/oradata/zhphpgg/','/u01/oracle/oradata/pu/'
*.db_recovery_file_dest='/u01/oracle/fast_recovery_area'
*.diagnostic_dest='/u01/oracle'
[oracle@localhost oracle]$ mkdir -p /u01/oracle/admin/pu/adump
[oracle@localhost oracle]$ mkdir -p /u01/oracle/oradata/pu/
[oracle@localhost oracle]$ mkdir -p /u01/oracle/fast_recovery_area/pu/
使用a服务器上拷贝过来的pfile启动数据库到nomount状态(如果服务器的配置不同,记得调整pfile中记录的内存数值,否则会提示内存不支持错误)
SQL> startup nomount pfile='/u01/initpu.ora';
ORACLE instance started.
Total System Global Area 1068937216 bytes
Fixed Size 2235208 bytes
Variable Size 918553784 bytes
Database Buffers 142606336 bytes
Redo Buffers 5541888 bytes
登陆rman恢复controlfile
[oracle@localhost ~]$ rman target /
Recovery Manager: Release 11.2.0.3.0 - Production on Wed Jul 6 13:52:18 2016
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: PU (not mounted)
RMAN> restore controlfile from '/u01/o1_mf_ncnn0_TAG20160706T111222_cqrxvpr1_.bkp';
Starting restore at 06-JUL-16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=19 device type=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/u01/oracle/oradata/pu/control01.ctl
output file name=/u01/oracle/fast_recovery_area/pu/control02.ctl
Finished restore at 06-JUL-16
打开数据库到mount状态
RMAN> alter database mount;
database mounted
released channel: ORA_DISK_1
RMAN>
还原数据文件
[oracle@localhost ~]$ rman target /
Recovery Manager: Release 11.2.0.3.0 - Production on Wed Jul 6 14:12:41 2016
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: PU (DBID=2744947428, not open)
RMAN> restore database;
Starting restore at 06-JUL-16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=18 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=1 device type=DISK
RMAN-00571: ====
a:oraclelinux6.5
ip地址:192.168.6.245
oracle版本:11.2.0.3
建库
b:oraclelinux6.5
ip地址:192.168.6.200
oracle版本:11.2.0.3
只安装oracle的软件,不建库
a备份==>b恢复
在a服务器上操作:
首先在a服务器上做0级备份
RMAN> run {
2> backup incremental level 0 database include current controlfile;
3> sql 'alter system archive log current';
4> backup archivelog all delete input;
5> }
Starting backup at 06-JUL-16
using channel ORA_DISK_1
using channel ORA_DISK_2
channel ORA_DISK_1: starting incremental level 0 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00005 name=/u01/clsp01.dbf
input datafile file number=00003 name=/u01/oracle/oradata/pu/undotbs01.dbf
input datafile file number=00004 name=/u01/oracle/oradata/pu/users01.dbf
channel ORA_DISK_1: starting piece 1 at 06-JUL-16
channel ORA_DISK_2: starting incremental level 0 datafile backup set
channel ORA_DISK_2: specifying datafile(s) in backup set
input datafile file number=00002 name=/u01/oracle/oradata/pu/sysaux01.dbf
input datafile file number=00001 name=/u01/oracle/oradata/pu/system01.dbf
input datafile file number=00006 name=/u01/salary01.dbf
input datafile file number=00007 name=/u01/TEST01.DBF
channel ORA_DISK_2: starting piece 1 at 06-JUL-16
channel ORA_DISK_1: finished piece 1 at 06-JUL-16
piece handle=/u01/oracle/fast_recovery_area/PU/backupset/2016_07_06/o1_mf_nnnd0_TAG20160706T111222_cqrxrq9o_.bkp tag=TAG20160706T111222 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:27
channel ORA_DISK_1: starting incremental level 0 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
channel ORA_DISK_1: starting piece 1 at 06-JUL-16
channel ORA_DISK_1: finished piece 1 at 06-JUL-16
piece handle=/u01/oracle/fast_recovery_area/PU/backupset/2016_07_06/o1_mf_ncnn0_TAG20160706T111222_cqrxvpr1_.bkp tag=TAG20160706T111222 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:20
channel ORA_DISK_2: finished piece 1 at 06-JUL-16
piece handle=/u01/oracle/fast_recovery_area/PU/backupset/2016_07_06/o1_mf_nnnd0_TAG20160706T111222_cqrxrr22_.bkp tag=TAG20160706T111222 comment=NONE
channel ORA_DISK_2: backup set complete, elapsed time: 00:02:43
Finished backup at 06-JUL-16
Starting Control File and SPFILE Autobackup at 06-JUL-16
piece handle=/u01/rmanbackup/controlfile_c-2744947428-20160706-03 comment=NONE
Finished Control File and SPFILE Autobackup at 06-JUL-16
sql statement: alter system archive log current
Starting backup at 06-JUL-16
current log archived
using channel ORA_DISK_1
using channel ORA_DISK_2
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=412 RECID=365 STAMP=916485310
channel ORA_DISK_1: starting piece 1 at 06-JUL-16
channel ORA_DISK_2: starting archived log backup set
channel ORA_DISK_2: specifying archived log(s) in backup set
input archived log thread=1 sequence=413 RECID=366 STAMP=916485311
channel ORA_DISK_2: starting piece 1 at 06-JUL-16
channel ORA_DISK_1: finished piece 1 at 06-JUL-16
piece handle=/u01/oracle/fast_recovery_area/PU/backupset/2016_07_06/o1_mf_annnn_TAG20160706T111511_cqrxy08q_.bkp tag=TAG20160706T111511 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
channel ORA_DISK_1: deleting archived log(s)
archived log file name=/u01/oracle/fast_recovery_area/PU/archivelog/2016_07_06/o1_mf_1_412_cqrxxyh8_.arc RECID=365 STAMP=916485310
channel ORA_DISK_2: finished piece 1 at 06-JUL-16
piece handle=/u01/oracle/fast_recovery_area/PU/backupset/2016_07_06/o1_mf_annnn_TAG20160706T111511_cqrxy0dx_.bkp tag=TAG20160706T111511 comment=NONE
channel ORA_DISK_2: backup set complete, elapsed time: 00:00:01
channel ORA_DISK_2: deleting archived log(s)
archived log file name=/u01/oracle/fast_recovery_area/PU/archivelog/2016_07_06/o1_mf_1_413_cqrxxzb3_.arc RECID=366 STAMP=916485311
Finished backup at 06-JUL-16
Starting Control File and SPFILE Autobackup at 06-JUL-16
piece handle=/u01/rmanbackup/controlfile_c-2744947428-20160706-04 comment=NONE
Finished Control File and SPFILE Autobackup at 06-JUL-16
RMAN> exit
Recovery Manager complete.
创建pfile文件
[oracle@oracle2 ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.3.0 Production on Wed Jul 6 11:20:55 2016
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP, Data Mining,
Oracle Database Vault and Real Application Testing options
SQL> create pfile from spfile;
File created.
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 412
Next log sequence to archive 414
Current log sequence 414
到备份目录下拷贝备份片和pfile文件到b服务器(记得全部拷贝)
[root@oracle2 2016_07_06]# scp * [email protected]:/u01
The authenticity of host '192.168.6.200 (192.168.6.200)' can't be established.
RSA key fingerprint is 1e:70:87:a4:a9:ac:58:97:e4:31:ac:f5:f5:2f:6d:70.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.6.200' (RSA) to the list of known hosts.
[email protected]'s password:
o1_mf_annnn_TAG20160706T111511_cqrxy08q_.bkp 100% 47KB 46.5KB/s 00:00
o1_mf_annnn_TAG20160706T111511_cqrxy0dx_.bkp 100% 2560 2.5KB/s 00:00
o1_mf_ncnn0_TAG20160706T111222_cqrxvpr1_.bkp 100% 9888KB 9.7MB/s 00:00
o1_mf_nnnd0_TAG20160706T111222_cqrxrq9o_.bkp 100% 613MB 25.6MB/s 00:24
o1_mf_nnnd0_TAG20160706T111222_cqrxrr22_.bkp 100% 1390MB 26.2MB/s 00:53
[root@oracle2 2016_07_06]# cd /u01/11
11.bad 11g/ 11.log 11.txt
[root@oracle2 2016_07_06]# cd /u01/11
11.bad 11g/ 11.log 11.txt
[root@oracle2 2016_07_06]# cd /u01/11g/
apex/ clone/ cv/ dv/ install/ jdev/ md/ odbc/ ord/ precomp/ slax/ timingframework/ xdk/
assistants/ config/ dbs/ emcli/ instantclient/ jdk/ mesg/ olap/ oui/ racg/ sqldeveloper/ ucp/
bin/ crs/ dc_ocm/ EMStage/ inventory/ jlib/ mgw/ OPatch/ owb/ rdbms/ sqlj/ uix/
ccr/ csmig/ deinstall/ has/ j2ee/ ldap/ network/ opmn/ owm/ relnotes/ sqlplus/ usm/
cdata/ css/ demo/ hs/ javavm/ lib/ nls/ oracore/ perl/ root.sh srvm/ utl/
cfgtoollogs/ ctx/ diagnostics/ ide/ jdbc/ log/ oc4j/ oraInst.loc plsql/ scheduler/ sysman/ wwg/
[root@oracle2 2016_07_06]# cd /u01/11g/dbs/
hc_pu.dat init.ora initpu.ora lkPU orapwpu snapcf_pu.f spfilepu.ora
[root@oracle2 2016_07_06]# cd /u01/11g/dbs/
[root@oracle2 dbs]# ls
hc_pu.dat init.ora initpu.ora lkPU orapwpu snapcf_pu.f spfilepu.ora
[root@oracle2 dbs]# scp initpu.ora [email protected]:/u01
[email protected]'s password:
initpu.ora 100% 2266 2.2KB/s 00:00
[root@oracle2 dbs]#
记录dbid(恢复的controlfile中会记录dbid,这里我们可以提前记录dbid)
SQL> select dbid from v$database;
DBID
----------
2744947428
在b服务器上操作:
创建a服务器上的目录
[oracle@localhost oracle]$ grep / /u01/initpu.ora
zhphpgg.__oracle_base='/u01/oracle'#ORACLE_BASE set from environment
pu.__oracle_base='/u01/oracle'#ORACLE_BASE set from environment
*.audit_file_dest='/u01/oracle/admin/pu/adump'
*.control_files='/u01/oracle/oradata/pu/control01.ctl','/u01/oracle/fast_recovery_area/pu/control02.ctl'
*.db_file_name_convert='/u01/oracle/oradata/zhphpgg/','/u01/oracle/oradata/pu/'
*.db_recovery_file_dest='/u01/oracle/fast_recovery_area'
*.diagnostic_dest='/u01/oracle'
[oracle@localhost oracle]$ mkdir -p /u01/oracle/admin/pu/adump
[oracle@localhost oracle]$ mkdir -p /u01/oracle/oradata/pu/
[oracle@localhost oracle]$ mkdir -p /u01/oracle/fast_recovery_area/pu/
使用a服务器上拷贝过来的pfile启动数据库到nomount状态(如果服务器的配置不同,记得调整pfile中记录的内存数值,否则会提示内存不支持错误)
SQL> startup nomount pfile='/u01/initpu.ora';
ORACLE instance started.
Total System Global Area 1068937216 bytes
Fixed Size 2235208 bytes
Variable Size 918553784 bytes
Database Buffers 142606336 bytes
Redo Buffers 5541888 bytes
登陆rman恢复controlfile
[oracle@localhost ~]$ rman target /
Recovery Manager: Release 11.2.0.3.0 - Production on Wed Jul 6 13:52:18 2016
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: PU (not mounted)
RMAN> restore controlfile from '/u01/o1_mf_ncnn0_TAG20160706T111222_cqrxvpr1_.bkp';
Starting restore at 06-JUL-16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=19 device type=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/u01/oracle/oradata/pu/control01.ctl
output file name=/u01/oracle/fast_recovery_area/pu/control02.ctl
Finished restore at 06-JUL-16
打开数据库到mount状态
RMAN> alter database mount;
database mounted
released channel: ORA_DISK_1
RMAN>
还原数据文件
[oracle@localhost ~]$ rman target /
Recovery Manager: Release 11.2.0.3.0 - Production on Wed Jul 6 14:12:41 2016
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: PU (DBID=2744947428, not open)
RMAN> restore database;
Starting restore at 06-JUL-16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=18 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=1 device type=DISK
RMAN-00571: ====