Chinaunix首页 | 论坛 | 博客
  • 博客访问: 327607
  • 博文数量: 61
  • 博客积分: 1445
  • 博客等级: 上尉
  • 技术积分: 435
  • 用 户 组: 普通用户
  • 注册时间: 2009-12-08 16:04
文章分类

全部博文(61)

文章存档

2010年(61)

分类: Oracle

2010-01-27 11:59:38

1. Introduction to Recovery Manager

  3个重要的特点:

  在线热备不需要ALTER TABLESAPCE … BEGIN BACKUP or END BACKUP,并且不会产生更多日志

  Incremental backups and restores. Can recover a NOARCHIVELOG database. However, only take incremental backups of a NOARCHIVELOG database after a consistent shutdown. 只备份HWM以下的blocks

  检测数据库坏块(interruption blocks), Computes checksums for each block during a backup

  其他作用:

  复制一个prd数据库用来测试,建立或者备份一个standby db

  Tests whether files can be backed up or restored without actually performing the backup or restore.

  Overview of the RMAN Environment

  RMAN executable (必须的)

  Target database (必须的)

  Recovery catalog database

  Media management software

2. Connecting to Databases with RMAN

  Starting RMAN: Overview

  连接3种数据库:

  % rman TARGET SYS/oracle@trgt CATALOG rman/cat@catdb

  --rman用户需要RECOVERY_CATALOG_OWNER 角色

  % rman TARGET SYS/oracle@trgt NOCATALOG

  --目标数据库用户需要sysdba权限,因为是默认,所以不用额外注明as sysdba。NOCATALOG 是默认形式,一旦使用了这种形式,就不能在连接catalog了。

  % rman TARGET / CATALOG rman/cat@catdb AUXILIARY SYS/oracle@auxdb

  或者:

  % rman

  RMAN> CONNECT TARGET SYS/oracle@trgt

  RMAN> CONNECT CATALOG rman/cat@catdb

  连接RAC(3个instance):

  % rman TARGET SYS/oracle@trgt2 CATALOG rman/cat@catdb

  CONFIGURE DEFAULT DEVICE TYPE TO sbt;

  CONFIGURE DEVICE TYPE sbt PARALLELISM 3;

  CONFIGURE CHANNEL 1 DEVICE TYPE sbt CONNECT = 'SYS/oracle@trgt1';

  CONFIGURE CHANNEL 2 DEVICE TYPE sbt CONNECT = 'SYS/oracle@trgt2';

  CONFIGURE CHANNEL 3 DEVICE TYPE sbt CONNECT = 'SYS/oracle@trgt3';

  BACKUP DATABASE;

3. Quick Start to Recovery Manager

  参考?/rdbms/demo/*.rcv

  RMAN基本命令(NOCATALOG mode)

  1. Connecting to the Target Database

  % rman target sys/admin@donnydb2

  2. 可以在rman中操作数据库

  RMAN> STARTUP MOUNT

  3. 产生schema reports

  RMAN> report schema;

  4. 备份数据库

  有2中方式:full(all blocks. datafiles, controlfile, parameter file) 和 incremental(only the blocks that have changed since a previous backup)

  Full Backup:

  RMAN> BACKUP DATABASE;

  默认device type 是disk,除非用configure 配置其到tape

  创建一个逻辑对象backup set, 包括多个backup piece

  Incremental Backup

  RMAN> BACKUP INCREMENTAL LEVEL 1 DATABASE;

  差异增量,累计增量。

  RMAN compares the current datafiles to a base backup, also called a level 0 backup, to determine which blocks to back up.

  0级增量和全备份不同,前者可以作为其他增量备份的基础备份,而后者不行。

  可能会发现有:no parent backup or copy of datafile 1 found;这说明datafile 1还没有0级备份,rman会自动创建。

  5. 备份一个表空间

  RMAN> BACKUP TABLESPACE SYSTEM;

  6. 备份归档日志

  RMAN> BACKUP ARCHIVELOG ALL DELETE INPUT;

  因为oracle不能直接将日志归档到tape,所以用rman将归档从disk备份到tape。如果指明delete input, rman会为每一个log seq num 备份一个copy,并且删除disk上的文件。

  7. 拷贝数据文件datafiles

  RMAN> copy datafile 4 to 'd:\oracle\oradata\donnydb2\bak\hehe.dbf';

  不用在关闭状态吗?这样的拷贝是一致的吗?

  8. Listing Backups and Copies

  RMAN> list backup;

  RMAN> list copy;

  9. 检测是否可以restore the backup, 而不用真正的restore

  RMAN> restore database validate;

  如果不报错,就可以了。

  10. Restoring and Recovering the Database

  RMAN> RESTORE DATABASE;

  RMAN> RECOVER DATABASE;

  RMAN> ALTER DATABASE OPEN;

  11. Restoring and Recovering a Tablespace

  RMAN> SQL 'ALTER TALBESPACE tools OFFLINE IMMEDIATE';

  RMAN> RESTORE TABLESPACE tools;

  RMAN> RECOVER TABLESPACE tools;

  RMAN> SQL 'ALTER TABLESPACE tools ONLINE';

  12. 查看RMAN 配置

  RMAN> show all;

  返回到默认配置,执行CONFIGURE ... CLEAR

  使用单独的Recovery Catalog,还是Nocatalog 模式(默认模式,记录在目标数据库controlfile 中)?

  当管理多个数据库时,建议使用catalog。要注意平时对catalog的备份。好处如下:

  You can store RMAN scripts in the recovery catalog.

  When restoring and recovering to a time when the database files that exist in the database are different from the files recorded in the mounted control file, the recovery catalog specifies which files that are needed. Without a catalog, you must first restore a control file backup that lists the correct set of database files.

  If the control file is lost and must be restored from backup, and if persistent configurations have been made to automate the tape channel allocation, these configurations are still available when the database is not mounted.

  RMAN periodically migrates information from the control file to the recovery catalog. 在哪里配置?

阅读(1178) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~