rman数据备份恢复学习笔记

昨天对rman数据备份恢复进行了总结,

分享一下。

常用的一些命令

list backup;
list expired backup;
report schema;
report need backup days 3;
report need backup;
report obsolete;
configure channel device type
-压缩备份

CONFIGURE DEVICE TYPE DISK PARALLELISM 3 BACKUP TYPE TO COMPRESSED BACKUPSET;

RMAN> backup database plus archivelog skip inaccessible delete input;

>delete noprompt backup;
.......
RMAN-06207: WARNING: 2 objects could not be deleted for DISK channel(s) due
RMAN-06208:          to mismatched status.  Use CROSSCHECK command to fix status
RMAN-06210: List of Mismatched objects
RMAN-06211: ==========================
RMAN-06212:   Object Type   Filename/Handle
RMAN-06213: --------------- ---------------------------------------------------
RMAN-06214: Backup Piece    /u01/app/backup/orcl/pri/orcl_1/DATAFILE_BACKUP
RMAN-06214: Backup Piece    /u01/app/backup/orcl/pri/orcl_1/LOG_BACKUP

RMAN> crosscheck backup;

using channel ORA_DISK_1
using channel ORA_DISK_2
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=/u01/app/backup/orcl/pri/orcl_1/DATAFILE_BACKUP recid=26 stamp=794756167
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=/u01/app/backup/orcl/pri/orcl_1/LOG_BACKUP recid=27 stamp=794756198
Crosschecked 2 objects

RMAN> delete noprompt backup;

using channel ORA_DISK_1
using channel ORA_DISK_2

List of Backup Pieces
BP Key  BS Key  Pc# Cp# Status      Device Type Piece Name
------- ------- --- --- ----------- ----------- ----------
26      26      1   1   EXPIRED     DISK        /u01/app/backup/orcl/pri/orcl_1/DATAFILE_BACKUP
27      27      1   1   EXPIRED     DISK        /u01/app/backup/orcl/pri/orcl_1/LOG_BACKUP
deleted backup piece
backup piece handle=/u01/app/backup/orcl/pri/orcl_1/DATAFILE_BACKUP recid=26 stamp=794756167
deleted backup piece
backup piece handle=/u01/app/backup/orcl/pri/orcl_1/LOG_BACKUP recid=27 stamp=794756198
Deleted 2 objects

--增量备份

RMAN> backup incremental level=0 database;

backup incremental level=1 database;

db block change tracking
1.
SQL> alter database enable block change tracking using file '/u01/app/oracle/change_tracking';

Database altered.

2.show parameter db_create_file_dest
SQL> alter system set db_create_file_dest='/u01/app/oracle';

System altered.

SQL> alter database enable block change tracking ;                  

Database altered.

-rw-r----- 1 oracle dba 11600384 Oct 16 11:16 o1_mf_87sn9vws_.chg
[oracle@oel1 changetracking]$ pwd
/u01/app/oracle/ORCL/changetracking
[oracle@oel1 changetracking]$

[[oracle@oel1 orcl2]$ ps -ef | grep ora_| grep ctw
oracle   27639     1  0 14:11 ?        00:00:00 ora_ctwr_orcl

 

--rman configuration
RMAN> configure channel 2 device type disk format '/u01/app/oracle/backupset/2%U';

new RMAN configuration parameters:
CONFIGURE CHANNEL 2 DEVICE TYPE DISK FORMAT   '/u01/app/oracle/backupset/2%U';
new RMAN configuration parameters are successfully stored

RMAN> show all;

RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 5;
CONFIGURE BACKUP OPTIMIZATION ON;
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u01/app/oracle/backupset/ctl/%F';
CONFIGURE DEVICE TYPE DISK PARALLELISM 2 BACKUP TYPE TO BACKUPSET;
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT   '/u01/app/oracle/backupset/%U';
CONFIGURE CHANNEL 2 DEVICE TYPE DISK FORMAT   '/u01/app/oracle/backupset/2%U';
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE ON;
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/10.2.0/db_1/dbs/snapcf_orcl.f'; # default

RMAN> configure channel device type disk clear;

old RMAN configuration parameters:
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT   '/u01/app/oracle/backupset/%U';
old RMAN configuration parameters are successfully deleted

RMAN> configure channel 1 device type disk format '/u01/app/oracle/backupset/1%U';

new RMAN configuration parameters:
CONFIGURE CHANNEL 1 DEVICE TYPE DISK FORMAT   '/u01/app/oracle/backupset/1%U';
new RMAN configuration parameters are successfully stored

RMAN> show all;

RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 5;
CONFIGURE BACKUP OPTIMIZATION ON;
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u01/app/oracle/backupset/ctl/%F';
CONFIGURE DEVICE TYPE DISK PARALLELISM 2 BACKUP TYPE TO BACKUPSET;
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE CHANNEL 1 DEVICE TYPE DISK FORMAT   '/u01/app/oracle/backupset/1%U';
CONFIGURE CHANNEL 2 DEVICE TYPE DISK FORMAT   '/u01/app/oracle/backupset/2%U';
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE ON;
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/10.2.0/db_1/dbs/snapcf_orcl.f'; # default

或者使用
configure channel device type disk format '/u01/app/oracle/backupset/3%U';

 

钱包
 1.Mkdir $ORACLE_BASE/admin/a/wallet
 2. alter system set encryption key identified by Oracle123; --- wallet password
 打开钱包
3.alter system set encryption wallet identified by oracle;

归档丢失 ,backup database plus archive log 失败
RMAN-06059: expected archived log not found,

solution1:
--crosscheck archivelog all
--list expired archivelog all;
--delete expired archivelog all;
soution2:
RMAN> change archivelog all crosscheck;

solution3:
crosscheck copy;

恢复

删除在线文件11

rm ....
alter tablespace tbs5 offline immediate;
RMAN> restore datafile 11;

Starting restore at 16-OCT-12
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3

channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00011 to /u01/app/oracle/oradata/orcl2/dbs05.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/3_37nnt9ro_1_1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 10/16/2012 13:44:09
ORA-19870: error reading backup piece /u01/app/oracle/3_37nnt9ro_1_1
ORA-19573: cannot obtain exclusive enqueue for datafile 11

solution1:
RMAN> run{
2> sql 'alter tablespace tbs5 offline immediate';
3> restore tablespace tbs5;
4> recover tablespace tbs5;
5> sql 'alter tablespace tbs5 online
6> ';
7> }

sql statement: alter tablespace tbs5 offline immediate

Starting restore at 16-OCT-12
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3

skipping datafile 2; already restored to file /u01/app/oracle/oradata/orcl/tbs5.dbf
restore not done; all files readonly, offline, or already restored
Finished restore at 16-OCT-12

Starting recover at 16-OCT-12
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3

starting media recovery
media recovery complete, elapsed time: 00:00:00

Finished recover at 16-OCT-12

sql statement: alter tablespace tbs5 online

 

solution2:

SQL> shutdown immediate
ORA-01116: error in opening database file 11
ORA-01110: data file 11: '/u01/app/oracle/oradata/orcl2/dbs05.dbf'
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3
SQL> shutdown abort
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.

Total System Global Area  524288000 bytes
Fixed Size                  1220336 bytes
Variable Size             188743952 bytes
Database Buffers          327155712 bytes
Redo Buffers                7168000 bytes
Database mounted.
SQL> alter system set encryption wallet open identified by oracle;

System altered.

RMAN> restore datafile 11;

Starting restore at 16-OCT-12
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3

channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00011 to /u01/app/oracle/oradata/orcl2/dbs05.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/3_37nnt9ro_1_1
channel ORA_DISK_1: restored backup piece 1
piece handle=/u01/app/oracle/3_37nnt9ro_1_1 tag=TAG20121016T133239
channel ORA_DISK_1: restore complete, elapsed time: 00:00:15
Finished restore at 16-OCT-12

RMAN> recover datafile 11;

Starting recover at 16-OCT-12
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3

starting media recovery
media recovery complete, elapsed time: 00:00:03

Finished recover at 16-OCT-12

SQL> alter database open;

Database altered.

 

--全库恢复

unable to find archive log
archive log thread=1 sequence=75
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 10/16/2012 14:07:03
RMAN-06054: media recovery requesting unknown log: thread 1 seq 75 lowscn 683408

 

solution:
RMAN> run{
2> set until logseq 75;
3> restore database;
4> recover database;
5> alter database open resetlogs;
6> }

 

坏块备份
RMAN> run{
2> set maxcorrupt for datafile 1 to 100;
3> backup tablespace tbs5;
4> }

 

 

时间: 2024-10-24 09:22:41

rman数据备份恢复学习笔记的相关文章

中小型数据库 RMAN CATALOG 备份恢复方案(二)

      中小型数据库呈现的是数据库并发少,数据库容量小,版本功能受限以及N多单实例等特点.尽管如此,数据库的损失程度也会存在零丢失的情形.企业不愿意花太多的钱又要保证数据库的可靠稳定,可是苦煞了我这些搞DB的.接上一篇文章,中小型数据库 RMAN CATALOG 备份恢复方案(一),我们继续来给出基于中小型数据库的恢复的脚本与其部署.   1.RMAN还原shell脚本 --下面的shell脚本用于实现数据库的自动还原,还原成功后,数据库被关闭.因为我们在Prod数据库无异常的情形下,不需要

中小型数据库 RMAN CATALOG 备份恢复方案(三)

      在前两篇文章中描述了中小型数据库使用RMAN catalog设计备份与恢复方案,并给出了所有相关的脚本来从某种车程度上模拟Oracle Data Guard以减少硬件故障带来Prod服务器上数据库损失.在这边文章中主要描述Prod数据库的变迁在Bak server端如何进行恢复.           中小型数据库 RMAN CATALOG 备份恢复方案(一)          中小型数据库 RMAN CATALOG 备份恢复方案(二)   1.恢复前提     按照前两篇文章的描述,

中小企业数据备份恢复解决方案

一体化的备份解决方案 快速的备份和恢复性能 极高的可靠性 业界领先的备份恢复技术 合成全备份 直接访问恢复技术 智能恢复 小颗粒精确恢复 断点续传便捷的操作和管理 配置简单:备份软件.虚拟磁带库组合 1.中小企业面临的挑战 目前中小企业的信息化进程不断加快,各种IT应用,例如OA.ERP.生产系统.电子商务等不断普及.企业对于数据的依赖性日益增强,对于快速发展中的中小企业来说,数据是企业的重要资产,是http://www.aliyun.com/zixun/aggregation/32730.ht

H3C中小企业数据备份恢复解决方案

一体化的备份解决方案 快速的备份和恢复性能 极高的可靠性 业界领先的备份恢复技术 合成全备份 直接访问恢复技术 智能恢复 小颗粒精确恢复 断点续传便捷的操作和管理 配置简单:备份软件.虚拟磁带库组合 1.中小企业面临的挑战 目前中小企业的信息化进程不断加快,各种IT应用,例如OA.ERP.生产系统.电子商务等不断普及.企业对于数据的依赖性日益增强,对于快速发展中的中小企业来说,数据是企业的重要资产,是http://www.aliyun.com/zixun/aggregation/32730.ht

中小型数据库 RMAN CATALOG 备份恢复方案(一)

        对于数据库的稳定性,高可用,跨平台以及海量数据库的处理,Oracle 数据库通常是大型数据库和大企业的首选.尽管如此,仍然不乏很多中小企业想要品尝一下Oracle腥味,因此在Oracle环境中也有不少中小型数据库.出于成本的考虑,通常有可能就搞个标准版了,跑在Linux上.谁叫Oracle太贵呢?对于中小企业而言,选择合理的才是最好的.对我们这些个搞DB的,贵的一定有贵的道理,我们也可以都进多几斗米.哈哈......典型的打工者的心态哟.言归正传,中小企业的成本限制了我们搞高可用

Oracle 12c PDB的数据备份恢复

今天测试了一下12c中的PDB还原恢复,里面还是有不少的差别. 我就简单模拟了一个破坏场景,是在一个未打开的PDB tcymob0从中删除了数据文件usres01.dbf,然后尝试备份恢复. 当然在这个操作前,我们使用RMAN来备份,使用命令backup database即可备份整个数据库. 手工破坏的语句如下: $ rm /U01/app/oracle/oradata/test12cs/tcymob0/pdbseed/users01.dbf这个时候的还原工作就很清晰了,直接还原对应的表空间或者

重视数据备份 恢复RAID5故障后丢失的数据

很多企业的网管都认为 RAID5很少出故障,即使出了故障,RAID5本身也有强大的容错能力,因此往往不太重视http://www.aliyun.com/zixun/aggregation/14344.html">数据备份.这就造成了RAID出现故障时就是大灾难.要知道天有不测风云,人有旦夕祸福,那么,在没有备份的情况下,如果RAID5出现故障,我们该如何恢复数据呢?本文将通过一个实例来讲解,如何恢复RAID5故障后丢失的数据. RAID5发生故障的原因可能有很多种,或者是RAID控制器故障

PHP 数据库驱动、连接数据不同方式学习笔记

目录   1. PHP数据库驱动简介 2. PHP连接数据库的不同方式      1. PHP数据库驱动简介   驱动是一段设计用来于一种特定类型的数据库服务器进行交互的软件代码.驱动可能会调用一些库.类似于Java中的数据库驱动的概念   复制代码 1. JDBC-ODPC桥: 它将JDBC API映射到ODPC API.再让JDBC-ODPC调用数据库本地驱动代码(也就是数据库厂商提供的数据库操作二进制代码库,例如Oracle中的oci.dll) 2. 本地API驱动 直接将JDBC API

我读经典(3):《大数据时代》学习笔记

        最近,怀着一颗好奇的心,我粗略阅读了(英)维克托·迈尔-舍恩伯格所著的<大数据时代>一书的电子版.总体感觉就是本书的内容很宏观,不太容易让人理解.         读完这本电子书之后,我又上网查了一点资料,对"大数据"有了进一步的了解. 1.     "大数据"的简介          最早提出"大数据"时代到来的是全球知名咨询公司麦肯锡,但近年来引起人们关注的原因是互联网和信息行业的发展.       "大