(即将一个库还原到另外一台主机)目标库与源库实例名相同
本实验是将一个库还原到另外一个库。
说明:
源库: 192.168.10.11 ORACLE_SID=PROD1 DBID=2148633869
目标库:192.168.10.88 ORACLE_SID=PROD1
1.准备工作
RMAN> show all;
using target database control file instead of recovery catalog
RMAN configuration parameters for database with db_unique_name PROD1 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 '%F'; # default
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 MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/snapcf_PROD1.f'; # default
RMAN> backup as backupset database;
Starting backup at 21-DEC-16
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=37 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/app/oracle/oradata/PROD1/system01.dbf
input datafile file number=00002 name=/u01/app/oracle/oradata/PROD1/sysaux01.dbf
input datafile file number=00005 name=/u01/app/oracle/oradata/PROD1/example01.dbf
input datafile file number=00003 name=/u01/app/oracle/oradata/PROD1/undotbs01.dbf
input datafile file number=00006 name=/u01/app/oracle/oradata/PROD1/ts_setnew01.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/PROD1/users01.dbf
channel ORA_DISK_1: starting piece 1 at 21-DEC-16
channel ORA_DISK_1: finished piece 1 at 21-DEC-16
piece handle=/u01/app/oracle/fast_recovery_area/PROD1/backupset/2016_12_21/o1_mf_nnndf_TAG20161221T170142_d5nk7prp_.bkp tag=TAG20161221T170142 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:15
Finished backup at 21-DEC-16
Starting Control File and SPFILE Autobackup at 21-DEC-16
piece handle=/u01/app/oracle/fast_recovery_area/PROD1/autobackup/2016_12_21/o1_mf_s_931194117_d5nk85w5_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 21-DEC-16
2.拷贝RMAN备份文件
在目标库创建相同目录并将源库RMAN备份文件拷贝到目标库
[oracle@enmo ~]$ mkdir -p /u01/app/oracle/fast_recovery_area/PROD1/backupset/2016_12_21
[oracle@enmo ~]$ mkdir -p /u01/app/oracle/fast_recovery_area/PROD1/autobackup/2016_12_21
[oracle@host01 ~]$ cd /u01/app/oracle/fast_recovery_area/PROD1/backupset/2016_12_21
[oracle@host01 2016_12_21]$ ls o1_mf_nnndf_TAG20161221T170142_d5nk7prp_.bkp
o1_mf_nnndf_TAG20161221T170142_d5nk7prp_.bkp
[oracle@host01 2016_12_21]$ scp o1_mf_nnndf_TAG20161221T170142_d5nk7prp_.bkp oracle@192.168.10.88:/u01/app/oracle/fast_recovery_area/PROD1/backupset/2016_12_21
oracle@192.168.10.88's password:
o1_mf_nnndf_TAG20161221T170142_d5nk7prp_.bkp 100% 1157MB 29.7MB/s 00:39
[oracle@host01 ~]$ cd /u01/app/oracle/fast_recovery_area/PROD1/autobackup/2016_12_21
[oracle@host01 2016_12_21]$ ls o1_mf_s_931194117_d5nk85w5_.bkp
o1_mf_s_931194117_d5nk85w5_.bkp
[oracle@host01 2016_12_21]$ scp o1_mf_s_931194117_d5nk85w5_.bkp oracle@192.168.10.88:/u01/app/oracle/fast_recovery_area/PROD1/autobackup/2016_12_21/
oracle@192.168.10.88's password:
o1_mf_s_931194117_d5nk85w5_.bkp
3.配置目标库
目标库设置环境变量,启动rman到nomount状态,设置dbid(即源库dbid)
本实验设置为与源库SID一致
[oracle@enmo ~]$ echo $ORACLE_SID
ENMO
[oracle@enmo ~]$ export ORACLE_SID=PROD1
[oracle@enmo ~]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Wed Dec 21 17:14:47 2016
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database (not started)
RMAN> set dbid 2148633869
executing command: SET DBID
4.目标库启动到nomount模式
此时会报错,原因是,目标库没有参数文件,但也是能启动到nomount模式,分配内存、启动后台进程
RMAN> startup nomount;
startup failed: ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/initPROD1.ora'
starting Oracle instance without parameter file for retrieval of spfile
Oracle instance started
Total System Global Area 1068937216 bytes
Fixed Size 2260088 bytes
Variable Size 281019272 bytes
Database Buffers 780140544 bytes
Redo Buffers 5517312 bytes
5.恢复参数文件
恢复的pfile文件
RMAN> restore spfile to pfile '?/dbs/initPROD1.ora' from '/u01/app/oracle/fast_recovery_area/PROD1/autobackup/2016_12_21/o1_mf_s_931194117_d5nk85w5_.bkp';
Starting restore at 21-DEC-16
using channel ORA_DISK_1
channel ORA_DISK_1: restoring spfile from AUTOBACKUP /u01/app/oracle/fast_recovery_area/PROD1/autobackup/2016_12_21/o1_mf_s_931194117_d5nk85w5_.bkp
channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
Finished restore at 21-DEC-16
[oracle@enmo dbs]$ ls initPROD1.ora
initPROD1.ora
[oracle@enmo dbs]$ cat initPROD1.ora
PROD1.__db_cache_size=369098752
PROD1.__java_pool_size=4194304
PROD1.__large_pool_size=8388608
PROD1.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
PROD1.__pga_aggregate_target=310378496
PROD1.__sga_target=528482304
PROD1.__shared_io_pool_size=0
PROD1.__shared_pool_size=134217728
PROD1.__streams_pool_size=4194304
*.audit_file_dest='/u01/app/oracle/admin/PROD1/adump'
*.audit_trail='db'
*.compatible='11.2.0.4.0'
*.control_files='/u01/app/oracle/oradata/PROD1/control01.ctl','/u01/app/oracle/fast_recovery_area/PROD1/control02.ctl'#Restore Controlfile
*.db_block_size=8192
*.db_domain=''
*.db_name='PROD1'
*.db_recovery_file_dest='/u01/app/oracle/fast_recovery_area'
*.db_recovery_file_dest_size=4385144832
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=PROD1XDB)'
*.log_archive_dest_1='location=/u01/app/backup'
*.memory_target=838860800
*.nls_date_format='yyyy-mm-dd hh24:mi:ss'
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.undo_tablespace='UNDOTBS1'
目标库ORACLE_SID与源库相同,所以不需要修改pfile参数文件;需要注意一点,即使改了ORACLE_SID,
在修改pfile参数文件时唯一不能改的是db_name的值。
根据pfile文件创建相应的目录
[oracle@enmo ~]$ mkdir -p /u01/app/oracle/admin/PROD1/adump
[oracle@enmo ~]$ mkdir -p /u01/app/oracle/oradata/PROD1/
[oracle@enmo ~]$ mkdir -p /u01/app/oracle/fast_recovery_area/PROD1
6.通过pfile启动数据库到nomount模式,测试pfile是否有修改参数
[oracle@enmo ~]$ export ORACLE_SID=PROD1
[oracle@enmo ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Wed Dec 21 17:36:29 2016
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
SYS@PROD1> show parameter pfile;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
spfile string
7.生成spfile
SYS@PROD1> create spfile from pfile;
File created.
SYS@PROD1> shutdown immediate;
ORA-01507: database not mounted
ORACLE instance shut down.
SYS@PROD1> startup nomount;
ORACLE instance started.
Total System Global Area 835104768 bytes
Fixed Size 2257840 bytes
Variable Size 520096848 bytes
Database Buffers 310378496 bytes
Redo Buffers 2371584 bytes
SYS@PROD1> show parameter pfile;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
spfile string /u01/app/oracle/product/11.2.0
/dbhome_1/dbs/spfilePROD1.ora
8.还原控制文件
[oracle@enmo ~]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Wed Dec 21 17:39:01 2016
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: PROD1 (not mounted)
RMAN> restore controlfile from '/u01/app/oracle/fast_recovery_area/PROD1/autobackup/2016_12_21/o1_mf_s_931194117_d5nk85w5_.bkp';
Starting restore at 21-DEC-16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=20 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/app/oracle/oradata/PROD1/control01.ctl
output file name=/u01/app/oracle/fast_recovery_area/PROD1/control02.ctl
Finished restore at 21-DEC-16
[oracle@enmo ~]$ cd /u01/app/oracle/oradata/PROD1/
[oracle@enmo PROD1]$ ls control01.ctl
control01.ctl
[oracle@enmo PROD1]$ cd /u01/app/oracle/fast_recovery_area/PROD1/
[oracle@enmo PROD1]$ ls control02.ctl
control02.ctl
SYS@PROD1> alter database mount;
Database altered.
9. 还原数据文件set newname操作
(即将数据文件转换路径到/u01/app/oracle/oradata/PROD1/下)
SYS@PROD1> ed 001
run{
set newname for datafile 1 to '/u01/app/oracle/oradata/PROD1/system01.dbf';
set newname for datafile 2 to '/u01/app/oracle/oradata/PROD1/sysaux01.dbf';
set newname for datafile 3 to '/u01/app/oracle/oradata/PROD1/undotbs01.dbf';
set newname for datafile 4 to '/u01/app/oracle/oradata/PROD1/users01.dbf';
set newname for datafile 5 to '/u01/app/oracle/oradata/PROD1/example01.dbf';
set newname for datafile 6 to '/u01/app/oracle/oradata/PROD1/ts_setnew01.dbf';
restore database;
switch datafile all;
recover database;
}
RMAN> run{
2> set newname for datafile 1 to '/u01/app/oracle/oradata/PROD1/system01.dbf';
3> set newname for datafile 2 to '/u01/app/oracle/oradata/PROD1/sysaux01.dbf';
4> set newname for datafile 3 to '/u01/app/oracle/oradata/PROD1/undotbs01.dbf';
5> set newname for datafile 4 to '/u01/app/oracle/oradata/PROD1/users01.dbf';
6> set newname for datafile 5 to '/u01/app/oracle/oradata/PROD1/example01.dbf';
7> set newname for datafile 6 to '/u01/app/oracle/oradata/PROD1/ts_setnew01.dbf';
8> restore database;
9> switch datafile all;
10> recover database;
11> }
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting restore at 21-DEC-16
Starting implicit crosscheck backup at 21-DEC-16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=20 device type=DISK
Crosschecked 8 objects
Finished implicit crosscheck backup at 21-DEC-16
Starting implicit crosscheck copy at 21-DEC-16
using channel ORA_DISK_1
Crosschecked 1 objects
Finished implicit crosscheck copy at 21-DEC-16
searching for all files in the recovery area
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: /u01/app/oracle/fast_recovery_area/PROD1/archivelog/2016_12_15/o1_mf_1_1_d54hk4l5_.arc
File Name: /u01/app/oracle/fast_recovery_area/PROD1/backupset/2016_11_18/o1_mf_nnndf_TAG20161118T175002_d2xmpbcy_.bkp
File Name: /u01/app/oracle/fast_recovery_area/PROD1/autobackup/2016_11_18/o1_mf_s_928259427_d2xmq3hr_.bkp
File Name: /u01/app/oracle/fast_recovery_area/PROD1/autobackup/2016_12_21/o1_mf_s_931194117_d5nk85w5_.bkp
File Name: /u01/app/oracle/fast_recovery_area/PROD1/autobackup/2016_11_29/o1_mf_s_929207478_d3tkkp7v_.bkp
File Name: /u01/app/oracle/fast_recovery_area/PROD1/autobackup/2016_11_29/o1_mf_s_929208145_d3tl6k2n_.bkp
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 /u01/app/oracle/oradata/PROD1/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /u01/app/oracle/oradata/PROD1/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/PROD1/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/PROD1/users01.dbf
channel ORA_DISK_1: restoring datafile 00005 to /u01/app/oracle/oradata/PROD1/example01.dbf
channel ORA_DISK_1: restoring datafile 00006 to /u01/app/oracle/oradata/PROD1/ts_setnew01.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/PROD1/backupset/2016_12_21/o1_mf_nnndf_TAG20161221T170142_d5nk7prp_.bkp
channel ORA_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/PROD1/backupset/2016_12_21/o1_mf_nnndf_TAG20161221T170142_d5nk7prp_.bkp tag=TAG20161221T170142
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:25
Finished restore at 21-DEC-16
Starting recover at 21-DEC-16
using channel ORA_DISK_1
starting media recovery
unable to find archived log
archived log thread=1 sequence=1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 12/21/2016 17:52:36
RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 1 and starting SCN of 1132956
此处我们会发现,在recover的时候,由于没有归档日志,所以,提示只能恢复到SCN 1132956
SYS@PROD1> ed 002
run{
set until scn 1132956;
restore database;
switch datafile all;
recover database;
}
RMAN> run{
2> set until scn 1132956;
3> restore database;
4> switch datafile all;
5> recover database;
6> }
executing command: SET until clause
Starting restore at 21-DEC-16
using channel ORA_DISK_1
skipping datafile 1; already restored to file /u01/app/oracle/oradata/PROD1/system01.dbf
skipping datafile 2; already restored to file /u01/app/oracle/oradata/PROD1/sysaux01.dbf
skipping datafile 3; already restored to file /u01/app/oracle/oradata/PROD1/undotbs01.dbf
skipping datafile 4; already restored to file /u01/app/oracle/oradata/PROD1/users01.dbf
skipping datafile 5; already restored to file /u01/app/oracle/oradata/PROD1/example01.dbf
skipping datafile 6; already restored to file /u01/app/oracle/oradata/PROD1/ts_setnew01.dbf
restore not done; all files read only, offline, or already restored
Finished restore at 21-DEC-16
Starting recover at 21-DEC-16
using channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time: 00:00:00
Finished recover at 21-DEC-16
10.resetlogs方式打开数据库
SYS@PROD1> alter database open resetlogs;
Database altered.
11. 收尾工作
SYS@PROD1> select instance_name,status from v$instance;
INSTANCE_NAME STATUS
---------------- ------------
PROD1 OPEN
SYS@PROD1> select file_name from dba_temp_files;
FILE_NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/PROD1/temp01.dbf
SYS@PROD1> select member from v$logfile;
MEMBER
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/PROD1/redo03.log
/u01/app/oracle/oradata/PROD1/redo02.log
/u01/app/oracle/oradata/PROD1/redo01.log
SYS@PROD1> show parameter name;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
cell_offloadgroup_name string
db_file_name_convert string
db_name string PROD1
db_unique_name string PROD1
global_names boolean FALSE
instance_name string PROD1
lock_name_space string
log_file_name_convert string
processor_group_name string
service_names string PROD1
本实验是将一个库还原到另外一个库。
说明:
源库: 192.168.10.11 ORACLE_SID=PROD1 DBID=2148633869
目标库:192.168.10.88 ORACLE_SID=PROD1
1.准备工作
RMAN> show all;
using target database control file instead of recovery catalog
RMAN configuration parameters for database with db_unique_name PROD1 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 '%F'; # default
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 MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/snapcf_PROD1.f'; # default
RMAN> backup as backupset database;
Starting backup at 21-DEC-16
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=37 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/app/oracle/oradata/PROD1/system01.dbf
input datafile file number=00002 name=/u01/app/oracle/oradata/PROD1/sysaux01.dbf
input datafile file number=00005 name=/u01/app/oracle/oradata/PROD1/example01.dbf
input datafile file number=00003 name=/u01/app/oracle/oradata/PROD1/undotbs01.dbf
input datafile file number=00006 name=/u01/app/oracle/oradata/PROD1/ts_setnew01.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/PROD1/users01.dbf
channel ORA_DISK_1: starting piece 1 at 21-DEC-16
channel ORA_DISK_1: finished piece 1 at 21-DEC-16
piece handle=/u01/app/oracle/fast_recovery_area/PROD1/backupset/2016_12_21/o1_mf_nnndf_TAG20161221T170142_d5nk7prp_.bkp tag=TAG20161221T170142 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:15
Finished backup at 21-DEC-16
Starting Control File and SPFILE Autobackup at 21-DEC-16
piece handle=/u01/app/oracle/fast_recovery_area/PROD1/autobackup/2016_12_21/o1_mf_s_931194117_d5nk85w5_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 21-DEC-16
2.拷贝RMAN备份文件
在目标库创建相同目录并将源库RMAN备份文件拷贝到目标库
[oracle@enmo ~]$ mkdir -p /u01/app/oracle/fast_recovery_area/PROD1/backupset/2016_12_21
[oracle@enmo ~]$ mkdir -p /u01/app/oracle/fast_recovery_area/PROD1/autobackup/2016_12_21
[oracle@host01 ~]$ cd /u01/app/oracle/fast_recovery_area/PROD1/backupset/2016_12_21
[oracle@host01 2016_12_21]$ ls o1_mf_nnndf_TAG20161221T170142_d5nk7prp_.bkp
o1_mf_nnndf_TAG20161221T170142_d5nk7prp_.bkp
[oracle@host01 2016_12_21]$ scp o1_mf_nnndf_TAG20161221T170142_d5nk7prp_.bkp oracle@192.168.10.88:/u01/app/oracle/fast_recovery_area/PROD1/backupset/2016_12_21
oracle@192.168.10.88's password:
o1_mf_nnndf_TAG20161221T170142_d5nk7prp_.bkp 100% 1157MB 29.7MB/s 00:39
[oracle@host01 ~]$ cd /u01/app/oracle/fast_recovery_area/PROD1/autobackup/2016_12_21
[oracle@host01 2016_12_21]$ ls o1_mf_s_931194117_d5nk85w5_.bkp
o1_mf_s_931194117_d5nk85w5_.bkp
[oracle@host01 2016_12_21]$ scp o1_mf_s_931194117_d5nk85w5_.bkp oracle@192.168.10.88:/u01/app/oracle/fast_recovery_area/PROD1/autobackup/2016_12_21/
oracle@192.168.10.88's password:
o1_mf_s_931194117_d5nk85w5_.bkp
3.配置目标库
目标库设置环境变量,启动rman到nomount状态,设置dbid(即源库dbid)
本实验设置为与源库SID一致
[oracle@enmo ~]$ echo $ORACLE_SID
ENMO
[oracle@enmo ~]$ export ORACLE_SID=PROD1
[oracle@enmo ~]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Wed Dec 21 17:14:47 2016
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database (not started)
RMAN> set dbid 2148633869
executing command: SET DBID
4.目标库启动到nomount模式
此时会报错,原因是,目标库没有参数文件,但也是能启动到nomount模式,分配内存、启动后台进程
RMAN> startup nomount;
startup failed: ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/initPROD1.ora'
starting Oracle instance without parameter file for retrieval of spfile
Oracle instance started
Total System Global Area 1068937216 bytes
Fixed Size 2260088 bytes
Variable Size 281019272 bytes
Database Buffers 780140544 bytes
Redo Buffers 5517312 bytes
5.恢复参数文件
恢复的pfile文件
RMAN> restore spfile to pfile '?/dbs/initPROD1.ora' from '/u01/app/oracle/fast_recovery_area/PROD1/autobackup/2016_12_21/o1_mf_s_931194117_d5nk85w5_.bkp';
Starting restore at 21-DEC-16
using channel ORA_DISK_1
channel ORA_DISK_1: restoring spfile from AUTOBACKUP /u01/app/oracle/fast_recovery_area/PROD1/autobackup/2016_12_21/o1_mf_s_931194117_d5nk85w5_.bkp
channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
Finished restore at 21-DEC-16
[oracle@enmo dbs]$ ls initPROD1.ora
initPROD1.ora
[oracle@enmo dbs]$ cat initPROD1.ora
PROD1.__db_cache_size=369098752
PROD1.__java_pool_size=4194304
PROD1.__large_pool_size=8388608
PROD1.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
PROD1.__pga_aggregate_target=310378496
PROD1.__sga_target=528482304
PROD1.__shared_io_pool_size=0
PROD1.__shared_pool_size=134217728
PROD1.__streams_pool_size=4194304
*.audit_file_dest='/u01/app/oracle/admin/PROD1/adump'
*.audit_trail='db'
*.compatible='11.2.0.4.0'
*.control_files='/u01/app/oracle/oradata/PROD1/control01.ctl','/u01/app/oracle/fast_recovery_area/PROD1/control02.ctl'#Restore Controlfile
*.db_block_size=8192
*.db_domain=''
*.db_name='PROD1'
*.db_recovery_file_dest='/u01/app/oracle/fast_recovery_area'
*.db_recovery_file_dest_size=4385144832
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=PROD1XDB)'
*.log_archive_dest_1='location=/u01/app/backup'
*.memory_target=838860800
*.nls_date_format='yyyy-mm-dd hh24:mi:ss'
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.undo_tablespace='UNDOTBS1'
目标库ORACLE_SID与源库相同,所以不需要修改pfile参数文件;需要注意一点,即使改了ORACLE_SID,
在修改pfile参数文件时唯一不能改的是db_name的值。
根据pfile文件创建相应的目录
[oracle@enmo ~]$ mkdir -p /u01/app/oracle/admin/PROD1/adump
[oracle@enmo ~]$ mkdir -p /u01/app/oracle/oradata/PROD1/
[oracle@enmo ~]$ mkdir -p /u01/app/oracle/fast_recovery_area/PROD1
6.通过pfile启动数据库到nomount模式,测试pfile是否有修改参数
[oracle@enmo ~]$ export ORACLE_SID=PROD1
[oracle@enmo ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Wed Dec 21 17:36:29 2016
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
SYS@PROD1> show parameter pfile;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
spfile string
7.生成spfile
SYS@PROD1> create spfile from pfile;
File created.
ORA-01507: database not mounted
ORACLE instance shut down.
SYS@PROD1> startup nomount;
ORACLE instance started.
Total System Global Area 835104768 bytes
Fixed Size 2257840 bytes
Variable Size 520096848 bytes
Database Buffers 310378496 bytes
Redo Buffers 2371584 bytes
SYS@PROD1> show parameter pfile;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
spfile string /u01/app/oracle/product/11.2.0
/dbhome_1/dbs/spfilePROD1.ora
8.还原控制文件
[oracle@enmo ~]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Wed Dec 21 17:39:01 2016
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: PROD1 (not mounted)
RMAN> restore controlfile from '/u01/app/oracle/fast_recovery_area/PROD1/autobackup/2016_12_21/o1_mf_s_931194117_d5nk85w5_.bkp';
Starting restore at 21-DEC-16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=20 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/app/oracle/oradata/PROD1/control01.ctl
output file name=/u01/app/oracle/fast_recovery_area/PROD1/control02.ctl
Finished restore at 21-DEC-16
[oracle@enmo ~]$ cd /u01/app/oracle/oradata/PROD1/
[oracle@enmo PROD1]$ ls control01.ctl
control01.ctl
[oracle@enmo PROD1]$ cd /u01/app/oracle/fast_recovery_area/PROD1/
[oracle@enmo PROD1]$ ls control02.ctl
control02.ctl
SYS@PROD1> alter database mount;
Database altered.
9. 还原数据文件set newname操作
(即将数据文件转换路径到/u01/app/oracle/oradata/PROD1/下)
SYS@PROD1> ed 001
run{
set newname for datafile 1 to '/u01/app/oracle/oradata/PROD1/system01.dbf';
set newname for datafile 2 to '/u01/app/oracle/oradata/PROD1/sysaux01.dbf';
set newname for datafile 3 to '/u01/app/oracle/oradata/PROD1/undotbs01.dbf';
set newname for datafile 4 to '/u01/app/oracle/oradata/PROD1/users01.dbf';
set newname for datafile 5 to '/u01/app/oracle/oradata/PROD1/example01.dbf';
set newname for datafile 6 to '/u01/app/oracle/oradata/PROD1/ts_setnew01.dbf';
restore database;
switch datafile all;
recover database;
}
RMAN> run{
2> set newname for datafile 1 to '/u01/app/oracle/oradata/PROD1/system01.dbf';
3> set newname for datafile 2 to '/u01/app/oracle/oradata/PROD1/sysaux01.dbf';
4> set newname for datafile 3 to '/u01/app/oracle/oradata/PROD1/undotbs01.dbf';
5> set newname for datafile 4 to '/u01/app/oracle/oradata/PROD1/users01.dbf';
6> set newname for datafile 5 to '/u01/app/oracle/oradata/PROD1/example01.dbf';
7> set newname for datafile 6 to '/u01/app/oracle/oradata/PROD1/ts_setnew01.dbf';
8> restore database;
9> switch datafile all;
10> recover database;
11> }
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting restore at 21-DEC-16
Starting implicit crosscheck backup at 21-DEC-16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=20 device type=DISK
Crosschecked 8 objects
Finished implicit crosscheck backup at 21-DEC-16
Starting implicit crosscheck copy at 21-DEC-16
using channel ORA_DISK_1
Crosschecked 1 objects
Finished implicit crosscheck copy at 21-DEC-16
searching for all files in the recovery area
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: /u01/app/oracle/fast_recovery_area/PROD1/archivelog/2016_12_15/o1_mf_1_1_d54hk4l5_.arc
File Name: /u01/app/oracle/fast_recovery_area/PROD1/backupset/2016_11_18/o1_mf_nnndf_TAG20161118T175002_d2xmpbcy_.bkp
File Name: /u01/app/oracle/fast_recovery_area/PROD1/autobackup/2016_11_18/o1_mf_s_928259427_d2xmq3hr_.bkp
File Name: /u01/app/oracle/fast_recovery_area/PROD1/autobackup/2016_12_21/o1_mf_s_931194117_d5nk85w5_.bkp
File Name: /u01/app/oracle/fast_recovery_area/PROD1/autobackup/2016_11_29/o1_mf_s_929207478_d3tkkp7v_.bkp
File Name: /u01/app/oracle/fast_recovery_area/PROD1/autobackup/2016_11_29/o1_mf_s_929208145_d3tl6k2n_.bkp
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 /u01/app/oracle/oradata/PROD1/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /u01/app/oracle/oradata/PROD1/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/PROD1/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/PROD1/users01.dbf
channel ORA_DISK_1: restoring datafile 00005 to /u01/app/oracle/oradata/PROD1/example01.dbf
channel ORA_DISK_1: restoring datafile 00006 to /u01/app/oracle/oradata/PROD1/ts_setnew01.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/PROD1/backupset/2016_12_21/o1_mf_nnndf_TAG20161221T170142_d5nk7prp_.bkp
channel ORA_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/PROD1/backupset/2016_12_21/o1_mf_nnndf_TAG20161221T170142_d5nk7prp_.bkp tag=TAG20161221T170142
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:25
Finished restore at 21-DEC-16
Starting recover at 21-DEC-16
using channel ORA_DISK_1
starting media recovery
unable to find archived log
archived log thread=1 sequence=1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 12/21/2016 17:52:36
RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 1 and starting SCN of 1132956
此处我们会发现,在recover的时候,由于没有归档日志,所以,提示只能恢复到SCN 1132956
SYS@PROD1> ed 002
run{
set until scn 1132956;
restore database;
switch datafile all;
recover database;
}
RMAN> run{
2> set until scn 1132956;
3> restore database;
4> switch datafile all;
5> recover database;
6> }
executing command: SET until clause
Starting restore at 21-DEC-16
using channel ORA_DISK_1
skipping datafile 1; already restored to file /u01/app/oracle/oradata/PROD1/system01.dbf
skipping datafile 2; already restored to file /u01/app/oracle/oradata/PROD1/sysaux01.dbf
skipping datafile 3; already restored to file /u01/app/oracle/oradata/PROD1/undotbs01.dbf
skipping datafile 4; already restored to file /u01/app/oracle/oradata/PROD1/users01.dbf
skipping datafile 5; already restored to file /u01/app/oracle/oradata/PROD1/example01.dbf
skipping datafile 6; already restored to file /u01/app/oracle/oradata/PROD1/ts_setnew01.dbf
restore not done; all files read only, offline, or already restored
Finished restore at 21-DEC-16
Starting recover at 21-DEC-16
using channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time: 00:00:00
Finished recover at 21-DEC-16
10.resetlogs方式打开数据库
SYS@PROD1> alter database open resetlogs;
Database altered.
11. 收尾工作
SYS@PROD1> select instance_name,status from v$instance;
INSTANCE_NAME STATUS
---------------- ------------
PROD1 OPEN
SYS@PROD1> select file_name from dba_temp_files;
FILE_NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/PROD1/temp01.dbf
SYS@PROD1> select member from v$logfile;
MEMBER
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/PROD1/redo03.log
/u01/app/oracle/oradata/PROD1/redo02.log
/u01/app/oracle/oradata/PROD1/redo01.log
SYS@PROD1> show parameter name;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
cell_offloadgroup_name string
db_file_name_convert string
db_name string PROD1
db_unique_name string PROD1
global_names boolean FALSE
instance_name string PROD1
lock_name_space string
log_file_name_convert string
processor_group_name string
service_names string PROD1
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/31400681/viewspace-2131152/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/31400681/viewspace-2131152/