zoukankan      html  css  js  c++  java
  • Oracle rman备份还原

      备份脚本:

     oracle备份fullbak.sh 脚本

    . /u01/prod/db/12.1.0/PROD_erpdbp.env
    LOGDATE="`date '+%Y%m%d'`"
    #delete backup logfile
    find /u01/backup/log -mtime +360 |xargs rm -f
    rman target / cmdfile=/u01/backup/scripts/fullbak.rman log=/u01/backup/log/fullbak_$LOGDATE.log
     
    rman备份脚本fullbak.rman:
    run{
    sql 'alter system archive log current';
          allocate channel ch1 type disk;
          allocate channel ch2 type disk;
          allocate channel ch3 type disk;
          backup as compressed backupset incremental level 0 database format '/u01/backup/data/db_%d_%T_%U.bak' plus archivelog format '/u01/backup/data/arch_%d_%T_%U.bak' delete all input; 
          CONFIGURE CONTROLFILE AUTOBACKUP on; 
          release channel ch1;
          release channel ch2;
          release channel ch3;
    crosscheck backup;
    crosscheck archivelog all;
    delete noprompt expired backup;
    delete expired archivelog all;
    report obsolete;
    delete noprompt obsolete;
    }

    RMAN 还原:

    查看oracle的控制文件备份信息:
    list backup of controlfile;
    用rman恢复数据:
     1,startup nomount;
     2,set dbid= 365215955;
     3,restore controlfile from '/u01/bak/db_PROD_20190807_41u8j1iv_1_1.bak';
     4,startup mount;
    5,catalog start with '/u01/bak/';
     6,restore database
     7,recover database;
     8,alter database open resetlogs;

    这里的 set dbid= 365215955 要和主库的一致 ,查看主库sql: select dbid from v$database;

     
    recover database until scn 5971330707288;
     
    create undo tablespace undotb2 datafile '/u01/prod/db/data/undotb12.dbf' 
    size 1024M autoextend on next 10M maxsize 12048M;
     
    提示错误:
    ORA-30012: undo tablespace 'UNDOTBS1' does not exist or of wrong type
     
    强制打开数据库:
    startup force;
    重新创建undo表空间
    create undo tablespace undotb2 datafile '/u01/prod/db/data/undotb12.dbf' size 1024M autoextend on next 10M maxsize 12048M
    在设置spfile文件
    alter system set undo_tablespace=undotb2 scope=spfile;
    修改undo的管理模式
    alter system set undo_management=auto scope=spfile;
    创建undo的表空间文件
    create undo tablespace undotb2 datafile '/u01/prod/db/data/undotb12.dbf' size 1024M autoextend on next 10M maxsize 12048M
  • 相关阅读:
    C#获取根目录的方法集合
    C# 获取文件MD5值的方法
    VS2015 搭建 Asp.net core 开发环境
    【Networking】容器网络大观 && SDN 资料汇总
    【Networking】flannel,pipework,weave,udp,vxlan,ovs等资料
    【K8s】Kubernetes 最近正在看的资料
    【GoLang】go 微服务框架 && Web框架学习资料
    【Eclipse】eclipse che 协作开发
    【Kubernetes】两篇文章 搞懂 K8s 的 fannel 网络原理
    【SpringBoot】SpringBoot 入门示例
  • 原文地址:https://www.cnblogs.com/zping/p/11377479.html
Copyright © 2011-2022 走看看