当前所在位置:珠峰网资料 >> 计算机 >> Oracle认证 >> 正文
利用dbmsbackuprestore恢复数据库
发布时间:2010/8/30 15:58:31 来源:城市学习网 编辑:ziteng
  进行测试之前先将数据库做全备:
  引用
  RMAN> run {
  2> allocate channel ch00 device type disk;
  3> backup database include current controlfile format ‘/backup/full%t’ tag=’FULLDB’;
  4> sql ‘alter system archive log current’;
  5> backup archivelog all format ‘/backup/arch%t’ tag=’ARCHIVELOG’;
  6> release channel ch00;
  7> }
  allocated channel: ch00
  channel ch00: sid=17 devtype=DISK
  Starting backup at 20-JAN-10
  channel ch00: starting full datafile backupset
  channel ch00: specifying datafile(s) in backupset
  including current controlfile in backupset
  input datafile fno=00001 name=/app/oracle/oradata/ora9i/system01.dbf
  input datafile fno=00002 name=/app/oracle/oradata/ora9i/undotbs01.dbf
  input datafile fno=00005 name=/app/oracle/oradata/ora9i/example01.dbf
  input datafile fno=00011 name=/app/oracle/oradata/ora9i/STREAM01.dbf
  input datafile fno=00010 name=/app/oracle/oradata/ora9i/xdb01.dbf
  input datafile fno=00006 name=/app/oracle/oradata/ora9i/indx01.dbf
  input datafile fno=00009 name=/app/oracle/oradata/ora9i/users01.dbf
  input datafile fno=00003 name=/app/oracle/oradata/ora9i/cwmlite01.dbf
  input datafile fno=00004 name=/app/oracle/oradata/ora9i/drsys01.dbf
  input datafile fno=00007 name=/app/oracle/oradata/ora9i/odm01.dbf
  input datafile fno=00008 name=/app/oracle/oradata/ora9i/tools01.dbf
  channel ch00: starting piece 1 at 20-JAN-10
  channel ch00: finished piece 1 at 20-JAN-10
  piece handle=/backup/full708756233 comment=NONE
  channel ch00: backup set complete, elapsed time: 00:02:26
  Finished backup at 20-JAN-10
  Starting Control File and SPFILE Autobackup at 20-JAN-10
  piece handle=/app/oracle/product/9.0.2/dbs/c-2494723682-20100120-00 comment=NONE
  Finished Control File and SPFILE Autobackup at 20-JAN-10
  sql statement: alter system archive log current
  Starting backup at 20-JAN-10
  current log archived
  channel ch00: starting archive log backupset
  channel ch00: specifying archive log(s) in backup set
  input archive log thread=1 sequence=1 recid=254 stamp=708756150
  input archive log thread=1 sequence=2 recid=255 stamp=708756383
  input archive log thread=1 sequence=3 recid=256 stamp=708756383
  channel ch00: starting piece 1 at 20-JAN-10
  channel ch00: finished piece 1 at 20-JAN-10
  piece handle=/backup/arch708756383 comment=NONE
  channel ch00: backup set complete, elapsed time: 00:00:02
  Finished backup at 20-JAN-10
  Starting Control File and SPFILE Autobackup at 20-JAN-10
  piece handle=/app/oracle/product/9.0.2/dbs/c-2494723682-20100120-01 comment=NONE
  Finished Control File and SPFILE Autobackup at 20-JAN-10
  released channel: ch00
  假设现在数据库异常宕机
  引用
  SQL> shutdown abort
  ORACLE instance shut down
  启动数据库至nomount状态
  引用
  SQL> startup nomount
  ORACLE instance started.
  Total System Global Area 1125193868 bytes
  Fixed Size                   452748 bytes
  Variable Size             335544320 bytes
  Database Buffers          788529152 bytes
  Redo Buffers                 667648 bytes [NextPage]   假设你的存储过程名为PROC_RAIN_JM
  再写一个存储过程名为PROC_JOB_RAIN_JM
  内容是:
  ///////////////////////////////////////////////////////////////////
  Create Or Replace Procedure PROC_JOB_RAIN_JM
  Is
  li_jobno         Number;
  Begin
  DBMS_JOB.SUBMIT(li_jobno,'PROC_RAIN_JM;',SYSDATE,'TRUNC(SYSDATE + 1)');
  End;
  ///////////////////////////////////////////////////////////////////
  最后那一项可以参考如下:
  每天午夜12点 'TRUNC(SYSDATE + 1)'
  每天早上8点30分 'TRUNC(SYSDATE + 1) + (8*60+30)/(24*60)'
  每星期二中午12点 'NEXT_DAY(TRUNC(SYSDATE ), ''TUESDAY'' ) + 12/24'
  每个月第一天的午夜12点 'TRUNC(LAST_DAY(SYSDATE ) + 1)'
  每个季度最后一天的晚上11点 'TRUNC(ADD_MONTHS(SYSDATE + 2/24, 3 ), 'Q' ) -1/24'
  每星期六和日早上6点10分 'TRUNC(LEAST(NEXT_DAY(SYSDATE, ''SATURDAY"), NEXT_DAY(SYSDATE, "SUNDAY"))) + (6*60+10)/(24*60)'
  其中li_jobno是它的ID,可以通过这个ID停掉这个任务,最后想说的是不要执行多次,你可以在里面管理起来,发现已经运行了就不SUBMIT
  每天运行一次 'SYSDATE + 1'
  每小时运行一次 'SYSDATE + 1/24'
  每10分钟运行一次 'SYSDATE + 10/(60*24)'
  每30秒运行一次 'SYSDATE + 30/(60*24*60)'
  每隔一星期运行一次 'SYSDATE + 7'
  不再运行该任务并删除它 NULL
  每年1月1号零时    trunc(last_day(to_date(extract(year from sysdate)||'12'||'01','yyyy-mm-dd'))+1)
广告合作:400-664-0084 全国热线:400-664-0084
Copyright 2010 - 2017 www.my8848.com 珠峰网 粤ICP备15066211号
珠峰网 版权所有 All Rights Reserved