第6天-2 脚本 本地脚本 全局脚本

来源:互联网 发布:伺服电机怎么编程控制 编辑:程序博客网 时间:2024/04/30 09:38
--6-2 脚本 本地脚本 全局脚本--一个catalog对应多个target--保存成脚本,必须用catalog才能创建脚本RMAN> create script scr1{2> backup as compressed backupset database;3> delete noprompt obsolete;4> backup archivelog all;5> }已创建脚本 scr1RMAN> list script names;恢复目录中存储脚本的列表    目标数据库 TEST 的脚本       脚本名       说明       ------------------------       scr1RMAN> print script scr1;正在打印存储的脚本: scr1 {backup as compressed backupset database;delete noprompt obsolete;backup archivelog all;}--脚本执行必须放在run中RMAN> run{2> execute script scr1;3> }--修改脚本RMAN> print script scr1 to file 'C:\oracle\product\10.2.0\flash_recovery_area\cmd\script\scr1.txt';已将脚本 scr1 写入文件 C:\oracle\product\10.2.0\flash_recovery_area\cmd\script\scr1.txt--修改脚本,在替换RMAN> replace script scr1 from file 'C:\oracle\product\10.2.0\flash_recovery_area\cmd\script\scr1.txt';将从文件 C:\oracle\product\10.2.0\flash_recovery_area\cmd\script\scr1.txt 加载脚本命令已替换脚本 scr1RMAN> print script scr1;正在打印存储的脚本: scr1 {backup datafile 4;delete noprompt obsolete;backup archivelog all;}tnsping 服务名shutdown immediatestartup mountalter database archivelog;alter database open;register database;--创建全局数据库脚本,也就是一个catalog中有多个target,每个target对全局脚本都是可见的,不是全局的脚本被脚本所有target所私有RMAN> create global script gscr1{ 2> backup datafile 1;3> }已创建的全局脚本 gscr1RMAN> list global script names;恢复目录中存储脚本的列表    全局脚本       脚本名       说明       ---------------------------       gscr1RMAN> delete global script gscr1;已删除全局脚本: gscr1--RMAN增量备份1.差异2.积累select * from dba_tables where tablespace_name in('TEST','TEST1','USERS','TEST2','TEST3')select * from dba_tablespacesselect count(*) from tttselect * from ttttselect count(*) from ttselect * from test.tselect * from test.ttinsert into test.tt values(1,10)committruncate table test.ttselect * from test.ttselect * from v$log111141048576001YESINACTIVE18667172013-10-26 11:23:09221171048576001NOCURRENT18772242013-10-26 13:43:1133115524288001YESINACTIVE18734362013-10-26 12:10:15441161048576001YESINACTIVE18767802013-10-26 13:34:16commit--星期天RMAN> backup incremental level=0 database;             --0级备份启动 backup 于 26-10月-13使用通道 ORA_DISK_1通道 ORA_DISK_1: 启动压缩的增量级别 0 数据文件备份集通道 ORA_DISK_1: 正在指定备份集中的数据文件--星期一insert into test.tt values(3,3)commitSQL> alter system archive log current;RMAN> backup incremental level=1 database;启动 backup 于 26-10月-13使用通道 ORA_DISK_1通道 ORA_DISK_1: 启动压缩的增量级别 1 数据文件备份集通道 ORA_DISK_1: 正在指定备份集中的数据文件--星期二insert into test.tt values(4,4)commitSQL> alter system archive log current;RMAN> backup incremental level=1 database;--星期三insert into test.tt values(5,5)commitSQL> alter system archive log current;RMAN> backup incremental level=1 cumulative database;启动 backup 于 26-10月-13使用通道 ORA_DISK_1通道 ORA_DISK_1: 启动压缩的增量级别 1 数据文件备份集--星期四insert into test.tt values(6,6)commitSQL> alter system archive log current;RMAN> backup incremental level=1 database;--星期五insert into test.tt values(7,7)commitSQL> alter system archive log current;RMAN> backup incremental level=1 cumulative database;--星期六insert into test.tt values(8,8)commitSQL> alter system archive log current;RMAN> backup incremental level=1 database;RMAN> report schema;RMAN> list backup of database summary;备份列表===============关键字     TY LV S 设备类型 完成时间   段数 副本数 压缩标记------- -- -- - ----------- ---------- ------- ------- ---------- ---1016    B  0  A DISK        26-10月-13 1       1       YES        TAG20131026T180009RMAN> restore preview database;--开始模拟损坏SQL> select file#,checkpoint_change# from v$datafile_header;SQL> select file#,checkpoint_change# from v$datafile;RMAN> recover database;RMAN> alter database open;1.shutdown|offline2.os copy3.log--==4.RMAN> CONFIGURE MAXSETSIZE clear;drop table t purge;C:\>dbv file='C:\oradata\test\TEST01.DBF' --数据文件数据块校验C:\>dbv file='C:\oradata\test\TEST01.DBF'DBVERIFY: Release 10.2.0.3.0 - Production on 星期六 10月 26 19:56:15 2013Copyright (c) 1982, 2005, Oracle.  All rights reserved.DBVERIFY - 开始验证: FILE = C:\oradata\test\TEST01.DBFDBVERIFY - 验证完成检查的页总数: 1280处理的页总数 (数据): 0失败的页总数 (数据): 0处理的页总数 (索引): 0失败的页总数 (索引): 0处理的页总数 (其它): 1279处理的总页数 (段)  : 0失败的总页数 (段)  : 0空的页总数: 1标记为损坏的总页数: 0流入的页总数: 0最高块 SCN            : 764718 (0.764718)RMAN> backup validate database; --不备份,只检查,对数据库块错误进行检测,无论有没有错误都不会有提示--如果有错误会把错路记录在一下视图中select * from v$database_block_corruption--rman可以单独恢复每隔一个数据块RMAN> blockrecover datafile 4 block 730;RMAN> run{2> set maxcorrupt for datafile 4 to 1;           --修改默认跳过的折断块数,修改该参数必须在run中运行3> backup datafile 4;4> }

原创粉丝点击