RMAN備份與恢復之spfile


1.備份spfile

  有關控制文件及參數文件備份的幾種形式:
  • 單獨備份控制文件及參數文件
    RMAN> backup current controlfile;
  • 備份數據文件時包含控制文件
    RMAN> backup datafile 4 include current controlfile;
  • 單獨備份spfile

2.恢復spfile

  SPFILE參數文件可以在RMAN中進行備份,因此可以使用RMAN來恢復SPFILE文件。可以自動備份SPFILE,SPFILE的自動備份是隨着控制文件的備份一起被完成的,因此可以通過自動備份控制文件來實現自動備份SPFILE文件的目的。

  其次,在備份系統表空間時將引發控制文件的自動備份,而不論是否設置自動備份參數為ON,此時同樣也備份SPFILE文件

SPFILE文件恢復步驟

1)  startup nomount [force];

2)  set dbid=dbid_no;

3)  restore spfile from autobackup | '<dir>'

4)  startup;

  下面設定控制文件的自動備份以及設置其備份路徑(注意要預先知道目標數據庫的DBID,此次事例的DBID為1420421951)。

 

  本例以單獨備份,一般可將RMAN配置信息controlfile 配置為自動備份,則任務備份工作時,都將自動備份controlfile,spfile。

[oracle@ZTE-TEST144239 ~]$ rman target / nocatalog

Recovery Manager: Release 11.2.0.3.0 - Production on Fri Oct 16 11:20:49 2015

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

connected to target database: ORCL (DBID=1420421951)
using target database control file instead of recovery catalog

RMAN>  backup spfile format '/data2/backup/sp_%d_%U';

Starting backup at 16-OCT-15
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=14 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=5 device type=DISK
allocated channel: ORA_DISK_3
channel ORA_DISK_3: SID=138 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 16-OCT-15
channel ORA_DISK_1: finished piece 1 at 16-OCT-15
piece handle=/data2/backup/sp_ORCL_2hqjrkkt_1_1 tag=TAG20151016T112100 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 16-OCT-15

Starting Control File and SPFILE Autobackup at 16-OCT-15
piece handle=/u01/app/oracle/fast_recovery_area/ORCL/autobackup/2015_10_16/o1_mf_s_893244062_c20v8zor_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 16-OCT-15
1.1備份spfile(單獨備份)
可指定路徑,備份多份
RMAN> backup copies 2 device type disk spfile format '/u01/app/oracle/fast_recovery_area/ORCL/sp_%d_%T_%U';

Starting backup at 16-OCT-15
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 16-OCT-15
channel ORA_DISK_1: finished piece 1 at 16-OCT-15 with 2 copies and tag TAG20151016T120250
piece handle=/u01/app/oracle/fast_recovery_area/ORCL/sp_ORCL_20151016_2rqjrn3a_1_1 comment=NONE
piece handle=/u01/app/oracle/fast_recovery_area/ORCL/sp_ORCL_20151016_2rqjrn3a_1_2 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 16-OCT-15

Starting Control File and SPFILE Autobackup at 16-OCT-15
piece handle=/u01/app/oracle/fast_recovery_area/ORCL/autobackup/2015_10_16/o1_mf_s_893246571_c20xqfbk_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 16-OCT-15
1.2備份多份spfile的方法
Recovery Manager complete.
[oracle@ZTE-TEST144239 ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.3.0 Production on Fri Oct 16 14:13:25 2015
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, OLAP, Data Mining and Real Application Testing options

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@ZTE-TEST144239 ~]$ cd $ORACLE_HOME/dbs
[oracle@ZTE-TEST144239 dbs]$ mv spfileorcl.ora spfileorcl.ora.bak
2.1試驗刪除spfile
[oracle@ZTE-TEST144239 ~]$ rman target / nocatalog

Recovery Manager: Release 11.2.0.3.0 - Production on Fri Oct 16 14:15:49 2015
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
connected to target database (not started)

RMAN> startup nomount force;

startup failed: ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/u01/app/oracle/product/11.2.0/db_1/dbs/initorcl.ora'

starting Oracle instance without parameter file for retrieval of spfile
Oracle instance started

Total System Global Area     158662656 bytes

Fixed Size                     2226456 bytes
Variable Size                130025192 bytes
Database Buffers              20971520 bytes
Redo Buffers                   5439488 bytes

RMAN> set DBID=1420421951;                                                       
executing command: SET DBID

RMAN> restore spfile from '/u01/app/oracle/fast_recovery_area/ORCL/sp_ORCL_20151016_2rqjrn3a_1_1';
Starting restore at 16-OCT-15
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=429 device type=DISK

channel ORA_DISK_1: restoring spfile from AUTOBACKUP /u01/app/oracle/fast_recovery_area/ORCL/sp_ORCL_20151016_2rqjrn3a_1_1
channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
Finished restore at 16-OCT-15
2.1恢復spfile
[oracle@TEST144239 /]$ sqlplus /nolog
SQL*Plus: Release 11.2.0.3.0 Production on Fri Oct 16 14:44:32 2015
Copyright (c) 1982, 2011, Oracle.  All rights reserved.
SQL> conn scott/Sina.2015@study
Connected.
SQL> select * from dual;
D
-
X
3.結果

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM