Oracle RMAN 学习:三思笔记

1 进入rman

Rman--物理备份结构/数据

1 本地db

Cmd

set oracle_sid=orcl

1 rman target /

Rman>

2 也可以先直接进入rman

然后>connect  target /

2 远程db(有效的service_name,本地的tns中有该service的正确配置)

Cmd

Rman target sys/xxxxx@orcl111

3 退出rman

直接exit

在启用rman时,可以指定日志输出

Rman target / log f:\mydb\rman_log.txt

2 熟悉rman操作

Rman的备份跟恢复,db都必须启动实例并加载数据库

 Nomount---mount---open

Oracle如果是db处于open状态(open read write),则db要处于归档状态,否则在备份操作的时候有可能出现ora—19602错误

1 启动和关闭数据库

Rman target /

Rman>shutdown immediate;

Rman>startup;

启动关闭命令跟sqlplus环境下 相同

2 执行操作系统命令

Rman支持在rman命令下使用host命令暂时退出rman

Rman>host;

执行完操作系统命令后,可以通过exit命令切换到rman提示符

3 执行sql语句

在rman提示符下,

RMAN

[ TARGET connectStringSpec

| { CATALOG connectStringSpec }

| LOG ['] filename ['] [ APPEND ]

.

.

.

]...

connectStringSpec::=

['] [userid] [/ [password]] [@net_service_name] [']

Rman> sql ‘select sysdate from dual’ 此时执行不会有结果输出

Rman>sql ‘alter system archive log all’

可以通过host命令切换到操作系统,然后conn / as sysdba等进行操作,然后exit到rman

Linux下:

Last login: Wed Oct 23 09:47:15 2013 from 192.168.2.187

[root@localhost ~]# su - oracle

[oracle@localhost ~]$ rman target/

Recovery Manager: Release 10.2.0.1.0 - Production on Thu Oct 24 09:51:20 2013

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

connected to target database: GRS (DBID=325518186)

RMAN> host;

[oracle@localhost ~]$ sqlplus /nolog

SQL*Plus: Release 10.2.0.1.0 - Production on Thu Oct 24 09:51:51 2013

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

SQL> conn /as sysdba

Connected.

SQL> select sysdate from dual;

SYSDATE

------------

24-OCT-13

SQL> exit

Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production

With the Partitioning, OLAP and Data Mining options

[oracle@localhost ~]$ exit

exit

host command complete

RMAN>

12c rman

RMAN> select sysdate from dual;

SYSDATE

-------------------

2015-08-05 00:03:27

4 rman备份类型

1 镜像复制:copy,将一一系列文件copy

2备份集:优势(备份时只读取数据库中已使用的数据块)

5 rman命令执行方式

1 单个执行命令

Rman>backup database;

2 批处理方式

Rman>run{

………..},将多个单个命令组合到一起,其中任何一个命令失败都将停止(后面的命令不在执行),有些特殊命令不能放到批处理中(list ,report。)

3 运行脚本

A 用命令方式调用os中保存的脚本

Rman target / @backup_db.rman

或者 rman target / cmdfile=backup_db.rman

B 在rman中执行脚本

Rman> @backup_db.rman

C 运行存储在catalog中的脚本(首先为rman创建恢复目录)

Rman> run {execute script backup_db};

3 rman 初级演练

1 整个库的备份

Rman>backup database;--对所有数据文件进行备份,

Rman>backup database format ‘f:\mydb\backup\back_db%u’;

此时没归档,报错ora-19602,改为archived模式,正常执行

alter system set log_archive_dest_1='location= /data/u02/app/frarea';

shutdown immediate;

startup mount;

alter database archivelog;

alter database open;

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02

RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-03009: failure of backup command on ORA_DISK_1 channel at 10/24/2013 10:34:34

ORA-19602: cannot backup or copy active file in NOARCHIVELOG mode

可以用list backup of database;来查看全部备份的文件

RMAN> backup database format '/u01/oracle/backup/back_%U';

Starting backup at 24-OCT-13

using channel ORA_DISK_1

RMAN-03009: failure of backup command on ORA_DISK_1 channel at 10/24/2013 10:56:39

ORA-01013: user requested cancel of current operation

continuing other job steps, job failed will not be re-run

channel ORA_DISK_1: starting full datafile backupset

channel ORA_DISK_1: specifying datafile(s) in backupset

including current control file in backupset

including current SPFILE in backupset

channel ORA_DISK_1: starting piece 1 at 24-OCT-13

channel ORA_DISK_1: finished piece 1 at 24-OCT-13

piece handle=/u01/oracle/backup/back_04on6v77_1_1 tag=TAG20131024T105639 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01

RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-03009: failure of backup command on ORA_DISK_1 channel at 10/24/2013 10:56:39

ORA-01013: user requested cancel of current operation

RMAN> exit

Recovery Manager complete.

[oracle@localhost ~]$ rman target /

Recovery Manager: Release 10.2.0.1.0 - Production on Thu Oct 24 10:57:04 2013

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

connected to target database: GRS (DBID=325518186)

RMAN> list backup of database;

using target database control file instead of recovery catalog

RMAN> backup database format '/u01/oracle/backup/back_%U';

Starting backup at 24-OCT-13

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=159 devtype=DISK

channel ORA_DISK_1: starting full datafile backupset

channel ORA_DISK_1: specifying datafile(s) in backupset

input datafile fno=00001 name=/u01/app/oracle/oradata/grs/system01.dbf

input datafile fno=00007 name=/u01/app/oracle/oradata/grs/cmask01.dbf

input datafile fno=00003 name=/u01/app/oracle/oradata/grs/sysaux01.dbf

input datafile fno=00005 name=/u01/app/oracle/oradata/grs/example01.dbf

input datafile fno=00006 name=/u01/app/oracle/oradata/grs/yyhhqq.dbf

input datafile fno=00002 name=/u01/app/oracle/oradata/grs/undotbs01.dbf

input datafile fno=00004 name=/u01/app/oracle/oradata/grs/users01.dbf

channel ORA_DISK_1: starting piece 1 at 24-OCT-13

channel ORA_DISK_1: finished piece 1 at 24-OCT-13

piece handle=/u01/oracle/backup/back_05on6v94_1_1 tag=TAG20131024T105740 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:02:37

channel ORA_DISK_1: starting full datafile backupset

channel ORA_DISK_1: specifying datafile(s) in backupset

including current control file in backupset

including current SPFILE in backupset

channel ORA_DISK_1: starting piece 1 at 24-OCT-13

channel ORA_DISK_1: finished piece 1 at 24-OCT-13

piece handle=/u01/oracle/backup/back_06on6ve1_1_1 tag=TAG20131024T105740 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:04

Finished backup at 24-OCT-13

RMAN> list backup of database;

List of Backup Sets

===================

BS Key  Type LV Size       Device Type Elapsed Time Completion Time

------- ---- -- ---------- ----------- ------------ ---------------

3       Full    645.97M    DISK        00:02:35     24-OCT-13

BP Key: 3   Status: AVAILABLE  Compressed: NO  Tag: TAG20131024T105740

Piece Name: /u01/oracle/backup/back_05on6v94_1_1

List of Datafiles in backup set 3

File LV Type Ckp SCN    Ckp Time  Name

---- -- ---- ---------- --------- ----

1       Full 988527     24-OCT-13 /u01/app/oracle/oradata/grs/system01.dbf

2       Full 988527     24-OCT-13 /u01/app/oracle/oradata/grs/undotbs01.dbf

3       Full 988527     24-OCT-13 /u01/app/oracle/oradata/grs/sysaux01.dbf

4       Full 988527     24-OCT-13 /u01/app/oracle/oradata/grs/users01.dbf

5       Full 988527     24-OCT-13 /u01/app/oracle/oradata/grs/example01.dbf

6       Full 988527     24-OCT-13 /u01/app/oracle/oradata/grs/yyhhqq.dbf

7       Full 988527     24-OCT-13 /u01/app/oracle/oradata/grs/cmask01.dbf

RMAN>

2 表空间的备份

只要db处于mount状态,不论是否打开,都可以进行rman 备份表空间

Rman> backup tablespace users;

-----backup tablespace users format 'f:\mydb\backup\backup_tp_users';

List backup of tablespace users; list backup查看一下备份

删除备份:delete backupset 4(bs key)

RMAN> backup tablespace yyhhqq;-------没有指定详细路径

Starting backup at 24-OCT-13

using channel ORA_DISK_1

channel ORA_DISK_1: starting full datafile backupset

channel ORA_DISK_1: specifying datafile(s) in backupset

input datafile fno=00006 name=/u01/app/oracle/oradata/grs/yyhhqq.dbf

channel ORA_DISK_1: starting piece 1 at 24-OCT-13

channel ORA_DISK_1: finished piece 1 at 24-OCT-13

piece handle=/u01/app/oracle/flash_recovery_area/GRS/backupset/2013_10_24/o1_mf_nnndf_TAG20131024T110255_96k3h019_.bkp tag=TAG20131024T110255 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:15

Finished backup at 24-OCT-13

RMAN> list backup of tablespace yyhhqq;

List of Backup Sets

===================

BS Key  Type LV Size       Device Type Elapsed Time Completion Time

------- ---- -- ---------- ----------- ------------ ---------------

3       Full    645.97M    DISK        00:02:35     24-OCT-13

BP Key: 3   Status: AVAILABLE  Compressed: NO  Tag: TAG20131024T105740

Piece Name: /u01/oracle/backup/back_05on6v94_1_1

List of Datafiles in backup set 3

File LV Type Ckp SCN    Ckp Time  Name

---- -- ---- ---------- --------- ----

6       Full 988527     24-OCT-13 /u01/app/oracle/oradata/grs/yyhhqq.dbf

BS Key  Type LV Size       Device Type Elapsed Time Completion Time

------- ---- -- ---------- ----------- ------------ ---------------

5       Full    712.00K    DISK        00:00:09     24-OCT-13

BP Key: 5   Status: AVAILABLE  Compressed: NO  Tag: TAG20131024T110255

Piece Name: /u01/app/oracle/flash_recovery_area/GRS/backupset/2013_10_24/o1_mf_nnndf_TAG20131024T110255_96k3h019_.bkp

List of Datafiles in backup set 5

File LV Type Ckp SCN    Ckp Time  Name

---- -- ---- ---------- --------- ----

6       Full 988697     24-OCT-13 /u01/app/oracle/oradata/grs/yyhhqq.dbf

RMAN> backup tablespace yyhhqq;

3数据文件的备份

有2 种方式指定数据文件(详细路径)和file_id,都可以从视图dba_data_files中得到

select file_id,file_name from dba_data_files

4 /u01/app/oracle/oradata/grs/users01.dbf

3 /u01/app/oracle/oradata/grs/sysaux01.dbf

在整库备份和list时都会出现file_id和数据文件的名称

RMAN>  backup datafile '/u01/app/oracle/oradata/grs/users01.dbf' format '/u01/oracle/backup/backup_datafile_%U';

RMAN> backup datafile 6 format '/u01/oracle/backup/backup_data6_%p_%I_%t;

Piece Name: /u01/oracle/backup/backup_data6_1_325518186_830601460;

Starting backup at 24-OCT-13

using channel ORA_DISK_1

channel ORA_DISK_1: starting full datafile backupset

channel ORA_DISK_1: specifying datafile(s) in backupset

input datafile fno=00004 name=/u01/app/oracle/oradata/grs/users01.dbf

channel ORA_DISK_1: starting piece 1 at 24-OCT-13

channel ORA_DISK_1: finished piece 1 at 24-OCT-13

piece handle=/u01/oracle/backup/backup_datafile_09on7bsd_1_1 tag=TAG20131024T143245 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03

Finished backup at 24-OCT-13

可以用file_id代替  backup datafile 6,7,8

RMAN> list backup of datafile 4;

List of Backup Sets

===================

BS Key  Type LV Size       Device Type Elapsed Time Completion Time

------- ---- -- ---------- ----------- ------------ ---------------

3       Full    645.97M    DISK        00:02:35     24-OCT-13

BP Key: 3   Status: AVAILABLE  Compressed: NO  Tag: TAG20131024T105740

Piece Name: /u01/oracle/backup/back_05on6v94_1_1

List of Datafiles in backup set 3

File LV Type Ckp SCN    Ckp Time  Name

---- -- ---- ---------- --------- ----

4       Full 988527     24-OCT-13 /u01/app/oracle/oradata/grs/users01.dbf

BS Key  Type LV Size       Device Type Elapsed Time Completion Time

------- ---- -- ---------- ----------- ------------ ---------------

6       Full    8.94M      DISK        00:00:02     24-OCT-13

BP Key: 6   Status: AVAILABLE  Compressed: NO  Tag: TAG20131024T143245

Piece Name: /u01/oracle/backup/backup_datafile_09on7bsd_1_1

List of Datafiles in backup set 6

File LV Type Ckp SCN    Ckp Time  Name

---- -- ---- ---------- --------- ----

4       Full 995093     24-OCT-13 /u01/app/oracle/oradata/grs/users01.dbf

4控制文件的备份

Rman>backup current controlfile;

backup current controlfile

执行backup命令时指定include current controlfile

Rman>backup database include current controlfile

通过指定configure命令将controlfile autobackup置为on

Rman>configure controlfile autobackup on/off;  rman做任何备份操作都会备份控制文件

List backup of controlfile

RMAN>   backup current controlfile format '/u01/oracle/backup/backup_control_file';

Starting backup at 24-OCT-13

using channel ORA_DISK_1

channel ORA_DISK_1: starting full datafile backupset

channel ORA_DISK_1: specifying datafile(s) in backupset

including current control file in backupset

channel ORA_DISK_1: starting piece 1 at 24-OCT-13

channel ORA_DISK_1: finished piece 1 at 24-OCT-13

piece handle=/u01/oracle/backup/backup_control_file tag=TAG20131024T144627 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02

Finished backup at 24-OCT-13

RMAN> list backup of controlfile;

List of Backup Sets

RMAN> configure controlfile autobackup on;----任何backup都会备份控制文件

new RMAN configuration parameters:

CONFIGURE CONTROLFILE AUTOBACKUP ON;

new RMAN configuration parameters are successfully stored

The RMAN BACKUP CURRENT CONTROLFILE command makes a binary backup of

the control file, as either a backup set or an image copy.

The SQL statement ALTER DATABASE BACKUP CONTROLFILE makes a binary

backup of the control file.

The SQL statement ALTER DATABASE BACKUP CONTROLFILE TO TRACE exports

the control file contents to a SQL script file. You can use the script to create a new

control file. Trace file backups have one major disadvantage: they contain no

records of archived redo logs, and RMAN backups and copies. For this reason,

binary backups are preferable.

使用alter database backup controlfile备份控制文件

SQL> alter database backup controlfile to trace;

或者

SQL> alter database backup controlfile to trace as '/data/controlfile1.cof';   (这样你可以查看controlfile的构成)

5归档文件的备份

1  RMAN> backup archivelog all;

Starting backup at 24-OCT-13

current log archived

using channel ORA_DISK_1

channel ORA_DISK_1: starting archive log backupset

channel ORA_DISK_1: specifying archive log(s) in backup set

input archive log thread=1 sequence=20 recid=1 stamp=829666475

channel ORA_DISK_1: starting piece 1 at 24-OCT-13

channel ORA_DISK_1: finished piece 1 at 24-OCT-13

piece handle=/u01/app/oracle/flash_recovery_area/GRS/backupset/2013_10_24/o1_mf_annnn_TAG20131024T145435_96kk1gpx_.bkp tag=TAG20131024T145435 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02

Finished backup at 24-OCT-13

Starting Control File and SPFILE Autobackup at 24-OCT-13

piece handle=/u01/app/oracle/flash_recovery_area/GRS/autobackup/2013_10_24/o1_mf_s_829666480_96kk1jj2_.bkp comment=NONE

Finished Control File and SPFILE Autobackup at 24-OCT-13

Backup archivelog命令比较灵活,all是指备份当前所有可访问到的归档文件夹,

还可以通过until,scn,time,sequence等参数灵活指定备份的归档区间。

2 执行backup时指定plus archivelog字句

Rman>backup current controlfile plus archivelog

在备份控制文件之前先对归档文件进行备份,

Backup 。。。 plus archivelog,命令执行以下步骤

A 运行alter system archive log current语句对当前redolog进行归档

B 执行backup archivlelog all命令 备份所有归档文件

C 执行backup命令对指定项进行备份

D 再次运行alter system archive log current对redolog进行归档

E 对新生成的尚未备份的归档文件进行备份

完成了归档日志的备份后,我们需要删除过期的归档文件的备份,

Rman,提供了delete all input参数,加在backup命令后,则会完成备份后自动删除归档目录中已备份的归档日志,

RMAN> delete archivelog all like '/backup/archivelog1/%' backed up 1 times to device type disk;

Rman>list backup of archivelog all;

--delete noprompt archivelog all completed before 'sysdate';   --->该命令清除所有的归档日志

delete noprompt archivelog all;                              --->同上一命令

6初始化参数文件的备份

通常在备份控制文件时,rman会自动备份服务器端的初始化参数文件,并置于控制文件相同的备份片中,/u01/app/oracle/product/10.2.0/db_1/dbs/spfilegrs.ora

Rman>backup spfile;单独备份参数文件

RMAN>  backup spfile format '/u01/oracle/backup/backup_spfile';

Starting backup at 24-OCT-13

using channel ORA_DISK_1

channel ORA_DISK_1: starting full datafile backupset

channel ORA_DISK_1: specifying datafile(s) in backupset

including current SPFILE in backupset

channel ORA_DISK_1: starting piece 1 at 24-OCT-13

channel ORA_DISK_1: finished piece 1 at 24-OCT-13

piece handle=/u01/oracle/backup/backup_spfile tag=TAG20131024T145840 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01

Finished backup at 24-OCT-13

Starting Control File and SPFILE Autobackup at 24-OCT-13

piece handle=/u01/app/oracle/flash_recovery_area/GRS/autobackup/2013_10_24/o1_mf_s_829666721_96kk91h7_.bkp comment=NONE

Finished Control File and SPFILE Autobackup at 24-OCT-13

RMAN> backup spfile format '/u01/oracle/backup

2> ';

Starting backup at 14-MAR-14

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=159 devtype=DISK

RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-03002: failure of backup command at 03/14/2014 16:14:29

RMAN-06062: can not backup SPFILE because the instance was not started with SPFILE

7对备份集进行备份

备份所有备份集

Rman>backup backupset all;

指定备份备份集

Rman>backup backupset n1,n2..;也可以添加delete input参数

4 rman命令

1 显示rman默认配置show

RMAN> show all;

RMAN configuration parameters are:

CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default

CONFIGURE BACKUP OPTIMIZATION OFF; # default

CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default

CONFIGURE CONTROLFILE AUTOBACKUP ON;

CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default

CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default

CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default

CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default

CONFIGURE MAXSETSIZE TO UNLIMITED; # default

CONFIGURE ENCRYPTION FOR DATABASE OFF; # default

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_grs.f'; # default

配置项后面加了#default,表示该配置项没有修改过,

Rman>show configure archivlelog deletion policy to none;

2 列出备份信息list

LIST BACKUP OF DATABASE BY BACKUP

LIST BACKUP BY FILE

LIST BACKUP SUMMARY

LIST EXPIRED COPY

LIST BACKUP RECOVERABLE

LIST FAILURE;

ADVISE FAILURE;

REPAIR FAILURE;

RMAN> list backup;

List of Backup Sets

===================

BS Key  Size       Device Type Elapsed Time Completion Time

------- ---------- ----------- ------------ ---------------

1       176.85M    DISK        00:02:21     10-NOV-14

BP Key: 1   Status: AVAILABLE  Compressed: YES  Tag: TAG20141110T165750

Piece Name: /home/oracle/oracle_rman/rman_backup_01pn9a8g_1_1

List of Archived Logs in backup set 1

Thrd Seq     Low SCN    Low Time  Next SCN   Next Time

---- ------- ---------- --------- ---------- ---------

1    3       480534     29-OCT-14 521206     30-OCT-14

BS Key  Type LV Size       Device Type Elapsed Time Completion Time

------- ---- -- ---------- ----------- ------------ ---------------

2       Full    135.77M    DISK        00:04:17     10-NOV-14

BP Key: 2   Status: AVAILABLE  Compressed: YES  Tag: TAG20141110T170021

Piece Name: /home/oracle/oracle_rman/rman_backup_02pn9ad5_1_1

List of Datafiles in backup set 2

File LV Type Ckp SCN    Ckp Time  Name

---- -- ---- ---------- --------- ----

1       Full 16926112   10-NOV-14 /u01/app/oracle/grs/system01.dbf

2       Full 16926112   10-NOV-14 /u01/app/oracle/grs/undotbs01.dbf

3       Full 16926112   10-NOV-14 /u01/app/oracle/grs/sysaux01.dbf

4       Full 16926112   10-NOV-14 /u01/app/oracle/grs/users01.dbf

5       Full 16926112   10-NOV-14 /u01/app/oracle/grs/example01.dbf

6       Full 16926112   10-NOV-14 /u01/app/oracle/grs/grsv501.dbf

BS Key  Size       Device Type Elapsed Time Completion Time

------- ---------- ----------- ------------ ---------------

3       1.11M      DISK        00:00:01     10-NOV-14

BP Key: 3   Status: AVAILABLE  Compressed: YES  Tag: TAG20141110T170448

Piece Name: /home/oracle/oracle_rman/rman_backup_03pn9alg_1_1

 List of Archived Logs in backup set 3

Thrd Seq     Low SCN    Low Time  Next SCN   Next Time

---- ------- ---------- --------- ---------- ---------

1    17      16926056   10-NOV-14 16926311   10-NOV-14

BS Key  Type LV Size       Device Type Elapsed Time Completion Time

------- ---- -- ---------- ----------- ------------ ---------------

4       Full    6.80M      DISK        00:00:01     10-NOV-14

BP Key: 4   Status: AVAILABLE  Compressed: NO  Tag: TAG20141110T170450

Piece Name: /home/oracle/oracle_rman/rman_backup_c-360277547-20141110-00

 Control File Included: Ckp SCN: 16926317     Ckp time: 10-NOV-14

SPFILE Included: Modification time: 07-NOV-14

List命令查看rman生成的备份集,备份镜像,归档文件等

List backup ;所有备份信息

List backup of controlfile;—所有控制文件的备份信息

List backup of datafile ‘f:\mydb\backup\......dbf’;

List backup of datafile 5;

List backup of archivelog all;---所有备份的归档文件的信息

List copy of tablespace ‘system’;----列出指定表空间的信息

List device type disk backup;列出某个设备上的所有信息

List archivelog all;列出db当前所有归档

List expired backup;列出无效备份(---无效备份怎么定义的??)

List backup summary

RMAN> list copy of database archivelog all

RMAN> list expired backup;

3 删除备份delete

用于删除rman备份记录以及相关物理文件(有时候并不是删除,而是打上标记),当使用rman执行备份操作时,会在rman资料库中生成rman备份记录,默认情况下rman备份记录会被存放在目标数据库的控制文件中,如果配置了恢复目录(recovery catalog),那么该备份集也会存放到该恢复目录中

Delete obsolete;删除过期备份----rman会根据冗余策略确定备份是否过期

RMAN> delete obsolete;

Delete obsolete命令

Note:1 如果被判断为废弃的备份是一个单独数据文件的镜像复制,在delete时直接删除

2 如果是备份集中的一部分,则必须等整个备份集都废弃了,才能删除

RMAN retention policy will be applied to the command

RMAN retention policy is set to redundancy 1

using channel ORA_DISK_1

Deleting the following obsolete backups and copies:

Type                 Key    Completion Time    Filename/Handle

-------------------- ------ ------------------ --------------------

Backup Set           1      24-OCT-13

Delete expired backup;删除无效备份,用此命令删除无效的备份,

首先执行crosscheck命令核对备份集,如果发现无效(比如备份对应的数据文件损坏或丢失),rman会将该备份集标记为expired状态,

RMAN> delete expired backup;

using channel ORA_DISK_1

  Delete expired copy;删除expiry副本

  Delete backupset 9,1,2;删除指定备份集

RMAN> delete backupset 43,47,48,49;

using channel ORA_DISK_1

List of Backup Pieces

BP Key  BS Key  Pc# Cp# Status      Device Type Piece Name

------- ------- --- --- ----------- ----------- ----------

43      43      1   1   UNAVAILABLE DISK        /u01/oracle/backup/full_1koo4kd1_1_1

47      47      1   1   UNAVAILABLE DISK        /u01/oracle/backup/rman1104_backup_c-325518186-20140312-00

48      48      1   1   UNAVAILABLE DISK        /u01/oracle/backup/backup_spfile

49      49      1   1   UNAVAILABLE DISK        /u01/oracle/backup/rman1104_backup_c-325518186-20140314-00

Do you really want to delete the above objects (enter YES or NO)? yes

  Delete backuppiece f:\myd\backup\....bak’;删除特定备份片

  Delete backup;删除所有备份集----状态为expired的备份删不掉,

  Delete datafile copy f……….bak;删除特定映像副本

  Delete copy ;删除所有映像副本

  Backup archivelog all delete input ;在备份后删除输入对象

RMAN> backup archivelog all delete input;

Starting backup at 24-OCT-13

current log archived

using channel ORA_DISK_1

channel ORA_DISK_1: starting archive log backupset

channel ORA_DISK_1: specifying archive log(s) in backup set

input archive log thread=1 sequence=20 recid=1 stamp=829666475

input archive log thread=1 sequence=21 recid=2 stamp=829669679

channel ORA_DISK_1: starting piece 1 at 24-OCT-13

channel ORA_DISK_1: finished piece 1 at 24-OCT-13

piece handle=/u01/app/oracle/flash_recovery_area/GRS/backupset/2013_10_24/o1_mf_annnn_TAG20131024T154800_96kn5k4j_.bkp tag=TAG20131024T154800 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:04

channel ORA_DISK_1: deleting archive log(s)

archive log filename=/u01/app/oracle/flash_recovery_area/GRS/archivelog/2013_10_24/o1_mf_1_20_96kk1b3h_.arc recid=1 stamp=829666475

archive log filename=/u01/app/oracle/flash_recovery_area/GRS/archivelog/2013_10_24/o1_mf_1_21_96kn5hv3_.arc recid=2 stamp=829669679

Finished backup at 24-OCT-13

Delete backupset 22 format =”f:\mydb\backup\backup_%bk” delete input;

4 报表显示命令report

REPORT NEED BACKUP DATABASE

REPORT OBSOLETE

REPORT SCHEMA

REPORT UNRECOVERABLE

Report主要用于当前备份信息的分析,如哪些备份已过期,哪些该备份,哪些备份不可用,哪些备份可删除等,

查看7天前的数据库的模式

Rman>report schema at time ‘sysdate-7’;--此时模式信息必须连接到catalog数据库(目录)

查看所需要备份的文件

RMAN> report need backup;

RMAN retention policy will be applied to the command

RMAN retention policy is set to redundancy 1

Report of files with less than 1 redundant backups

File #bkps Name

---- ----- -----------------------------------------------------

查看指定表空间是否需要备份

Report need backup tablespace yyhhqq;

查看过期备份

RMAN> report obsolete;

RMAN retention policy will be applied to the command

RMAN retention policy is set to recovery window of 7 days

Report of obsolete backups and copies

Type                 Key    Completion Time    Filen

RMAN> delete obsolete;

RMAN retention policy will be applied to the command

RMAN retention policy is set to redundancy 1

using channel ORA_DISK_1

Deleting the following obsolete backups and copies:

Type                 Key    Completion Time    Filename/Handle

-------------------- ------ ------------------ --------------------

5 执行检查crosscheck命令

Crosscheck用来检查备份或归档物理文件的状态,如果物理文件存储并且在控制文件(或回复目录)有配匹记录,则标记该对象的状态为available(有效),如果文件不存在,则标记为expired,

检查所有归档文件

Rman>crosscheck archivelog all;

当操作系统环境变量nls_lang指定为中文,执行crosscheck检查失败,而又确定文件存在,显示失败说明成功,设置为american_america,英文环境检查正常

检查所有备份集

RMAN> crosscheck backup;

using channel ORA_DISK_1

crosschecked backup piece: found to be 'AVAILABLE'

backup piece handle=/u01/oracle/backup/back_05on6v94_1_1 recid=3 stamp=829652260

crosschecked backup piece: found to be 'AVAILABLE'

backup piece handle=/u01/oracle/backup/backup_datafile_09on7bsd_1_1 recid=6 stamp=829665165

crosschecked backup piece: found to be 'AVAILABLE'

backup piece handle=/u01/app/oracle/flash_recovery_area/GRS/backupset/2013_10_24/o1_mf_annnn_TAG20131024T145435_96kk1gpx_.bkp recid=8 stamp=829666478

crosschecked backup piece: found to be 'EXPIRED'

backup piece handle=/u01/oracle/backup/backup_spfile recid=12 stamp=829666720

crosschecked backup piece: found to be 'AVAILABLE'

backup piece handle=/u01/app/oracle/flash_recovery_area/GRS/backupset/2013_10_24/o1_mf_annnn_TAG20131024T154800_96kn5k4j_.bkp recid=14 stamp=829669681

crosschecked backup piece: found to be 'AVAILABLE'

backup piece handle=/u01/app/oracle/flash_recovery_area/GRS/autobackup/2013_10_24/o1_mf_s_829669684_96kn5nok_.bkp recid=15 stamp=829669684

Crosschecked 6 objects

RMAN> delete expired backup;

using channel ORA_DISK_1

List of Backup Pieces

BP Key  BS Key  Pc# Cp# Status      Device Type Piece Name

------- ------- --- --- ----------- ----------- ----------

12      12      1   1   EXPIRED     DISK        /u01/oracle/backup/backup_spfile

Do you really want to delete the above objects (enter YES or NO)? yes

deleted backup piece

backup piece handle=/u01/oracle/backup/backup_spfile recid=12 stamp=829666720

Deleted 1 EXPIRED objects

6 修改状态change命令

Change命令用来修改备份文件或归档文件的状态,不是指物理文件,而是这些文件在控制文件(或恢复目录)中对应记录的状态,available,unavailable,

修改指定备份集状态为unavailable

Rman>change backupset n unavailable;n为指定备份集的备份集序号,指定的备份集必须存在,

RMAN> change backupset 47,48,46,43 unavailable;

changed backup piece unavailable

backup piece handle=/u01/oracle/backup/full_1koo4kd1_1_1 recid=43 stamp=830624161

changed backup piece unavailable

backup piece handle=/u01/oracle/backup/rman1104_backup_c-325518186-20131119-00 recid=46 stamp=831916246

changed backup piece unavailable

backup piece handle=/u01/oracle/backup/rman1104_backup_c-325518186-20140312-00 recid=47 stamp=842007923

changed backup piece unavailable

backup piece handle=/u01/oracle/backup/backup_spfile recid=48 stamp=842200054

Changed 4 objects to UNAVAILABLE status

修改指定指定的表空间的备份集为unavailable;

Rman>change backup of tablespace users unavailable;

修改指定归档文件状态为unavailable

Rman>change archivelog logseq=n unavailable;

Change 命令附带了delete字句,

删除某个归档文件

Rman>change archivelog logseq=n delete;

Oracle RMAN 学习的更多相关文章

  1. Oracle RMAN 学习:恢复

    Oracle RMAN 学习:恢复 6 rman恢复 Rman中的恢复对应restore,recover Restore,数据修复,利用备份集的数据文件来替换已损坏的数据文件或将其恢复到另外一个位置, ...

  2. Oracle RMAN 学习:演练进阶篇

    Oracle RMAN 学习:演练进阶篇 5 Rman备份演练进阶篇 5.1 是否选择增量备份 Backup命令生成的备份集中只备份了那些使用了的数据块,备份集实际大小已经较目标数据库的数据文件小了很 ...

  3. Oracle DBA 学习总结

    对于学习Oracle 数据库,应该先要了解Oracle 的框架.它有物理结构(由控制文件.数据文件.重做日志文件.参数文件.归档文件.密码文件组成) ,逻辑结构(表空间.段.区.块),内存分配( SG ...

  4. Asp.Net MVC4 + Oracle + EasyUI 学习 序章

    Asp.Net MVC4 + Oracle + EasyUI  序章 -- 新建微软实例 本文链接:http://www.cnblogs.com/likeli/p/4233387.html 1.  简 ...

  5. Oracle RMAN 备份一例

    Oracle RMAN备份一例: Solaris 10 + Oracle 11.2.0.3 Shell:csh,安装有bash,脚本调用bash 备份策略:周日0级备份,周一~周六1级备份,每6小时备 ...

  6. Oracle RAC学习笔记:基本概念及入门

    Oracle RAC学习笔记:基本概念及入门 2010年04月19日 10:39 来源:书童的博客 作者:书童 编辑:晓熊 [技术开发 技术文章]    oracle 10g real applica ...

  7. Oracle—RMAN备份(三)

    一.增量备份的相关概念 1. 在前面说明了RMAN的完整备份,完整备份是备份所用使用过的块,不备份没有使用的过的块:增量备份只备份自上次备份以来更改过的块. 2.即使RMAN的默认操作是在增量备份时扫 ...

  8. Oracle—RMAN备份(一)

    一.RMAN备份相关概念 1.RMAN备份中表空间不需要处于backup模式下,它备份数据文件,归档日志文件,控制文件,spfile和备份集片,但不备份联机重做日志文件,临时文件和口令文件. 2.备份 ...

  9. Oracle—RMAN备份(二)

    在Oracle  RMAN备份(一)中,对各种文件在RMAN中备份进行了说明, 一.备份集的复制 在RMAN 备份中,可以备份其自己的备份,即备份一个文件放在多个目录下,oralce支持最多备份四个. ...

随机推荐

  1. Spark基本概念快速入门

      Spark集群 一组计算机的集合,每个计算机节点作为独立的计算资源,又可以虚拟出多个具备计算能力的虚拟机,这些虚拟机是集群中的计算单元.Spark的核心模块专注于调度和管理虚拟机之上分布式计算任务 ...

  2. nova notification

    1 compute.instance.update类型的消息 需要配置notify_on_state_change参数,可以为空,或者vm_state,或者vm_and_task_state, 当虚拟 ...

  3. JavaScript数组和函数的使用

    数组 数组:一个有顺序,有长度的数据集合 作用:存储大量数据 一.数组的定义 1.构造函数法:使用构造函数法的时候,都会使用new关键字 var arr=new Array(): 当长度为0 的时候, ...

  4. Postman工具——Pre-Request Script、Tests

    这篇是介绍 Postman 的最后一篇,也就是最后两个用法:Pre-Request Script 和 Tests ,它支持以嵌入脚本的方式动态准备测试数据,并根据业务需求设计测试用例. 一.Pre-R ...

  5. poj2396有源汇上下界可行流

    题意:给一些约束条件,要求算能否有可行流,ps:刚开始输入的是每一列和,那么就建一条上下界相同的边,这样满流的时候就一定能保证流量相同了,还有0是该列(行)对另一行每个点都要满足约束条件 解法:先按无 ...

  6. poj 1324 状态压缩+bfs

    http://poj.org/problem?id=1324 Holedox Moving Time Limit: 5000MS   Memory Limit: 65536K Total Submis ...

  7. handsontable 给单元格自定义属性

    setHotAttr(hotObj,rowHeader,colHeader){// 给handsongtable绑定行列属性 console.log(hotObj); console.log(colH ...

  8. LeetCode OJ:Path Sum II(路径和II)

    Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given su ...

  9. codeforces C. Pearls in a Row map的应用

    C. Pearls in a Row time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  10. 转载:maven依赖范围

    其中依赖范围scope 用来控制依赖和编译,测试,运行的classpath(注意是与classpath)的关系. 主要的是三种依赖关系如下:1.compile: 默认编译依赖范围.对于编译,测试,运行 ...