控制檔案的備份和恢復

anycall2010發表於2008-09-16

控制檔案有兩種常用的備份和恢復方法:

方法一:引數檔案轉儲:

SQL>create pfile='/oracle/pfile.txt' from spfile;

當資料庫不能啟動的時候,可以使用

SQL>startup pfile='/oracle/pfile.txt' 就可以使資料庫啟動。

方法二:RMAN自動備份的辦法:

1、配置RMAN的自動備份(預設情況下是關閉的)

RMAN>configure controlfile autobackup on;

2、察看是否有自動備份功能:

SQL> select * from v$rman_configuration;

     CONF# NAME
---------- -----------------------------------------------------------------
VALUE
--------------------------------------------------------------------------------
         1 CONTROLFILE AUTOBACKUP
ON
3、備份資料庫:

RMAN> backup database;

Starting backup at 15-SEP-08
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=39 devtype=DISK
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/oracle/oradata/dg1/system01.dbf
input datafile fno=00003 name=/oracle/oradata/dg1/sysaux01.dbf
input datafile fno=00005 name=/oracle/oradata/dg1/example01.dbf
input datafile fno=00002 name=/oracle/oradata/dg1/undotbs01.dbf
input datafile fno=00004 name=/oracle/oradata/dg1/users01.dbf
channel ORA_DISK_1: starting piece 1 at 15-SEP-08
channel ORA_DISK_1: finished piece 1 at 15-SEP-08
piece handle=/oracle/product/10.2.0/dbs/03jqleub_1_1 tag=TAG20080915T131659 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:26
Finished backup at 15-SEP-08

Starting Control File and SPFILE Autobackup at 15-SEP-08
piece handle=/oracle/product/10.2.0/dbs/c-1646839347-20080915-00 comment=NONE
Finished Control File and SPFILE Autobackup at 15-SEP-08

注意控制檔案的命名方法:

C-IIIIIIIIII-YYYYMMDD-QQ

C表示“控制檔案”

IIIIIIIIII表示資料庫的DBID

YYYYMMDD表示時間

QQ表示序號00-FF(16進位制)

4、設定資料庫不能啟動的情況:

SQL> alter system set db_block_buffers=10000000 scope=spfile;

System altered.

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORA-00371: not enough shared pool memory, should be atleast 2568715059 bytes

5、編輯PFILE檔案:

[oracle@dg1 dbs]$ mv spfiledg1.ora  spfiledg1.orabak

[oracle@dg1 dbs]$ mv  init.ora  initdg1.ora

為什麼要這麼做:因為資料庫首先查詢$ORALCE_HOME/dbs 下spfile.ora;如果沒有則查詢spfile.ora;如果還沒有,則查詢init.ora

編輯init.ora中db_name='dg1'

6.啟動RMAN(以前有備份的檔案)


[oracle@dg1 dbs]$ rman target /

Recovery Manager: Release 10.2.0.1.0 - Production on Mon Sep 15 14:08:15 2008

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

connected to target database: dg1 (not mounted)

RMAN> startup nomount;

Oracle instance started

Total System Global Area     100663296 bytes

Fixed Size                     1217908 bytes
Variable Size                 92277388 bytes
Database Buffers               4194304 bytes
Redo Buffers                   2973696 bytes

RMAN> restore spfile to '/oracle/spfile1.ora' from autobackup;

Starting restore at 15-SEP-08
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=46 devtype=DISK

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 09/15/2008 14:08:59
RMAN-06495: must explicitly specify DBID with SET DBID command

當不能指定DBID的情況下,自動恢復是不能成功的!

7、手工指定恢復的檔案集:

[oracle@dg1 dbs]$ rman target /

Recovery Manager: Release 10.2.0.1.0 - Production on Mon Sep 15 13:52:51 2008

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

connected to target database (not started)

RMAN> startup nomount;

Oracle instance started

Total System Global Area     100663296 bytes

Fixed Size                     1217908 bytes
Variable Size                 92277388 bytes
Database Buffers               4194304 bytes
Redo Buffers                   2973696 bytes

RMAN> restore spfile to '/oracle/spfile.ora' from 'c-1646839347-20080915-00';

Starting restore at 15-SEP-08
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=47 devtype=DISK

channel ORA_DISK_1: autobackup found: c-1646839347-20080915-00
channel ORA_DISK_1: SPFILE restore from autobackup complete
Finished restore at 15-SEP-08

最後,成功將控制檔案恢復。。。。。。



來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/8334342/viewspace-448477/,如需轉載,請註明出處,否則將追究法律責任。

相關文章