Oracle9i新特点-SPFILE的使用

Oracle9i新特点:SPFILE的使用

--How to backup and restore spfile and controlfile using autobackup option

Last Updated: Wednesday, 2004-10-27 0:40 Eygle


|

本文发表于itpub技术丛书《Oracle数据库DBA专题技术精粹》,未经许可,严禁转载本文.

原文出处:

http://www.eygle.com/faq/Oracle9i.New.Feature.Spfile.04.htm

六. SPFILE的备份与恢复

在本文开篇我们提到,Oracle把Spfile也纳入到Rman的备份恢复策略当中,如果你配置了控制文件自动备份(autoback),那么Oracle会
在数据库发生重大变化(如增减表空间)时自动进行控制文件及Spfile文件的备份。

下面我们来看一下这个过程:
a. 设置控制文件自动备份:

|

> [oracle@jumper oracle]$ rman target / > > Recovery Manager: Release 9.2.0.3.0 - Production > > Copyright (c) 1995, 2002, Oracle Corporation. All rights reserved. > > connected to target database: HSJF (DBID=1052178311) > > RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON; > > using target database controlfile instead of recovery catalog
> old RMAN configuration parameters:
> CONFIGURE CONTROLFILE AUTOBACKUP OFF;
> new RMAN configuration parameters:
> CONFIGURE CONTROLFILE AUTOBACKUP ON;
> new RMAN configuration parameters are successfully stored > > RMAN> exit


这个设置可以在数据库中通过如下方式查询得到:

> >
> > [oracle@jumper bdump]$ sqlplus "/ as sysdba" > > SQL*Plus: Release 9.2.0.3.0 - Production on Sat Jan 17 01:08:05 2004 > > Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
> > > Connected to:
> Oracle9i Enterprise Edition Release 9.2.0.3.0 - Production
> With the Partitioning, OLAP and Oracle Data Mining options
> JServer Release 9.2.0.3.0 - Production > > SQL> select * from v$rman_configuration;
> CONF# NAME VALUE
> ---------- ------------------------- ----------
> 1 CONTROLFILE AUTOBACKUP ON >
>
>   >


b. 记录数据库变化

> >   > > SQL> create tablespace eygle
> 2 datafile '/data1/oracle/oradata/eygle01.dbf'
> 3 size 5M; > > Tablespace created. >
>
>   >


如果新创建一个表空间,这时候检查alert

  1<sid>.log文件,你可以在其中发现这样的备份信息:   
  2
  3
  4&gt; 
  5&gt;     Sat Jan 17 00:55:57 2004  
  6&gt;     &gt; Starting control autobackup  
  7&gt;     &gt; Control autobackup written to DISK device  
  8&gt;     &gt; handle '/opt/oracle/product/9.2.0/dbs/c-1052178311-20040117-00'  
  9&gt;     &gt; Completed: create tablespace eygle  
 10&gt;     &gt; datafile '/data1/oracle/oradata/eygle01.dbf’
 11&gt;                             
 12  
 13---  
 14  
 15如果使用rman进行备份,在提示中你可以看到如下信息: 
 16
 17&gt; 
 18&gt;     
 19&gt; 
 20&gt; RMAN&gt; configure controlfile autobackup on; 
 21&gt; 
 22&gt; old RMAN configuration parameters:   
 23&gt;  CONFIGURE CONTROLFILE AUTOBACKUP OFF;   
 24&gt;  new RMAN configuration parameters:   
 25&gt;  CONFIGURE CONTROLFILE AUTOBACKUP ON;   
 26&gt;  new RMAN configuration parameters are successfully stored 
 27&gt; 
 28&gt; RMAN&gt; run   
 29&gt;  2&gt; {   
 30&gt;  3&gt; allocate channel ch1 type disk format='e:\oracle\orabak\penny%t.arc';   
 31&gt;  4&gt; backup archivelog all delete all input;   
 32&gt;  5&gt; release channel ch1;   
 33&gt;  6&gt; } 
 34&gt; 
 35&gt; allocated channel: ch1   
 36&gt;  channel ch1: sid=13 devtype=DISK 
 37&gt; 
 38&gt; Starting backup at 02-DEC-03   
 39&gt;  current log archived   
 40&gt;  channel ch1: starting archive log backupset   
 41&gt;  channel ch1: specifying archive log(s) in backup set   
 42&gt;  input archive log thread=1 sequence=63 recid=168 stamp=511712617   
 43&gt;  input archive log thread=1 sequence=64 recid=169 stamp=511712620   
 44&gt;  input archive log thread=1 sequence=65 recid=170 stamp=511712626   
 45&gt;  input archive log thread=1 sequence=66 recid=171 stamp=511712690   
 46&gt;  channel ch1: starting piece 1 at 02-DEC-03   
 47&gt;  channel ch1: finished piece 1 at 02-DEC-03   
 48&gt;  piece handle=E:\ORACLE\ORABAK\PENNY511712693.ARC comment=NONE   
 49&gt;  channel ch1: backup set complete, elapsed time: 00:00:03   
 50&gt;  channel ch1: deleting archive log(s)   
 51&gt;  archive log filename=E:\ORACLE\ORADATA\PENNY\ARCHIVE\1_63.DBF recid=168 stamp=511712617   
 52&gt;  archive log filename=E:\ORACLE\ORADATA\PENNY\ARCHIVE\1_64.DBF recid=169 stamp=511712620   
 53&gt;  archive log filename=E:\ORACLE\ORADATA\PENNY\ARCHIVE\1_65.DBF recid=170 stamp=511712626   
 54&gt;  archive log filename=E:\ORACLE\ORADATA\PENNY\ARCHIVE\1_66.DBF recid=171 stamp=511712690   
 55&gt;  Finished backup at 02-DEC-03 
 56&gt; 
 57&gt; Starting Control File and SPFILE Autobackup at 02-DEC-03   
 58&gt;  piece handle=E:\ORACLE\ORA92\DATABASE\C-3627775766-20031202-01 comment=NONE   
 59&gt;  Finished Control File and SPFILE Autobackup at 02-DEC-03 
 60&gt; 
 61&gt; released channel: ch1 
 62&gt;     
 63&gt;     
 64&gt;      
 65&gt;                               
 66  
 67---  
 68  
 69我们简单看一下自动备份的控制文件及spfile文件的格式及命名规则:   
 70c-IIIIIIIIII-YYYYMMDD-QQ   
 71c ------------------------控制文件   
 72IIIIIIIIII---------DBID   
 73YYYYMMDD------------时间戳   
 74QQ----------------------序号00-FF,16进制表示 
 75
 76c. 使用自动备份恢复spfile文件 
 77
 78&gt; 
 79&gt;     
 80&gt; 
 81&gt; [oracle@jumper bdump]$ rman target / 
 82&gt; 
 83&gt; Recovery Manager: Release 9.2.0.3.0 - Production 
 84&gt; 
 85&gt; Copyright (c) 1995, 2002, Oracle Corporation. All rights reserved. 
 86&gt; 
 87&gt; connected to target database: HSJF (DBID=1052178311) 
 88&gt; 
 89&gt; RMAN&gt; restore spfile to '/tmp/spfileeygle.ora' from autobackup; 
 90&gt; 
 91&gt; Starting restore at 17-JAN-04 
 92&gt; 
 93&gt; using target database controlfile instead of recovery catalog   
 94&gt;  allocated channel: ORA_DISK_1   
 95&gt;  channel ORA_DISK_1: sid=18 devtype=DISK   
 96&gt;  channel ORA_DISK_1: looking for autobackup on day: 20040117   
 97&gt;  channel ORA_DISK_1: autobackup found: c-1052178311-20040117-01   
 98&gt;  channel ORA_DISK_1: SPFILE restore from autobackup complete   
 99&gt;  Finished restore at 17-JAN-04 
100&gt; 
101&gt; RMAN&gt; exit   
102&gt; 
103&gt; 
104&gt; Recovery Manager complete.   
105&gt;  [oracle@jumper bdump]$ ls -l /tmp/spfileeygle.ora   
106&gt;  -rw-r----- 1 oracle dba 3584 1月 17 09:34 /tmp/spfileeygle.ora 
107&gt;     
108&gt;     
109&gt;      
110&gt;                               
111  
112---  
113  
114你同样可以通过这种方法恢复控制文件,示例如下: 
115
116&gt; 
117&gt;     
118&gt; 
119&gt; [oracle@jumper bdump]$ rman target / 
120&gt; 
121&gt; Recovery Manager: Release 9.2.0.3.0 - Production 
122&gt; 
123&gt; Copyright (c) 1995, 2002, Oracle Corporation. All rights reserved. 
124&gt; 
125&gt; connected to target database: HSJF (DBID=1052178311) 
126&gt; 
127&gt; RMAN&gt; **restore controlfile to '/tmp/control01.ctl' from autobackup;**
128&gt; 
129&gt; Starting restore at 17-JAN-04 
130&gt; 
131&gt; using target database controlfile instead of recovery catalog   
132&gt;  allocated channel: ORA_DISK_1   
133&gt;  channel ORA_DISK_1: sid=10 devtype=DISK   
134&gt;  channel ORA_DISK_1: looking for autobackup on day: 20040117   
135&gt;  channel ORA_DISK_1: autobackup found: c-1052178311-20040117-02   
136&gt;  channel ORA_DISK_1: controlfile restore from autobackup complete   
137&gt;  Finished restore at 17-JAN-04 
138&gt; 
139&gt; RMAN&gt; exit   
140&gt; 
141&gt; 
142&gt; Recovery Manager complete.   
143&gt;  [oracle@jumper bdump]$ ls -l /tmp/control*   
144&gt;  -rw-r----- 1 oracle dba 1892352 1月 17 09:44 /tmp/control01.ctl 
145&gt;     
146&gt;     
147&gt;      
148&gt;                               
149  
150---  
151  
152Oracle9i自动备份控制文件的功能给我们带来了极大的收益,通过自动备份,在数据库出现紧急状况的时候,你可能可以从这个自动备份中获得更   
153为有效及时的控制文件. 
154
155缺省的,这个自动备份功能是关闭的,你可以用我们上面提到的方法打开该功能.   
156  
157  
158  
159
160
161&lt;&lt;上一页  下一页&gt;&gt;
162
163本文作者:   
164eygle,Oracle技术关注者,来自中国最大的Oracle技术论坛  itpub  .   
165www.eygle.com  是作者的个人站点.你可通过  [email protected]  来联系作者.欢迎技术探讨交流以及链接交换. 
166
167* * *
168
169原文出处: 
170
171http://www.eygle.com/faq/Oracle9i.New.Feature.Spfile.04.htm</sid>
Published At
Categories with 数据库类
Tagged with
comments powered by Disqus