当前位置:操作系统 > Unix/Linux >>

还原种子数据库练习

还原种子数据库练习
 
种子数据库的控制文件位置:
$ORACLE_HOME/assistants/dbca/templates/Seed_Database.ctl

 

种子数据库的备份片位置:
$ORACLE_HOME/assistants/dbca/templates/Seed_Database.dfb

 

大体步骤如下:
编辑一个pfile启动到nomount,然后通过控制文件启动到mount状态,恢复数据库文件,然后启动数据库。
 
1.随便编辑一个pfile,只添加上Db_name和控制文件路径即可
[oracle@elvis-desktop dbs]$ vi initORCL.ora
db_name='ORCL'
control_files='/oracle/oradata/ORCL/control1.ctl'
2.定义一个ORACLE_SID,创建存放数据库文件的目录
[oracle@elvis-desktop dbs]$ export ORACLE_SID=ORCL
[oracle@elvis-desktop dbs]$ mkdir /oracle/oradata/ORCL/
3.把种子数据库的控制文件拷贝到pfile中的路径,并且修改成相应的名字,使用pfile启动到nomount状态
[oracle@elvis-desktop dbs]$ rman target /
Recovery Manager: Release 11.2.0.3.0 - Production on Thu Sep 5 13:45:33 2013
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database (not started)
RMAN> startup nomount pfile='/oracle/product/11.2.0/dbhome_1/dbs/initORCL.ora';
Oracle instance started
Total System Global Area 238034944 bytes
Fixed Size 2227136 bytes
Variable Size 180356160 bytes
Database Buffers 50331648 bytes
Redo Buffers 5120000 bytes
4.启动数据库到mount状态
RMAN> alter database mount;
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of alter db command at 09/05/2013 13:52:32
ORA-01103: database name 'SEEDDATA' in control file is not 'ORCL'
------->>>此处报数据库的名字为SEEDDATA,将pfile中的db_name修改成SEEDDATA,重启数据库,启动到mount状态
[oracle@elvis-desktop dbs]$ vi initORCL.ora
db_name='SEEDDATA'
control_files='/oracle/oradata/ORCL/control01.ctl'
RMAN> alter database mount;
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of alter db command at 09/05/2013 13:53:12
ORA-01103: database name 'SEEDDATA' in control file is not 'ORCL'
RMAN> shutdown abort;
Oracle instance shut down
RMAN> startup nomount pfile='/oracle/product/11.2.0/dbhome_1/dbs/initORCL.ora';
connected to target database (not started)
Oracle instance started
Total System Global Area 238034944 bytes
Fixed Size 2227136 bytes
Variable Size 180356160 bytes
Database Buffers 50331648 bytes
Redo Buffers 5120000 bytes
RMAN> alter database mount;
database mounted
5.注册数据库备份片的位置,开始恢复数据库
RMAN> catalog start with '/oracle/product/11.2.0/dbhome_1/assistants/dbca/templates/Seed_Database.dfb';
searching for all files that match the pattern /oracle/product/11.2.0/dbhome_1/assistants/dbca/templates/Seed_Database.dfb
List of Files Unknown to the Database
=====================================
File Name: /oracle/product/11.2.0/dbhome_1/assistants/dbca/templates/Seed_Database.dfb
Do you really want to catalog the above files (enter YES or NO)? YES
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: /oracle/product/11.2.0/dbhome_1/assistants/dbca/templates/Seed_Database.dfb
RMAN> crosscheck backup; ----->>>检查备份集的有效性
using channel ORA_DISK_1
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=/ade/b/385031636/oracle/oradata/Seed_Database.dfb RECID=1 STAMP=762085401
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/oracle/product/11.2.0/dbhome_1/assistants/dbca/templates/Seed_Database.dfb RECID=2 STAMP=825342912
Crosschecked 2 objects
RMAN> delete expired backup; ----->>>>删除过期备份
using channel ORA_DISK_1
List of Backup Pieces
BP Key BS Key Pc# Cp# Status Device Type Piece Name
------- ------- --- --- ----------- ----------- ----------
1 1 1 1 EXPIRED DISK /ade/b/385031636/oracle/oradata/Seed_Database.dfb
Do you really want to delete the above objects (enter YES or NO)? YES
deleted backup piece
backup piece handle=/ade/b/385031636/oracle/oradata/Seed_Database.dfb RECID=1 STAMP=762085401
Deleted 1 EXPIRED objects
RMAN> list backup; ----->>>>检查备份集的相关信息
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
1 Full 253.38M DISK 00:00:58 17-SEP-11
BP Key: 2 Status: AVAILABLE Compressed: YES Tag:
Piece Name: /oracle/product/11.2.0/dbhome_1/assistants/dbca/templates/Seed_Database.dfb
List of Datafiles in backup set 1
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 995547 17-SEP-11 /ade/b/385031636/oracle/oradata/seeddata/system01.dbf
2 Full 995547 17-SEP-11 /ade/b/385031636/oracle/oradata/seeddata/sysaux01.dbf
3 Full 995547 17-SEP-11 /ade/b/385031636/oracle/oradata/seeddata/undotbs01.dbf
4 Full 995547 17-SEP-11 /ade/b/385031636/oracle/oradata/seeddata/users01.dbf
------->>>上述检查后,我们就该知道要修改数据文件的名字到新的目录
RMAN> restore database;
Starting restore at 05-SEP-13
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to /ade/b/385031636/oracle/oradata/seeddata/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /ade/b/385031636/oracle/oradata/seeddata/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /ade/b/385031636/oracle/oradata/seeddata/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /ade/b/385031636/oracle/oradata/seeddata/users01.dbf
channel ORA_DISK_1: reading from backup piece /oracle/product/11.2.0/dbhome_1/assistants/dbca/templates/Seed_Database.dfb
channel ORA_DISK_1: ORA-19870: error while restoring backup piece /oracle/product/11.2.0/dbhome_1/assistants/dbca/templates/Seed_Database.dfb
ORA-19504: failed to create file "/ade/b/385031636/oracle/oradata/seeddata/system01.dbf"
ORA-27040: file create error, unable to create file
Linux-x86_64 Error: 2: No such file or directory
Additional information: 1
failover to previous backup
creating datafile file number=1 name=/ade/b/385031636/oracle/oradata/seeddata/system01.dbf
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 09/05/2013 13:59:56
ORA-01180: can not create datafile 1
ORA-01110: data file 1: '/ade/b/385031636/oracle/oradata/seeddata/system01.dbf'
-------------------->>>>果然提示报错,不能创建相关的目录。我们要修改到指定的位置/oracle/oradata/ORCL/
-------------------->>>>修改数据库文件名字,switch datafile all就是更新控制文件的意思
RMAN> run
{
set newname for datafile '/ade/b/385031636/oracle/oradata/seeddata/system01.dbf' to '/oracle/oradata/ORCL/system01.dbf';
set newname for datafile '/ade/b/385031636/oracle/oradata/seeddata/sysaux01.dbf' to '/oracle/oradata/ORCL/sysaux01.dbf';
set newname for datafile '/ade/b/385031636/oracle/oradata/seeddata/undotbs01.dbf' to '/oracle/oradata/ORCL/undotbs01.dbf';
set newname for datafile '/ade/b/385031636/oracle/oradata/seeddata/users01.dbf' to '/oracle/oradata/ORCL/users01.dbf';
restore database;
switch datafile all;
recover database;
}
executing command: SET NEWNAME
executing command: SET NEWNAME
ex
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,