• 使用rman备份异机恢复数据库


    一.RMAN备份源库
    注意点:
     最好保留rman备份日志

    $rman target / log=backup.log
    RMAN>run {
    allocate channel t1 type disk;
    allocate channel t2 type disk;
    allocate channel t3 type disk;
    allocate channel t4 type disk;
    backup format '<give location of backup/%U>' filesperset 8 (database);
    
    sql 'alter system archive log current';
    backup format '<give location of backup/%U>' fiesperset 8 (archivelog all);
    backup format '<give location of backup/%U>' current controlfile;
    }

    二.将备份文件传输到用于恢复的机器
    注意点:
    在10之前,必须将备份放到相同的路径和目录;10g之后,可以使用catalog命令进行注册。
    除了备份文件,还要将参数文件传输过去(当然也可以自己重建)

    2.1 创建或修改参数文件
     对于参数文件中使用的文件路径目录都要创建好
    2.2 创建口令文件

     C:> orapwd file=pwdmdb.ora password=ys06 entries=2

    2.3 创建oracle services(windows平台需要执行)

      C:> ORADIM -new -sid mdb -intpwd ys06 -maxusers 10 -startmode auto -pfile  'C:init.ora';

    三.还原控制文件

    > set oracle_sid=mdb
    > sqlplus /nolog
    $ connect /as sysdba
    $ startup nomount pfile=C:init.ora
    $ exit
    > rman target / 
    RMAN> restore controlfile from 'C:dataNCCNTRL_20150921_8AQHLUR6_1_1'  #这一步需要使用到参数文件中对控制文件的配置信息
    RMAN> alter database mount;

    四.catalog备份信息
    如果备份文件的位置和源库上不同,需要进行catalog注册

    RMAN> catalog start with '备份文件的存放目录' noprompt;         #会将所有的备份片注册进来    
    RMAN> crosscheck backup tag '<backup tag from backup log>' ;     #如果有多份备份,将老的备份标记为expired     
    RMAN> delete expired backup;                                      #删除过期的备份   

    五.还原数据库

    RMAN> report schema;    #列出schema信息,如果源库和目标库的文件位置或文件名不同,需要使用set newname进行重新设置
    RMAN> run{
       allocate channel t1 type disk;
       allocate channel t2 type disk;
       set newname for datafile 1 to 'C:ORACLEORADATASYSTEM01.DBF';
       set newname for datafile 2 to 'C:ORACLEORADATASYSAUX01.DB';
       set newname for datafile 3 to 'C:ORACLEORADATAUNDOTBS01.DBF';
       set newname for datafile 4 to 'C:ORACLEORADATAUSERS01.DBF';
       set until sequence 24;           
       restore database;
       switch datafile all;
       recover database;
      }

    sequence可以从rman备份日志中找到,或者查看v$backup_redolog

    六.重命名redo文件

    SQL> set lines 200
         col member format a60
         select a.thread#,a.group#,b.type,b.member,a.bytes/1048576 
         from v$log a,v$logfile b 
         where a.group#=b.group# order by a.group#;
    SQL> alter database rename file '<old file location and name>' to '<new location and name>';

    确认一下

    SQL> select a.thread#,a.group#,b.type,b.member,a.bytes/1048576 from v$log a,v$logfile b where a.group#=b.group# order by a.group#;

    七.重命名temp文件

    SQL> alter database rename tempfile 'D:APPADMINISTRATORORADATAmdbTEMP01.DBF' to 'C:ORACLEORADATATEMP01.DBF'

    八.打开数据库

    SQL> alter database open resetlogs;
    SQL> create spfile from pfile;
    SQL> shutdown immediate
    SQL> startup

    数据异机还原后,和源库有相同的DBID和DB_NAME

  • 相关阅读:
    Pandas高级教程之:category数据类型
    Pandas高级教程之:处理缺失数据
    Pandas高级教程之:处理text数据
    密码学系列之:blowfish对称密钥分组算法
    架构之:数据流架构
    ES6中的新特性:Iterables和iterators
    密码学系列之:feistel cipher
    Pandas高级教程之:Dataframe的重排和旋转
    Electron实用技巧-electron-builder中用户协议(license)的使用及多语言支持
    Electron实用技巧-开机启动时隐藏主窗口,只显示系统托盘
  • 原文地址:https://www.cnblogs.com/abclife/p/4825999.html
Copyright © 2020-2023  润新知