记一次oracle rman增量备份恢复计划

所需积分/C币:27 2018-12-07 14:45:17 663KB PDF

1.1 备份时间 凌晨2点(02:00:00) 1.2 备份操作 注: 增量备份模式为cumulative(累积模式) 1. 周日:0级增量备份 1. 周一:1级增量备份 1. 周二:1级增量备份 1. 周三:1级增量备份 1. 周四:0级增量备份 1. 周五:1级增量备份 1. 周六:1级增量备份 1.3 效果 保留策略为保存14天,也就是能恢复到14天内的任何时间点 并且实现本地备份+异地备份
/data/oracle/ora backup/level 1 incr %T/controlfile/control %F configure device type disk parallelism 2; crosscheck backup t obsolete delete noprompt expired backup; allocate channel dev1 type disk; allocate channel dev2 type disk; backup as compressed backupset incremental level=l cumulative tag=level1%t format /data/oracle/ora backup/level 1 incr %T/dbfile/db %n %T %U database; sgl'alter system archive log current backup archivelog all format/ data/oracle/ora backuplevl 1_ incr %T/arch/arc %n %T- %U delete all input; release channel dev1; release channel dev2 23|nux脚本 expect脚本来自动输入密码( expect_ scp) #/data/oracle/ora backup/script set timeout 100 set password"123456"#目标服务器指定用户登录密码 set src file [lindex Sargv 0] set dest file [lindex $argv 1] spawn sCp-2--$ src file用户名@服务器ip: Sdest_ile t (yes/no)? send yes\n expect *assword: "i send " spas sword\n") as sword send "$password\n expect 1007 expect eof a零级备份( shell rman bak_0.sh) #!/bin/bash #f incremental level 0 backup script #零级备份脚本 source /home/oracle/bash profile current day= date +7Y/m%d name= date -d now +%F incr day=level 0 incr scurrent day mkdir /data/oracle/ora backup/sincr day mkdir /data/oracle/ora backup/sincr day/arch mkdir /data/oracle/ora backup/sincr day /controlfile mkdir /data/oracle/ora backup/sincr day/dbfile mkdir /data/oracle/ora backup/sincr day/dbfile log echo echo -- Begin Increment Backup of Db DateTime: date echo ----- SORACLE HOME/bin/rman target/ log=/data/oracle/ora backup/sincr day/dbfile log/backup log_ sname log <<EOF @/data/oracle/ora backup/script/rman bak 0 it EOF echo End Increment Backup of DB 10. 103. 23. 102 DateTime: date echo echo - start of send file to 10.103.23 103 Datetime: date /data/oracle/ora backup/script/expect scp /data/oracle/ora backup/sincr day /data/test #iBF expect scp脚本实现异机备份 echo echo - End of send file to 10.. 103 Datetime date echo echo echo b.-级备份( shell rman bak1.sh) #!/bin/bash #一级级份脚本 source /home/oracle/ bash profile current day= date +%Y%m%d name= date -d now +%F incr day =level 1 incr scurrent day mkdir /data/oracle/ora backup/sincr day mkdir /data/oracle/ora backup/sincr day /arch mkdir /data/oracle/ora backup/sincr day /controlfile mkdir /data/oracle/ora backup/sincr day/dbfile mkdir /data/oracle/ora backup/sincr day/dbfile log echo'-------------- echo --Begin Increment Backup of DB DateTime: date soRACLE HOME/bin/rman target/ log=/data/oracle/ora backup/sincr day/dbfile log/backup log_sname log <<EOF data/oracle/ora backup/script/rman bak_1 exit EOF echo echo - End Increment Backup of DB 10 103.23 102 DateTime: date-- echo echo - start of send file to 10. 103.23 103 Datetime date #scp-2 -r /data/oracle/ora backup/sincr day root@124.235.118.12: data/test /data/oracle/ora backup/script/expect scp /data/oracle/ora backup /sincr day /data/test #iaF expect scp脚本实现异机备份 echo i echo - End of send file to 10. 103.23, 103 DateTime: date echo 24inux定时任务 Toracle@liux script]$ crontab 0 2 **0,4/data/oracle/ora backup/script/ shell rman bak esh 0 2 + 1, 2,3,5, 6/data/oracle/ora backup/script/shell rman bak_ 1. sh 3、恢复 RMAN恢复分为完全恢复和不完全恢复。完全恢复,顾名思义,就是基于全备的基础上对数据进行恢复。但是真实 环境中这样的恢复用得很少。相反,不完全恢复使用较多。不完全恢复,也就是通过备份文件,恢复某一个误操作 或者是某一段时间丢失的数据。不完全恢复可以基于时间,基于SCN,基于日志序列号、基于备份控制文件。本文 讲解基于时间点的不完全恢复 31异机恢复 这里只给出异机完全恢复 参考: Linux平台下RMAN异机恢复总结 3.1.1环境说明 源服务器 目标服务器 oracle版本 11.2.0.1.0-Production 11.2.0.1.0- Produ 安装目录( ORACL_HOME) /home/oracle/app/oracle/product/11.2.0/dbhome_ /data/database/oracle/product/11.2.0/db_ 文件备份目录 /data/oracle/ara backi /home/oracle/oradata/backu 实例名称 backs 3.12将备份文件考到目标服务器的相关目录(以备份目录为例) 将在源服务器数据库备份的数据文件拷贝至目标服务器的备份目录(/home/ oracle/ oradata/ backup) 注意:如果在备份的 llinux脚本中有如图所示的命令、且 expect_s卬p脚本中的IP地址、目录均正确,则可以省略 这一步 EOF echo echo End Increment Backup of DB 10 103.23 102 DateTime: date echo echo-- start of send file to 10.103.23 103 DateTime:date /data/oracle/ora backup/script/expect_ scp /data/oracle/ora backup/sinc day /data/test echo echo-- End of send file to 10,103. 23. 103 DateTime: date echo echo echo 3.1.3恢复步骤 a.先查询源数据库的DBD SQL> select name, dbid from vsdatabase; NAME DB工D BACKDB 627414831 SOL> b将目标数据库启动到 nomount状态 s sqlplus /nol SQL> conn /as sysdba SQL> shutdown immediate SQL> Startup nomount c.修改目标数据库的DBD与源数据库一致 s rman target/ RMAN> set dbID=627414031 d.还原spfe文件 RMAN>restore spfile to pfile /data/database/oracle/product/11.2.0/db 1/dbs/spfilebackdb ora from/home/oracle/oradata/backup/levl incr 20181206/controlfile/control c-627414031-20181206 恢复结束后新开窗口进入bs目录修改 spfilebackdbora文件 s cd /data/database/oracle/product/11.2.0/db_1/dbs/ s vi spfilebackdbora 修改前 ispfilebackora backdb. db cache size=2348810240 backdb. java pool size=67108864 backdb. large pool size=67108864 backdb. oracle base=/home/oracle/app/oracle #ORACLE BASE set from environment backdb. pga aggregate target=2684354560 backdb. sga target=4026531840 backdb. shared io pool size=0 backdb. shared pool size=1476395008 backdb. streams pool size=0 *. audit file dest='/home /oracle/app/oracle/ admin/backdb/adump * audit trail=db *, compatib1e='11.2.0.0,8 *. control file record keep time=15 *. control files='/home/oracle/app/oracle/oradata/backdb/controlol ctl,/home/oracle/app/oracle/ oradata/backdb/contro102 ctl k, db block size=8192 k, db domain= db name="backdb *.diagnostic dest=/home/oracle/app/oracle *. dispatchers='(PROTOCOL=TCP)(SERVICE=backdbXDB) * memory target=6689914880 来. open cursors=388 本, processes=158 * remote login_ passwordfile= EXCLUSIVE undo tablespace="UNDOTBS1 修改后 spfilebackora backdb. db cache size=2348810240 backdb._javapool_size=67108864 backdb._large_pool_size=67108864 backdb. oracle_ base='/home/oracle/app/oracle #oRACLE_ BASe set from environment backdb. pga aggregate target= 2684354560 backdb._ sga target=4026531840 backdb.shared_io_pool_size=0 backdb shared pool-size=1476395008 backdb. streams pool size=0 audit file dest='/data/database/oracle/admin/backdbfadunp audit-tralld6 compatible=11. 2.0.0.0 ontrol_files='/data/ database/oracle/oradat a/backdbycontrol01 ctl', '/data/database/oracleforadat a/ backdb/contro102 ctI' db block 31z0=819 db domain= db backs diagnostic dest='/data/database/oracle dispatchers=(PROTOCOL=ICP)(SERVICE=backdbXDB) memory target=6689914880 open cursors=300 eg=150 remote_ login_passwordfile= EXCLUSIVE mdo tablespace=" UNDOIBS1 根据 spfileback oro创建相应的目录 s mkdir /data/database/oracle/admin/backdb/adump s chown -R oracle: oinstall /data/database/oracle/admin/backdb/adump e.修改环境变量中的 ORACLE SID s export ORACLE SID=backdb 或者vi/home/ oracle/. bash profi1e并 source. bash profile f.还原控制文件 回到RMAN窗口 RMAN> shutdown immediate RMAN> quit s rman target/ RMAN> startup nomount RMAN> restore controlfile from /home/oracle/oradata/backup/levl 0 incr 20181206/controlfile/control c-627414031-20181206-00'; g将数据库修改至 mount状态 RMaN> alter database mount database mounted released channel: ORA DISK 1 RMAN> h.检查数据库备份有效性 RMAN> crosscheck backup; using channel ORA DISK_ 1 sing channel ORA DISK 2 cross checked backup piece: found to be AVAILABLE backup piece handle=/data/oracle/ora backup/levl 0 incr 20181206/ dbfile/db BACKDBXX 20181206 2stk29p3 1 1 RECID=88 STAMP=994156632 crosschecked backup piece: found to be 'AVAI LABLE backup piece handle=/data/oracle/ora backup/levl incr 20181206/dbfile/db BACKDBxx_ 20181206 2ttk29p3_1_1 RECID=89 STAMP=994156632 crosschecked backup piece: found to be AVAILABLE backup piece handle=/data/oracle/ora backup/levl0incr 20181206/arch/arc BACKDBXX 20181206 3otk29q11-1 RECID=90 STAMP=994156632 crosschecked backup piece: found to be AVAILABLE ba acup piece handle=/data/oracle/ora backup/levl 0 incr_ 20181206/arch/arc BACKDBXX 20181206 2vtk29g0_1-1 RECID=91 STAMP=994156632 Crosschecked 4 objects crosschecked backup piece: found to be EXPIRED backup piece handle=/data/oracle/ora backup/dbfile/levl 0 incr_ 20181205/db BACKDBXX_ 20181205 0ctkolm7_1_ 1 RECID=8 STAMP=994072263 crosschecked backup piece: found to be EXPIRED backup piece handle=/data/oracle/ora backup/dbfile/levl 0 incr 20181205/db BACKDBXX_ 20181205 0dtkolm7_1 RECID=9 STAMP=994072263 crosschecked backup piece: found to be ' EXPIRED backup piece handle=/data/oracle/ora backup/controlfile/levl 0_ incr_ 20181205/control-c 627414031-20181295-92 RECID=18 STAMP=994872288 crosschecked backup piece: found to be EXPIRED backup piece handle=/data/oracle/ora backup/archlevl 0 incr 20181205/ arc BACKDBXX 20181205 eftkoln2 1 1 RECID=11 STAMP=99407229e crosschecked back iece found to be EXPIreD backup lee handle=/data/oracle/ora backup/arch/levl 0 incr 20181205/arc BACKDBXX 20181205 0gtkoin2_1 1 RECID=12 STAMP=994072290 crosschecked backup piece: found to be ' EXPIRED backup piece handle=/data/oracle/ora backup/controlfile/levl p incr 20181205/control_ c 627414031-29181295-03 RECID=13 STAMI=994972291 crosschecked backup piece: found to be EXPIRED backup piece handle=/data/oracle/ora backup/levl 0 incr_ 20181205/dbfile/db BACKDBxX 20181205_ 2gtk16fa 1_1 RECID=74 STAMP=994089450 crosschecked backup piece: found to be EXPIRED backup piece handle=/data/oracle/ora backup/levl incr 20181205/dbfile/db BACKDBXX_ 20181205 2htk16fa_1_1 RECID=75 STAMP=994089450 crosschecked backup piece: found to be EXPIRED backup piece handle=/data/oracle/ora backup/levl 0 incr- 20181205/controlfile/control-c 627414031-20181295-18 RECID=76 STAMP=994989475 crosschecked backup piece: found to be EXPIRED backup piece handle=/data/oracle/ora backup/levl 0 incr 20181205/arch/arc BACKDBxx 20181205 2jtk16g4 1_1 RECID=77 STAMP=994089476 crosschecked backup piece: found to be EXPIRED backup piece handle=/data/oracle/ora backup/levl 0 incr 20181205/arch/arc BACKDBxX 20181205_2ktk16g4_1-1 RECID=78 STAMP=994089477 crosschecked backup piece: found to be EXPIRED backup piece handle=/data/oracle/ora backup/levl incr_ 20181205/controlfile/control-c 627414031-20181295-19 RECID=79 STAMP=99498947 crosschecked backup piece: found to be EXPIRED backup piece handle=/data/oracle/ora backup/levl 0 incr 20181205/dbfile/db BACKDBXX 20181205 2ntk16iv 1 1 RECID=80 STAMP=994089567 crosschecked backup piece: found to be EXPIRED backup piece handle=/data/oracle/ora backup/levl 0 incr 20181205/abtile/db BACKDBXX 20181205 2mtk16iv 1 1 RECID=81 STAMP=994089567 crosschecked backup piece: found to be 'EXPIRED backup piece handle=/data/oracle/ora backup/levl 0_incr_ 20181205/controlfile/control-c 627414031-28181295-1 a recid=82 STAMP=994989570 crosschecked backup piece: found to be EXPIRED backup piece handle=/data/oracle/ora backup/levl 0 incr 20181205/arch/arc BACKDBXX 20181205 2ptk16j41-1 RECID=83 STAMP=994089572 crosschecked backup piece: found to be EXPIRED backup piece handle=/data/oracle/ora backup/levl_0 incr 20181205/arch/arc BACKDBXX_ 20181205_ 2qtk1634_1_1 RECID=84 STAMP=994089572 crosschecked backup piece: found to be EXPIRED backup piece handle=/data/oracle/ora backup/levl 0_incr_ 20181205/controlfile/control_c 627414031-28181295-1 b reCID=85 STAMP=994889573 crosschecked backup piece: found to be ' EXPIRED backup piece handle=/data/oracle/ora backup/levi 0 incr 20181206/dbfile/db BACKDBxX 20181206 2stk29p3 1 1 RECID=86 STAMP=994125603 crosschecked backup piece: found to be EXPIRED backup piece handle=/data/oracle/ora backup/levl 0 incr 20181206/dbfile/db BACKDBxX 20181206 2ttk29p3_ 1_1 RECID=87 STAMP=994125603 Crosschecked 20 objects 使用 catalog start with命令将以前的备份集信息重新导入到当前控制文件中 RMAN> catalog start with/home/oracle/oradata/backup j RMAN> crosscheck backup; using channel ORA DISK_ 1 using channel ORA DISK_ 2 crosschecked backup piece: found to be AVAILABLE backup piece handle=/home/oracle/oradata/backup/levl incr 20181206/dbfile/db_ BACKDBXX_ 20181206 2stk29p31-1 RECID=88 STAMP=994156632 crosschecked backup piece: found to be 'AVAILABLE backup piece handle=/home/oracle/oradata/backup/levl 0 incr 20181206/dbfile/db BACKDBxX 20181206 2ttk29p3 1 1 RECID=89 STAMP=994156632 crosschecked backup piece: found to be AVAILABLE backup piece handle=/home/oracle/oradata/backup/levle incr 20181206/arch/arc BaCKDBxX 20181206 30tk29q1- 1 1 RECID=90 STAMP=994156632 crosschecked backup piece: found to be AVAILABLE backup piece handle=/home/oracle/oradata/backup/levl 0 incr 20181206/arch/arc BACKDBXX 20181206 2vtk29qo 1 1 RECID=91 STAMP=994156632 Crosschecked 4 objects crosschecked backup piece: found to be EXPIRED backup piece handle=/data/oracle/ora backup/ dbfile/levl 0 incr 20181205/db BACKDBxX 20181205 0ctkolm7 1 1 RECID=8 STAMP=994072263 crosschecked backup piece: found to be EXPIRED

...展开详情
img
  • 分享学徒

    成功上传1个资源即可获取

关注 私信 TA的资源

上传资源赚积分,得勋章
    最新推荐