使用RMAN的备份及恢复--丢失所有控制文件及数据文件

[复制链接]
查看11 | 回复9 | 2013-11-21 16:35:25 | 显示全部楼层 |阅读模式
1.数据库基本信息:
SQL> select * from v$version;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
PL/SQL Release 11.2.0.3.0 - Production
CORE11.2.0.3.0Production
TNS for Linux: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Production
SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
/opt/ora11g/oradata/chen/system01.dbf
/opt/ora11g/oradata/chen/sysaux01.dbf
/opt/ora11g/oradata/chen/undotbs01.dbf
/opt/ora11g/oradata/chen/users01.dbf
SQL> archive log list;
Database log mode
Archive Mode
Automatic archival
Enabled
Archive destination
/opt/ora11g/oradata/arch
Oldest online log sequence 1
Next log sequence to archive 3
Current log sequence 3
SQL> select name from v$archived_log;
NAME
--------------------------------------------------------------------------------
/opt/ora11g/oradata/arch/00010000000001791096419.arc
/opt/ora11g/oradata/arch/00010000000002791096419.arc
SQL> select name from v$controlfile;
NAME
--------------------------------------------------------------------------------
/opt/ora11g/oradata/chen/control01.ctl
/opt/ora11g/oradata/chen/control02.ctl
/opt/ora11g/oradata/chen/control03.ctl
2.启用控制文件的自动备份:
[oracle@localhost ~]$ rman target /
Recovery Manager: Release 11.2.0.3.0 - Production on 3 23:54:22 2012
Copyright (c) 1982, 2011, Oracle and/or its affiliates.All rights reserved.
connected to target database: NEWCHEN (DBID=2466066852)
RMAN> configure controlfile autobackup on;
using target database control file instead of recovery catalog
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters are successfully stored
RMAN> exit
Recovery Manager complete.
3.执行RMAN全备份:
[oracle@localhost backup]$ rman target /
Recovery Manager: Release 11.2.0.3.0 - Production on 3 23:56:46 2012
Copyright (c) 1982, 2011, Oracle and/or its affiliates.All rights reserved.
connected to target database: NEWCHEN (DBID=2466066852)
RMAN> run {
2> backup database
3> format '/opt/ora11g/oradata/backup/full_%d_%T_%s'
4> plus archivelog
5> format '/opt/ora11g/oradata/backup/arch_%d_%T_%s'
6> ;}
Starting backup at 24-812
current log archived
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=43 device type=DISK
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=1 RECID=1 STAMP=792114570
input archived log thread=1 sequence=2 RECID=2 STAMP=792114644
input archived log thread=1 sequence=3 RECID=3 STAMP=792115236
channel ORA_DISK_1: starting piece 1 at 24-812
channel ORA_DISK_1: finished piece 1 at 24-812
piece handle=/opt/ora11g/oradata/backup/arch_NEWCHEN_20120824_1 tag=TAG20120824T000037 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 24-812
Starting backup at 24-812
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/opt/ora11g/oradata/chen/system01.dbf
input datafile file number=00002 name=/opt/ora11g/oradata/chen/sysaux01.dbf
input datafile file number=00003 name=/opt/ora11g/oradata/chen/undotbs01.dbf
input datafile file number=00004 name=/opt/ora11g/oradata/chen/users01.dbf
channel ORA_DISK_1: starting piece 1 at 24-812
channel ORA_DISK_1: finished piece 1 at 24-812
piece handle=/opt/ora11g/oradata/backup/full_NEWCHEN_20120824_2 tag=TAG20120824T000041 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:02:16
Finished backup at 24-812
Starting backup at 24-812
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=4 RECID=4 STAMP=792115380
channel ORA_DISK_1: starting piece 1 at 24-812
channel ORA_DISK_1: finished piece 1 at 24-812
piece handle=/opt/ora11g/oradata/backup/arch_NEWCHEN_20120824_3 tag=TAG20120824T000301 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 24-812
Starting Control File and SPFILE Autobackup at 24-812
piece
handle=/opt/ora11g/fast_recovery_area/NEWCHEN/autobackup/2012_08_24/o1_mf_s_792115382_83g9s89x_.bkp
comment=NONE
Finished Control File and SPFILE Autobackup at 24-812
RMAN>
4.移除所有控制文件及数据文件:
[oracle@localhost dbs]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.3.0 Production on 4 00:08:08 2012
Copyright (c) 1982, 2011, Oracle.All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@localhost oradata]$ pwd
/opt/ora11g/oradata
[oracle@localhost oradata]$ ls
archbackupchen
[oracle@localhost oradata]$ mv chen chenbak
[oracle@localhost oradata]$ mkdir chen
[oracle@localhost oradata]$ ls
archbackupchenchenbak
[oracle@localhost oradata]$
5.从自动备份中恢复控制文件:
[oracle@localhost ~]$ rman target /
Recovery Manager: Release 11.2.0.3.0 - Production on 4 17:30:28 2012
Copyright (c) 1982, 2011, Oracle and/or its affiliates.All rights reserved.
connected to target database (not started)
RMAN> startup nomount;
Oracle instance started
Total System Global Area 196681728 bytes
Fixed Size
1343864 bytes
Variable Size
96472712 bytes
Database Buffers
96468992 bytes
Redo Buffers
2396160 bytes
RMAN> set dbid=2466066852
executing command: SET DBID
RMAN> restore controlfile from autobackup;
Starting restore at 24-812
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=19 device type=DISK
recovery area destination: /opt/ora11g/fast_recovery_area
database name (or database unique name) used for search: NEWCHEN
channel ORA_DISK_1: AUTOBACKUP
/opt/ora11g/fast_recovery_area/NEWCHEN/autobackup/2012_08_24/o1_mf_s_792115382_83g9s89x_.bkp found in
the recovery area
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20120824
channel ORA_DISK_1: restoring control file from AUTOBACKUP
/opt/ora11g/fast_recovery_area/NEWCHEN/autobackup/2012_08_24/o1_mf_s_792115382_83g9s89x_.bkp
channel ORA_DISK_1: control file restore from AUTOBACKUP complete
output file name=/opt/ora11g/oradata/chen/control01.ctl
output file name=/opt/ora11g/oradata/chen/control02.ctl
output file name=/opt/ora11g/oradata/chen/control03.ctl
Finished restore at 24-812
6.启动数据库到mount状态:
[oracle@localhost dbs]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.3.0 Production on 4 17:36:02 2012
Copyright (c) 1982, 2011, Oracle.All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> alter database mount;
Database altered.
7.使用rman进行恢复:
RMAN> restore database;
Starting restore at 24-812
released channel: ORA_DISK_1
Starting implicit crosscheck backup at 24-812
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=19 device type=DISK
Crosschecked 3 objects
Finished implicit crosscheck backup at 24-812
Starting implicit crosscheck copy at 24-812
using channel ORA_DISK_1
Finished implicit crosscheck copy at 24-812
searching for all files in the recovery area
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name:
/opt/ora11g/fast_recovery_area/NEWCHEN/autobackup/2012_08_24/o1_mf_s_792115382_83g9s89x_.bkp
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 /opt/ora11g/oradata/chen/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /opt/ora11g/oradata/chen/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /opt/ora11g/oradata/chen/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /opt/ora11g/oradata/chen/users01.dbf
channel ORA_DISK_1: reading from backup piece /opt/ora11g/oradata/backup/full_NEWCHEN_20120824_2
channel ORA_DISK_1: piece handle=/opt/ora11g/oradata/backup/full_NEWCHEN_20120824_2
tag=TAG20120824T000041
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:01:46
Finished restore at 24-812
RMAN> recover database;
Starting recover at 24-812
using channel ORA_DISK_1
starting media recovery
archived log for thread 1 with sequence 4 is already on disk as file
/opt/ora11g/oradata/arch/00010000000004791096419.arc
archived log file name=/opt/ora11g/oradata/arch/00010000000004791096419.arc thread=1 sequence=4
unable to find archived log
archived log thread=1 sequence=5
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 08/24/2012 17:43:44
RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 5 and starting
SCN of 808155
RMAN> alter database open resetlogs;
database opened
RMAN>
8.恢复完成:
SQL> select * from dual;
DU
--
X
SQL>

回复

使用道具 举报

千问 | 2013-11-21 16:35:25 | 显示全部楼层
不错,rman备份集一般都是放在catalog库上面~
可以继续研究下,加入spfile都丢了呢?那就nomount也到不了了,该咋整了?
回复

使用道具 举报

千问 | 2013-11-21 16:35:25 | 显示全部楼层
周应侯 发表于 2012-8-25 09:23
不错,rman备份集一般都是放在catalog库上面~
可以继续研究下,加入spfile都丢了呢?那就nomount也到不了 ...

我会继续研究的,spfile丢了,可以从告警日志中找到一些信息,然后手动创建pfile的~!!
回复

使用道具 举报

千问 | 2013-11-21 16:35:25 | 显示全部楼层
那你得手动编辑pfile,然后再生产spfile
现在你已经有了rman备份的spfile文件,那该怎样恢复呢?
回复

使用道具 举报

千问 | 2013-11-21 16:35:25 | 显示全部楼层
呵呵我以为是提问呢 原来是传授知识呢
回复

使用道具 举报

千问 | 2013-11-21 16:35:25 | 显示全部楼层
wiliiwin 发表于 2012-8-25 10:58
呵呵我以为是提问呢 原来是传授知识呢

嘿嘿,见笑了~!!
回复

使用道具 举报

千问 | 2013-11-21 16:35:25 | 显示全部楼层
周应侯 发表于 2012-8-25 09:40
那你得手动编辑pfile,然后再生产spfile
现在你已经有了rman备份的spfile文件,那该怎样恢复呢?

rman可以无参数文件启动数据库
然后就可以restore spfile了,spfile恢复之后就可以nomount了~!!
回复

使用道具 举报

千问 | 2013-11-21 16:35:25 | 显示全部楼层
liuxuelong007 发表于 2012-8-30 16:16
rman可以无参数文件启动数据库
然后就可以restore spfile了,spfile恢复之后就可以nomount了~!!

有这么简单吗?做个实验看看呗~
回复

使用道具 举报

千问 | 2013-11-21 16:35:25 | 显示全部楼层
最近要迁移数据库到另外一台新服务器,学习一下楼主的备份恢复方法


回复

使用道具 举报

千问 | 2013-11-21 16:35:25 | 显示全部楼层
clientor 发表于 2012-9-3 00:24
最近要迁移数据库到另外一台新服务器,学习一下楼主的备份恢复方法

嘿嘿,客气了~!!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行