• rman备份恢复命令总结


     关注公众号


    备份:


    Backup 有增量,copy 没有增量。
    0,所有的使用的数据块,是基石
    1—4 增量级别,备份<=n 以来的变化
    1c---4c 累积增量,备份<=n-1 以来的变化
    通过增量的级别来指定完备的备份策略

    一、report:列出需要备份的所有物理文件--应该做什么
    report schema;--数据库的结构是什么
    report need backup days 3;

    二、list:列出备份集详细信息--已经有什么了
    list backup;
    list backup of datafile 9;
    list copy of controlfile;
    list backup of controlfile;
    list backup of spfile;

    三、crosscheck:按照控制文件记录的信息,校验实际备份文件
    crosscheck backup;
    crosscheck copy;

    delete –把控制文件中的信息删除
    delete noprompt expired copy;

    expired: rman的备份信息存储在控制文件,如果手工的删除备份文件,数据库不知道

    如:
    crosscheck archivelog all;
    delete noprompt expired archivelog all ;
    DELETE noprompt ARCHIVELOG ALL COMPLETED BEFORE 'SYSDATE-1';

    四、show:查看参数
    show all;

    五、obsolete—不符合保留策略的;
    report obsolete;
    delete noprompt obsolete;

    六、catalog命令
    登记备份片:
    catalog backuppiece '/setup/rman/f4.dbf';
    登记目录下所有的备份片:
    catalog start with '/setup/rman';

    七、
    增量备份:
    backup incremental level 0 datafile 4 format ‘’;
    累积增量备份:
    backup cumulative incremental level 1 datafile 4 format ‘’;

    八、控制文件备份:
    (1)单独备份控制文件
    (2)备份1号文件的时候,自动备份控制文件
    (3)可以在备份的时候加上include current controlfile
    backup datafile 4 include current controlfile format ‘/setup/bk/f4’;
    (4)控制文件的自动备份策略
    (5)控制文件的copy

    backup current controlfile format ‘/setup/bk/%u.ctl’;
    copy current controlfile to 'd:kc1.ctl';

    copy current controlfile to '/setup/rman/1_bak.ctl';
    相当于:
    alter database backup controlfile to ‘’;

    九、数据文件的备份:
    backup datafile 4 format 'c:kf4_%u';

    十、归档日志的备份:
    copy archivelog 'F:oracleoradatazl9archARC264.LOG' to 'd:ka.cp';
    BACKUP ARCHIVELOG ALL DELETE INPUT format 'd:karc%s.bk';
    backup archivelog sequence between 264 and 265 thread=1 format 'd:karc%s.bk';
    backup archivelog sequence between 50 and 52 thread=1 like '%0586360856%' format 'c:karc%s.bk';

    十一、备份spfile:
    backup spfile format 'd:kspfile.%s';


    其他:
    backup as compressed backupset database include current controlfile plus archivelog delete input format '/setup/rman/%T_%U';
    backup database format 'c:k\%d_%s_%p' filesperset 3;
    backup as compressed backupset format 'c:arcf4_%u' datafile 4 tag='users_full';


    恢复:


    一、数据块恢复
    BLOCKRECOVER DATAFILE 12 BLOCK 12;

    二、控制文件恢复:
    1. 启动数据库到nomount状态
    2.
    rman target /
    set dbid=XXX
    如果controlfile全部丢失,可能无法获得dbid,需要使用restore controlfile from '';恢复控制文件。
    RESTORE CONTROLFILE FROM 'C:kORA10O1_MF_NCNNF_TAG20071221T112712_3PPDNLWG_.BKP';
    3. restore controlfile from autobackup;
    4. alter database mount;
    5. recover database;
    6. alter database open resetlogs;
    重新全备数据库。

    三、数据文件的恢复:
    select name,enabled,status from v$datafile;
    1. alter database datafile 4 offline;
    2. list backup of datafile 4 summary;
    3. restore datafile 4;
    4. recover datafile 4;
    5. alter database datafile 4 online;
    select name,enabled,status from v$datafile;

    四、表空间的恢复:
    restore tablespace users;
    recover tablespace users;
    alter tablespace users online;
    select name,enabled,status from v$datafile;

    五、系统表空间的恢复(undo,system,sysaux):
    数据库启动到mount状态
    restore tablespace system;
    recover tablespace system;
    alter database open;

    六、不完全恢复
    数据库得处于mount状态

    使用scn:
    run {
    allocate channel c1 type DISK;
    allocate channel c2 type DISK;
    set until SCN = ****** ;
    restore database;
    recover database;
    alter database open resetlogs; }

    (scn号####)
    recover database until change #### using backup controlfile;

    使用时间点:
    run {
    allocate channel c1 type disk;
    allocate channel c2 type disk;
    sql 'alter session set nls_date_format="yyyy-mm-dd hh24:mi:ss"';
    set until time = '2011-10-19 22:21:38';
    restore database;
    recover database;
    alter database open resetlogs;
    }


    ****************************
    物理时间和数据库间的SCN 的对照表,每五分钟采样
    select to_char(TIME_DP,'yyyy/mm/dd:hh24:mi:ss'),SCN from SYS.SMON_SCN_TIME;
    set num 50
    select current_scn from v$database;
    ****************************

    直接恢复到最近:
    recover database until cancel;
    alter database open resetlogs;

    七、数据库的完全恢复
    启动到mount状态
    Restore database;
    Recover database;

  • 相关阅读:
    训练一个图像分类器
    边界值分析
    系统测试
    单元测试
    集成测试
    为什么要调整挖矿难度
    并在session里执行graph
    pytorch处理数据
    判定表测试
    qemusystemriscv64
  • 原文地址:https://www.cnblogs.com/xingxingdiandian/p/9269338.html
Copyright © 2020-2023  润新知