zoukankan      html  css  js  c++  java
  • Oracle数据库备份实验笔记[不完整,内容乱]

    rman target / log=/orasoft/backup/${DATE}backup1.log <<EOF
    run {
    allocate channel c1 device type disk;
    allocate channel c2 device type disk;
    allocate channel c3 device type disk;
    backup database format '/orasoft/backup/db_%T%U.bak';
    backup current controlfile format '/orasoft/backup/ctl_%T_%U';
    backup spfile format '/orasoft/backup/spfile_%T_%U';
    release channel c1;
    release channel c2;
    release channel c3;
    }
    EOF


    #####实验1

    #创建测试数据
    create table test1a(id int) tablespace users;
    insert into test1a values (1);
    select * from test1a;
    commit;

    #开始备份
    alter tablespace users begin backup;
    cp users01.dbf -t ~/backup/
    alter tablespace users end backup;

    #模拟物理损坏
    rm users01.dbf

    #清内存(这条语句不太好使)
    SQL> alter system flush buffer_cache;
    alter system checkpoint;


    #恢复备份文件
    cp ~/backup/users01.dbf -t ./

    #恢复
    alter tablespace users offline immediate;
    recover tablespace users;
    alter tablespace users online;

    #恢复完成

    select * from test1a;





    #####实验2

    #备份
    RMAN> backup tablespace users;
    上面命令的备份文件放到了如下路径:
    /home/zhang/app/zhang/product/11.2.0/dbhome_1/dbs

    #恢复
    [zhang@pi zhang]$ rman target /
    sql "alter tablespace users offline immediate";
    RMAN> restore tablespace users;//现在数据库还不能用,但是表空间的文件已经恢复了
    RMAN> recover tablespace users;
    RMAN> sql "alter tablespace users online";  

    #恢复完成




    #####实验3

    #备份就是手工copy dbf文件的方式备份(同实验1)

    #恢复
    SQL> alter tablespace users offline immediate;
    SQL> recover tablespace users;   
    SQL> alter tablespace users online;

  • 相关阅读:
    一天一道算法题---6.8--数学题
    TOJ----1037---最大独立集
    一天一道算法题---6.6---排列递推(我不会)
    一天一道算法题---6.4--中途相遇法
    一天一道算法题--6.5--数学题
    夜太美---酒不醉--人自醉
    SSH组合之Spring3整合Hibernate4(一)
    Hibernater入门
    Java微信公众平台进入开发模式
    新浪sae平台进行数据库的连接
  • 原文地址:https://www.cnblogs.com/vanwoos/p/7805166.html
Copyright © 2011-2022 走看看