首页 > Linux操作系统 > Linux操作系统 > 控制文件的备份和恢复
控制文件有两种常用的备份和恢复方法:
方法一:参数文件转储:
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
编辑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博客 ” ,链接:https://blog.itpub.net/8334342/viewspace-448477/ ,如需转载,请注明出处,否则将追究法律责任。