channel ORA_DISK_1: looking for AUTOBACKUP on day: 20171230
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20171229
channel ORA_DISK_1: AUTOBACKUP found: /ora_xtts/rman/c-2655496871-20171229-00
channel ORA_DISK_1: restoring spfile from AUTOBACKUP /ora_xtts/rman/c-2655496871-20171229-00
channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
Finished restore at 30-DEC-17
Oracle instance shut down
9.编辑pfile参数文件并修改所需要的参数。这包括compatible参数,如果目标数据库的compatible参数不同于源数据库的设置,那么在目标数据库版本中这个参数会被弃用。更新以_DEST结尾的参数来反映新的目录结构。
[oracle@jytest3 dbs]$ mv initjyrac1.ora initjyrac1.ora.bak
[oracle@jytest3 dbs]$ vi initjyrac1.ora
*.audit_file_dest='/u01/app/oracle/admin/jyrac/adump'
*.audit_trail='db'
*.cluster_database=false
*.compatible='11.2.0.4.0'
*.control_files='+DATA/jyrac/controlfile/current.257.930412709'
*.db_block_size=8192
*.db_create_file_dest='+DATA'
*.db_domain=''
*.db_name='jyrac'
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=jyracXDB)'
jyrac1.dispatchers='(PROTOCOL=TCP) (SERVICE=jyrac1XDB)'
jyrac1.instance_number=1
*.job_queue_processes=1000
*.log_archive_dest_1='location=+data/arch/jyrac'
*.open_cursors=300
*.pga_aggregate_target=836763648
*.processes=150
*.remote_login_passwordfile='exclusive'
*.sga_target=2510290944
jyrac2.thread=2
jyrac1.thread=1
jyrac1.undo_tablespace='UNDOTBS1'
jyrac2.undo_tablespace='UNDOTBS2'
10.使用编辑后的pfile参数文件来启动实例到nomount状态
RMAN> startup force nomount pfile='/u01/app/oracle/product/12.2.0/db/dbs/initjyrac1.ora'
Oracle instance started
Total System Global Area 2516582400 bytes
Fixed Size 8623832 bytes
Variable Size 637536552 bytes
Database Buffers 1862270976 bytes
Redo Buffers 8151040 bytes
11.从控制文件自动备份文件中还原控制文件并将目标数据库启动到mount状态,为了还原非缺省格式的自动备份,需要执行set controlfile autobackup format命令来指定格式。
RMAN> run
2> {
3> set controlfile autobackup format for device type disk to '/ora_xtts/rman/%F';
4> restore controlfile from autobackup;
5> alter database mount;
6> }
executing command: SET CONTROLFILE AUTOBACKUP FORMAT
Starting restore at 30-DEC-17
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=6 device type=DISK
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20171230
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20171229
channel ORA_DISK_1: AUTOBACKUP found: /ora_xtts/rman/c-2655496871-20171229-00
channel ORA_DISK_1: restoring control file from AUTOBACKUP /ora_xtts/rman/c-2655496871-20171229-00
channel ORA_DISK_1: control file restore from AUTOBACKUP complete
output file name=+DATA/JYRAC/CONTROLFILE/current.329.964063767
Finished restore at 30-DEC-17
Statement processed
released channel: ORA_DISK_1
控制文件会被还原到pfile参数文件中control_files参数所指定的目录中。
12.在目标主机上将源数据库的备份文件注册到rman档案库中。如果目录中的所有文件有共同的前缀,那么可以使用catalog start with命令。如果想要单独指定文件名来进行注册,那么执行catalog datafilecopy命令。我这里所有的备份文件存储在/ora_xtts/rman目录中,因此使用catalog start with命令进行注册。
RMAN> catalog start with '/ora_xtts/rman/';
searching for all files that match the pattern /ora_xtts/rman/
List of Files Unknown to the Database
=====================================
File Name: /ora_xtts/rman/arch_JYRAC_20171229_0isnb48r_1_1
File Name: /ora_xtts/rman/arch_JYRAC_20171229_0ksnb4q5_1_1
File Name: /ora_xtts/rman/c-2655496871-20171229-00
File Name: /ora_xtts/rman/jyrac_0jsnb48u_JYRAC_964006174_19_1
Do you really want to catalog the above files (enter YES or NO)? YES
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: /ora_xtts/rman/arch_JYRAC_20171229_0isnb48r_1_1
File Name: /ora_xtts/rman/arch_JYRAC_20171229_0ksnb4q5_1_1
File Name: /ora_xtts/rman/c-2655496871-20171229-00
File Name: /ora_xtts/rman/jyrac_0jsnb48u_JYRAC_964006174_19_1
13.还原与恢复源数据库
如果数据文件要被还原到目标主机上的目录与源数据库所在的目录不相同,那么必须使用set newname命令来对还原的数据文件指定新的目录路径。如果联机重做日志将创建在与源数据库不相同的目录中,那么必须使用alter database rename file命令来为每个联机重做日志指定新的目录路径,在这里使用set newname for database命令来为所有被还原的数据文件指定新目录,新的联机重做日志文件使用alter database rename file命令来指定,并且指定恢复目标scn。