RMAN备份与恢复之参数文件与控制文件
0 说明
本例是基于备份数据库全库的基础上,还原参数据文件(spfile),控制文件。
1 准备
[oracle@TEST144239 /]$ sqlplus /nolog SQL*Plus: Release 11.2.0.3.0 Production on Mon Oct 12 11:58:35 2015 Copyright (c) 1982, 2011, Oracle. All rights reserved. SQL> conn sys/Sina.2015@study as sysdba
Connected.
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /data2/orcl/recover_log/archive_log
Oldest online log sequence 22
Next log sequence to archive 24
Current log sequence 24
1.1检查数据库归档状态
[oracle@TEST144239 ~]$ rman target sys/Sina.2015@study
1.2RMAN登陆目标
2 备份数据库
通常默认在/u01/app/oracle/fast_recovery_area/ORCL/ ,若需要特定指定备份数据存储位置时,可以创建备份数据库存储的目录。
[oracle@TEST144239 /]$ mkdir /data2/backup
2.1创建备份数据存储目录
RMAN> backup as compressed backupset database plus archivelog; Starting backup at 12-OCT-15
current log archived
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
channel ORA_DISK_1: starting compressed archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=12 RECID=1 STAMP=892728339
input archived log thread=1 sequence=13 RECID=2 STAMP=892736557
input archived log thread=1 sequence=14 RECID=3 STAMP=892753270
input archived log thread=1 sequence=15 RECID=4 STAMP=892768262
channel ORA_DISK_1: starting piece 1 at 12-OCT-15
channel ORA_DISK_2: starting compressed archived log backup set
channel ORA_DISK_2: specifying archived log(s) in backup set
input archived log thread=1 sequence=16 RECID=5 STAMP=892791995
input archived log thread=1 sequence=17 RECID=6 STAMP=892803633
input archived log thread=1 sequence=18 RECID=7 STAMP=892815402
input archived log thread=1 sequence=19 RECID=8 STAMP=892828012
input archived log thread=1 sequence=20 RECID=9 STAMP=892843267
channel ORA_DISK_2: starting piece 1 at 12-OCT-15
channel ORA_DISK_3: starting compressed archived log backup set
channel ORA_DISK_3: specifying archived log(s) in backup set
input archived log thread=1 sequence=21 RECID=10 STAMP=892857631
input archived log thread=1 sequence=22 RECID=11 STAMP=892882839
input archived log thread=1 sequence=23 RECID=12 STAMP=892891106
input archived log thread=1 sequence=24 RECID=13 STAMP=892900945
input archived log thread=1 sequence=25 RECID=14 STAMP=892901057
input archived log thread=1 sequence=26 RECID=15 STAMP=892901228
input archived log thread=1 sequence=27 RECID=16 STAMP=892901372
input archived log thread=1 sequence=28 RECID=17 STAMP=892901532
channel ORA_DISK_3: starting piece 1 at 12-OCT-15
channel ORA_DISK_3: finished piece 1 at 12-OCT-15
piece handle=/u01/app/oracle/fast_recovery_area/ORCL/backupset/2015_10_12/o1_mf_annnn_TAG20151012T145139_c1pp3xr2_.bkp tag=TAG20151012T145139 comment=NONE
channel ORA_DISK_3: backup set complete, elapsed time: 00:00:15
channel ORA_DISK_3: starting compressed archived log backup set
channel ORA_DISK_3: specifying archived log(s) in backup set
input archived log thread=1 sequence=29 RECID=18 STAMP=892901677
input archived log thread=1 sequence=30 RECID=19 STAMP=892909146
input archived log thread=1 sequence=31 RECID=20 STAMP=892909170
input archived log thread=1 sequence=32 RECID=21 STAMP=892909211
input archived log thread=1 sequence=33 RECID=22 STAMP=892911098
channel ORA_DISK_3: starting piece 1 at 12-OCT-15
channel ORA_DISK_1: finished piece 1 at 12-OCT-15
piece handle=/u01/app/oracle/fast_recovery_area/ORCL/backupset/2015_10_12/o1_mf_annnn_TAG20151012T145139_c1pp3wp6_.bkp tag=TAG20151012T145139 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:20
channel ORA_DISK_2: finished piece 1 at 12-OCT-15
piece handle=/u01/app/oracle/fast_recovery_area/ORCL/backupset/2015_10_12/o1_mf_annnn_TAG20151012T145139_c1pp3ww1_.bkp tag=TAG20151012T145139 comment=NONE
channel ORA_DISK_2: backup set complete, elapsed time: 00:00:22
channel ORA_DISK_3: finished piece 1 at 12-OCT-15
piece handle=/u01/app/oracle/fast_recovery_area/ORCL/backupset/2015_10_12/o1_mf_annnn_TAG20151012T145139_c1pp4hhj_.bkp tag=TAG20151012T145139 comment=NONE
channel ORA_DISK_3: backup set complete, elapsed time: 00:00:06
Finished backup at 12-OCT-15 Starting backup at 12-OCT-15
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/data2/orcl/system01.dbf
input datafile file number=00003 name=/data2/orcl/undotbs01.dbf
channel ORA_DISK_1: starting piece 1 at 12-OCT-15
channel ORA_DISK_2: starting compressed full datafile backup set
channel ORA_DISK_2: specifying datafile(s) in backup set
input datafile file number=00002 name=/data2/orcl/sysaux01.dbf
input datafile file number=00004 name=/data2/orcl/users01.dbf
channel ORA_DISK_2: starting piece 1 at 12-OCT-15
channel ORA_DISK_2: finished piece 1 at 12-OCT-15
piece handle=/u01/app/oracle/fast_recovery_area/ORCL/backupset/2015_10_12/o1_mf_nnndf_TAG20151012T145203_c1pp4phv_.bkp tag=TAG20151012T145203 comment=NONE
channel ORA_DISK_2: backup set complete, elapsed time: 00:00:55
channel ORA_DISK_1: finished piece 1 at 12-OCT-15
piece handle=/u01/app/oracle/fast_recovery_area/ORCL/backupset/2015_10_12/o1_mf_nnndf_TAG20151012T145203_c1pp4o7j_.bkp tag=TAG20151012T145203 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:16
Finished backup at 12-OCT-15 Starting backup at 12-OCT-15
current log archived
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
channel ORA_DISK_1: starting compressed archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=34 RECID=23 STAMP=892911204
channel ORA_DISK_1: starting piece 1 at 12-OCT-15
channel ORA_DISK_1: finished piece 1 at 12-OCT-15
piece handle=/u01/app/oracle/fast_recovery_area/ORCL/backupset/2015_10_12/o1_mf_annnn_TAG20151012T145325_c1pp76vh_.bkp tag=TAG20151012T145325 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07
Finished backup at 12-OCT-15 Starting Control File and SPFILE Autobackup at 12-OCT-15
piece handle=/u01/app/oracle/fast_recovery_area/ORCL/autobackup/2015_10_12/o1_mf_s_892911216_c1pp7o9p_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 12-OCT-15
2.2RMAN备份全库
模拟数据库崩溃,删除控制文件,此时数据库还在继续运行,可能要过一会切换日志崩溃。这里我直接重启一下数据库
[oracle@TEST144239 orcl]$ cd /data2/orcl
[oracle@TEST144239 orcl]$ ll
总用量 1666384
-rw-r----- 1 oracle oinstall 9748480 10月 12 15:15 control01.ctl
drwxr-xr-x 3 oracle oinstall 4096 10月 10 10:48 recover_log
-rw-r----- 1 oracle oinstall 52429312 10月 12 14:53 redo01.log
-rw-r----- 1 oracle oinstall 52429312 10月 12 15:08 redo02.log
-rw-r----- 1 oracle oinstall 52429312 10月 12 15:15 redo03.log
-rw-r----- 1 oracle oinstall 681582592 10月 12 15:14 sysaux01.dbf
-rw-r----- 1 oracle oinstall 754982912 10月 12 15:14 system01.dbf
-rw-r----- 1 oracle oinstall 30416896 10月 12 14:33 temp01.dbf
-rw-r----- 1 oracle oinstall 94380032 10月 12 15:15 undotbs01.dbf
-rw-r----- 1 oracle oinstall 5251072 10月 12 15:13 users01.dbf
[oracle@TEST144239 orcl]$ mv control01.ctl control01.ctl.bak
[oracle@TEST144239 orcl]$ ll
总用量 1666384
-rw-r----- 1 oracle oinstall 9748480 10月 12 15:15 control01.ctl.bak
drwxr-xr-x 3 oracle oinstall 4096 10月 10 10:48 recover_log
-rw-r----- 1 oracle oinstall 52429312 10月 12 14:53 redo01.log
-rw-r----- 1 oracle oinstall 52429312 10月 12 15:08 redo02.log
-rw-r----- 1 oracle oinstall 52429312 10月 12 15:15 redo03.log
-rw-r----- 1 oracle oinstall 681582592 10月 12 15:15 sysaux01.dbf
-rw-r----- 1 oracle oinstall 754982912 10月 12 15:14 system01.dbf
-rw-r----- 1 oracle oinstall 30416896 10月 12 14:33 temp01.dbf
-rw-r----- 1 oracle oinstall 94380032 10月 12 15:15 undotbs01.dbf
-rw-r----- 1 oracle oinstall 5251072 10月 12 15:13 users01.dbf
SQL> startup force
ORACLE instance started. Total System Global Area 1937457152 bytes
Fixed Size 2229584 bytes
Variable Size 1241516720 bytes
Database Buffers 687865856 bytes
Redo Buffers 5844992 bytes
ORA-00205: error in identifying control file, check alert log for more info
2.3试验(模拟删除控制文件)
3 还原与恢复
$ORACLE_SID查看原来的SID。这里是假设原来$ORACLE_SID没设置的情况下:
[oracle@TEST144239 ~]$ export ORACLE_SID=test
[oracle@TEST144239 ~]$ echo $ORACLE_SID
test
[oracle@TEST144239 ~]$ rman target / Recovery Manager: Release 11.2.0.3.0 - Production on Mon Oct 12 15:45:22 2015 Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved. connected to target database (not started) RMAN> startup nomount startup failed: ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/u01/app/oracle/product/11.2.0/db_1/dbs/inittest.ora' starting Oracle instance without parameter file for retrieval of spfile Oracle instance started
Total System Global Area 158662656 bytes
Fixed Size 2226456 bytes
Variable Size 130025192 bytes
Database Buffers 20971520 bytes
Redo Buffers 5439488 bytes 此时查看下[oracle@TEST144239 orcl]$ cd /u01/app/oracle/product/11.2.0/db_1/dbs/ 中产生的文件:
[oracle@TEST144239 dbs]$ ll
总用量 9540
-rw-rw---- 1 oracle oinstall 1544 10月 12 15:18 hc_orcl.dat
-rw-r--r-- 1 oracle oinstall 2851 5月 15 2009 init.ora
-rw-r----- 1 oracle oinstall 0 10月 12 15:45 lkinsttest
-rw-r----- 1 oracle oinstall 24 10月 9 11:53 lkORCL
-rw-r----- 1 oracle oinstall 1536 10月 9 12:02 orapworcl
-rw-r----- 1 oracle oinstall 9748480 10月 12 14:53 snapcf_orcl.f
-rw-r----- 1 oracle oinstall 2560 10月 12 09:18 spfileorcl.ora
3.1假定没有设置Oracle_SID,设置Oracle_SID启动一个伪实例
从数据库备份集中还原spfile
RMAN> restore spfile from '/u01/app/oracle/fast_recovery_area/ORCL/autobackup/2015_10_12/o1_mf_s_892911216_c1pp7o9p_.bkp'; Starting restore at 12-OCT-15
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=429 device type=DISK channel ORA_DISK_1: restoring spfile from AUTOBACKUP /u01/app/oracle/fast_recovery_area/ORCL/autobackup/2015_10_12/o1_mf_s_892911216_c1pp7o9p_.bkp
channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
Finished restore at 12-OCT-15 此时参数文件恢复完成,此时,在DBS目录下有一个以当前oracle_sid.ora为后缀的参数文件:
[oracle@TEST144239 dbs]$ ll
总用量 9548
-rw-rw---- 1 oracle oinstall 1544 10月 12 15:18 hc_orcl.dat
-rw-rw---- 1 oracle oinstall 1544 10月 12 15:47 hc_test.dat
-rw-r--r-- 1 oracle oinstall 2851 5月 15 2009 init.ora
-rw-r----- 1 oracle oinstall 24 10月 9 11:53 lkORCL
-rw-r----- 1 oracle oinstall 1536 10月 9 12:02 orapworcl
-rw-r----- 1 oracle oinstall 9748480 10月 12 14:53 snapcf_orcl.f
-rw-r----- 1 oracle oinstall 2560 10月 12 09:18 spfileorcl.ora
-rw-r----- 1 oracle oinstall 2560 10月 12 15:47 spfiletest.ora
3.2还原spfile
从数据库备份集中还原控制文件
停掉伪实例,还原原来的参数文件名,原来是ORACLE_SID=orcl
RMAN> shutdown immediate
Oracle instance shut down
[oracle@TEST144239 dbs]$ mv spfiletest.ora spfileorcl.ora
[oracle@TEST144239 dbs]$ ll
总用量 9544
-rw-rw---- 1 oracle oinstall 1544 10月 12 15:18 hc_orcl.dat
-rw-rw---- 1 oracle oinstall 1544 10月 12 16:08 hc_test.dat
-rw-r--r-- 1 oracle oinstall 2851 5月 15 2009 init.ora
-rw-r----- 1 oracle oinstall 24 10月 9 11:53 lkORCL
-rw-r----- 1 oracle oinstall 1536 10月 9 12:02 orapworcl
-rw-r----- 1 oracle oinstall 9748480 10月 12 14:53 snapcf_orcl.f
-rw-r----- 1 oracle oinstall 2560 10月 12 15:47 spfileorcl.ora 还原控制文件:
[oracle@TEST144239 ~]$ export ORACLE_SID=orcl
[oracle@TEST144239 ~]$ rman target / Recovery Manager: Release 11.2.0.3.0 - Production on Mon Oct 12 16:16:03 2015 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 1937457152 bytes Fixed Size 2229584 bytes
Variable Size 1241516720 bytes
Database Buffers 687865856 bytes
Redo Buffers 5844992 bytes
RMAN> restore controlfile from '/u01/app/oracle/fast_recovery_area/ORCL/autobackup/2015_10_12/o1_mf_s_892911216_c1pp7o9p_.bkp'; Starting restore at 12-OCT-15
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=63 device type=DISK channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
output file name=/data2/orcl/control01.ctl
output file name=/u01/app/oracle/fast_recovery_area/orcl/control02.ctl
Finished restore at 12-OCT-15
3.3还原控制文件
RMAN> alter database mount; database mounted RMAN> alter database open;
3.4打开数据库
RMAN备份与恢复之参数文件与控制文件的更多相关文章
- 【RMAN】Oracle中如何备份控制文件?备份控制文件的方式有哪几种?
真题1. 如何备份控制文件?备份控制文件的方式有哪几种? 答案:备份控制文件的方式有多种. ① 备份控制文件可以在线进行: SQL> ALTER DATABASE BACKUP CONTROLF ...
- ORACLE体系结构一 (物理结构)- 数据文件、日志文件、控制文件和参数文件
一.物理结构Oracle物理结构包含了数据文件.日志文件.控制文件和参数文件 1.数据文件每一个ORACLE数据库有一个或多个物理的数据文件(data file).一个数据库的数据文件包含全部数据库数 ...
- 批量迁移Oracle数据文件,日志文件及控制文件
有些时候需要将Oracle的多个数据文件以及日志文件重定位或者迁移到新的分区或新的位置,比如磁盘空间不足,或因为特殊需求.对于这种情形可以采取批量迁移的方式将多个数据文件或者日志文件实现一次性迁移.当 ...
- RMAN备份之丢失数据文件及控制文件的恢复
About Recovery with a Backup Control FileIf all copies of the current control file are lost or damag ...
- RMAN恢复 增加表空间后控制文件丢失
查看目前的控制文件位置 SQL> select name from v$controlfile; NAME-------------------------------------------- ...
- 【Oracle】非RMAN恢复数据文件、控制文件
实验环境:OEL 5.6 oracle 11g(11.2.0.4.0) 注意: system表空间数据文件不能在线recover,需要启动到mount状态再recover: undo表空间数据文件可以 ...
- oracle数据库丢失数据文件、控制文件、重做日志文件、初始化文件恢复方法
rman target/ list backup; 查看是否已备份,如果没有,那就不知道了 模拟故障,删除/u01/app/oracle/oradata/ORCL文件夹下的所有文件 sqlplus ...
- oracle之 利用 controlfile trace文件重建控制文件
一. 11g RAC 重建控制文件 1. --"create controlfile"命令生成到追踪文件中:alter database backup controlfile to ...
- 【Oracle】利用trace文件重建控制文件
重建步骤: 1.生成trace文件: alter database backup controlfile to trace; 2.找到生成的trace文件: show parameter dump u ...
随机推荐
- sprint计划会议
会议召开时间表 日期 时间 内容 05/09 21:00-22:00 讨论题目(未果) 05/10 21:00-21:30 确定题目(网络助手) 05/13 21:00-21:45 讨论软件页面设计 ...
- source insight 注册码
分享一下google来的 呵呵 Source Insight,一个无比强大的工具.一个很好的查看代码的工具.到它的官网上去看一下,就知道,世界上基本上所有的大的软件公司,都在用这个工具.习惯了这个工具 ...
- qemu源码架构
前言:本文主要概括了QEMU的代码结构,特别从代码翻译的角度分析了QEMU是如何将客户机代码翻译成TCG代码和主机代码并且最终执行的过程.并且在最后描述了QEMU和KVM之间联系的纽带. 申明:本文前 ...
- PHP生成图片验证码(simple)
php新手,写了一个web登录界面,除了用户名,密码,感觉有个验证码会比较cool一点,便根据参考书的简单介绍,写了一个image.php来生成简单的图片验证码,颇有感慨,分享一下. 1. 图片验 ...
- char类型与Unicode的编码
Java的char型是非常独特的,占用两个字节,因为Java中char型采用了Unicode编码. 要理解这个问题,我们必须要理解什么是Unicode. 世界上存在着多种编码方式,同一个二进制数字可以 ...
- SQLite 字段类型
一般数据采用的固定的静态数据类型,而SQLite采用的是动态数据类型,会根据存入值自动判断. SQLite具有以下五种数据类型: 1.NULL:空值. 2.INTEGER:带符号的整型,具体取决有存入 ...
- Android 中类似ModelWindow的一个实现
Android里一般的画面(Activity)都是尽量占满整个屏幕,这样符合单线程的设计, 而有些类似popup之类的子画面,却希望他弹出来的时候表现的如同web的模态窗口 (ModelWindow, ...
- 关押罪犯(2010年NOIP全国联赛提高组)
题目描述 Description S 城现有两座监狱,一共关押着N 名罪犯,编号分别为1~N.他们之间的关系自然也极 不和谐.很多罪犯之间甚至积怨已久,如果客观条件具备则随时可能爆发冲突.我们用&qu ...
- ipconfig /flushdns 解释
当我们一域名的形式访问过目标网站后,该网站的域名和IP地址对应关系就会自动保存到本地工作站的DNS缓存列表中,如果以后再次访问该域名,浏览器就会先访问DNS缓存列表中的信息.但是,如果被访问网站的域名 ...
- linux之mysql启动问题
网站总是挂掉,查看到原来是mysql总是莫名其妙的挂掉 1.查看mysql日志的位置 mysql> show VARIABLES like '%log%'; +----------------- ...