博客首页 » Oracle 最简单的RMAN配置、备份及恢复(3) - 使用rman备份从零恢复数据库
发布于 04 Sep 2013 08:48
标签 backup-restore blog oracle rman
Oracle无疑是一个复杂的软件,不过它的基本使用远没有这么复杂。其中RMAN是Oracle的备份软件。在上两篇文章中,分别介绍了备份和删除数据库的方法。本文介绍恢复方法。使用方法如下。
使用rman备份从零恢复数据库
准备环境设置及创建目录
设定SID
export ORACLE_SID=test02t
根据数据库需要创建目录,如果不知道目录的话,可以在restore spfile这步以后用sqlplus的show parameter察看相应目录
mkdir -p /u01/oradata/test02t
mkdir -p /u02/oradata/test02t
mkdir -p /u03/oradata/test02t
mkdir -p /u04/oradata/test02t
mkdir -p /u01/oracle/app/admin/test02t/adump
mkdir -p /u01/oracle/app/admin/test02t/bdump
mkdir -p /u01/oracle/app/admin/test02t/cdump
mkdir -p /u01/oracle/app/admin/test02t/udump
mkdir -p /u01/oracle/app/admin/test02t/utldir
准备最初的文件
创建init file
echo db_name=test02t > /tmp/inittest02t.ora
找到备份集中的controlfile autobackup,并且copy到$ORACLE_HOME/dbs下,并且保持%F的形式,也就是去掉多余的前缀后缀。
cp -a /u04/oradata/test02t/rman/current/ctl_c-2513594778-20130904-00.bak $ORACLE_HOME/dbs/c-2513594778-20130904-00
restore spfile
rman target / startup nomount; set dbid=2513594778 restore spfile from autobackup; shutdown immediate;
restore controlfile
#rm /u01/oracle/app/oracle/product/10.2.0/db_1/dbs/inittest02t.ora
startup nomount; restore controlfile from autobackup; shutdown immediate;
restore, recover and open database
startup mount; restore database; recover database; alter database open resetlogs;
详细log如下
[scripts oracle@test03] export ORACLE_SID=test02t [scripts oracle@test03] echo db_name=test02t > /tmp/inittest02t.ora [scripts oracle@test03] cp -a /u04/oradata/test02t/rman/current/ctl_c-2513594778-20130904-00.bak $ORACLE_HOME/dbs/c-2513594778-20130904-00 [scripts oracle@test03] rman target / Recovery Manager: Release 10.2.0.4.0 - Production on Wed Sep 4 17:12:18 2013 Copyright (c) 1982, 2007, Oracle. All rights reserved. connected to target database: test02t (not mounted) RMAN> startup nomount pfile=/tmp/inittest02t.ora; connected to target database (not started) Oracle instance started Total System Global Area 2097152000 bytes Fixed Size 2085224 bytes Variable Size 553651864 bytes Database Buffers 1526726656 bytes Redo Buffers 14688256 bytes RMAN> set dbid=2513594778 executing command: SET DBID RMAN> restore spfile from autobackup; Starting restore at 04-SEP-13 using channel ORA_DISK_1 channel ORA_DISK_1: looking for autobackup on day: 20130904 channel ORA_DISK_1: autobackup found: c-2513594778-20130904-00 channel ORA_DISK_1: SPFILE restore from autobackup complete Finished restore at 04-SEP-13 RMAN> shutdown immediate; Oracle instance shut down RMAN> set dbid=2513594778 executing command: SET DBID RMAN> startup nomount; connected to target database (not started) Oracle instance started Total System Global Area 2097152000 bytes Fixed Size 2085224 bytes Variable Size 553651864 bytes Database Buffers 1526726656 bytes Redo Buffers 14688256 bytes RMAN> restore controlfile from autobackup; Starting restore at 04-SEP-13 allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=155 devtype=DISK channel ORA_DISK_1: looking for autobackup on day: 20130904 channel ORA_DISK_1: autobackup found: c-2513594778-20130904-00 channel ORA_DISK_1: control file restore from autobackup complete output filename=/u02/oradata/test02t/control01.ctl output filename=/u02/oradata/test02t/control02.ctl output filename=/u02/oradata/test02t/control03.ctl Finished restore at 04-SEP-13 RMAN> shutdown immediate; Oracle instance shut down RMAN> startup mount; connected to target database (not started) Oracle instance started database mounted Total System Global Area 2097152000 bytes Fixed Size 2085224 bytes Variable Size 553651864 bytes Database Buffers 1526726656 bytes Redo Buffers 14688256 bytes RMAN> restore database; Starting restore at 04-SEP-13 allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=156 devtype=DISK channel ORA_DISK_1: starting datafile backupset restore channel ORA_DISK_1: specifying datafile(s) to restore from backup set restoring datafile 00001 to /u02/oradata/test02t/system01.dbf restoring datafile 00002 to /u02/oradata/test02t/undotbs01.dbf restoring datafile 00003 to /u02/oradata/test02t/sysaux01.dbf restoring datafile 00004 to /u02/oradata/test02t/users01.dbf channel ORA_DISK_1: reading from backup piece /u04/oradata/test02t/rman/current/bk_test02t_03oj141h_1_1_20130904.bkp channel ORA_DISK_1: restored backup piece 1 piece handle=/u04/oradata/test02t/rman/current/bk_test02t_03oj141h_1_1_20130904.bkp tag=TAG20130904T163705 channel ORA_DISK_1: restore complete, elapsed time: 00:00:25 Finished restore at 04-SEP-13 RMAN> RMAN> recover database; Starting recover at 04-SEP-13 using channel ORA_DISK_1 starting media recovery channel ORA_DISK_1: starting archive log restore to default destination channel ORA_DISK_1: restoring archive log archive log thread=1 sequence=33 channel ORA_DISK_1: reading from backup piece /u04/oradata/test02t/rman/current/bk_test02t_04oj1420_1_1_20130904.bkp channel ORA_DISK_1: restored backup piece 1 piece handle=/u04/oradata/test02t/rman/current/bk_test02t_04oj1420_1_1_20130904.bkp tag=TAG20130904T163720 channel ORA_DISK_1: restore complete, elapsed time: 00:00:02 archive log filename=/u04/oradata/ipadlbst/arch/1_33_825193754.dbf thread=1 sequence=33 unable to find archive log archive log thread=1 sequence=34 RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03002: failure of recover command at 09/04/2013 17:23:11 RMAN-06054: media recovery requesting unknown log: thread 1 seq 34 lowscn 566180 RMAN> alter database open resetlogs; database opened RMAN> quit Recovery Manager complete.
本系列文章列表
Oracle 最简单的RMAN配置、备份及恢复(2) - 备份数据库
http://oracle-abc.wikidot.com/zh-blog:26
Oracle 最简单的RMAN配置、备份及恢复(2) - 刪除数据库
http://oracle-abc.wikidot.com/zh-blog:27
Oracle 最简单的RMAN配置、备份及恢复(3) - 使用rman备份从零恢复数据库
http://oracle-abc.wikidot.com/zh-blog:28
本页面的文字允许在知识共享 署名-相同方式共享 3.0协议和GNU自由文档许可证下修改和再使用,仅有一个特殊要求,请用链接方式注明文章引用出处及作者。请协助维护作者合法权益。
系列文章
文章列表
- Oracle 最简单的RMAN配置、备份及恢复(3) - 使用rman备份从零恢复数据库
这篇文章对你有帮助吗,投个票吧?
留下你的评论