ITPub博客

首页 > 数据库 > Oracle > oracle数据库热备与恢复

oracle数据库热备与恢复

原创 Oracle 作者:cggy2012 时间:2014-06-27 15:43:35 0 删除 编辑
一、简介
1、热备份(offline backups)
数据库启动状态创建的备份就是热备份,也叫联机备份。按照我的理解就是数据库处于活动状态时创建的备份。热备份下创建的备份肯定是不一致备份,用于恢复时可能会用到archivelog与online redologs。要创建热备份首先我们要保证数据库处于归档模式,否则创建的备份可能是无效的。
二、实验
1、建立测试环境
2、进行热备
3、破坏数据库
4、关闭数据库进行恢复
5、验证恢复是否完成
-------------------------------------------------------------------------------------------
1、建立测试环境
Table dropped.
idle> CREATE TABLE t
  2  (
  3   ID NUMBER
  4  )  tablespace users;
Table created.
idle> insert into t values(1);
1 row created.
idle> insert into t values(2);
1 row created.
idle> insert into t values(3);
1 row created.
idle> commit;
Commit complete.
---------------------------------------------------------------------------------------------
2、进行热备(users表空间)
idle> alter tablespace users begin backup;
Tablespace altered.
[oracle@dap-test dw]$ cp users01.dbf /data/oracle/u01/oradata/
idle> alter tablespace users end backup;
Tablespace altered.
---------------------------------------------------------------------------------------------
3、破坏数据
[oracle@dap-test dw]$ rm -rf users01.dbf
---------------------------------------------------------------------------------------------
4、关闭数据库进行恢复
sys@DW> shutdown immediate;
    ORA-01116: error in opening database file 4
    ORA-01110: data file 4: '/data/oracle/u01/oradata/dw/users01.dbf'
    ORA-27041: unable to open file
    Linux-x86_64 Error: 2: No such file or directory
    Additional information: 3
sys@DW> shutdown abort
    ORACLE instance shut down.
 
idle> startup
    ORACLE instance started.
Total System Global Area 1620115456 bytes
    Fixed Size                  2228824 bytes
    Variable Size            1258294696 bytes
    Database Buffers          352321536 bytes
    Redo Buffers                7270400 bytes
    Database mounted.
    ORA-01157: cannot identify/lock data file 4 - see DBWR trace file
    ORA-01110: data file 4: '/data/oracle/u01/oradata/dw/users01.dbf'
 
idle> shutdown abort
[oracle@dap-test //]$ cp /data/oracle/u01/oradata/users01.dbf /data/oracle/u01/oradata/dw/
---------------------------------------------------------------------------------------------
5、验证恢复是否完成
idle> startup
    ORACLE instance started.
Total System Global Area 1620115456 bytes
    Fixed Size                  2228824 bytes
    Variable Size            1258294696 bytes
    Database Buffers          352321536 bytes
    Redo Buffers                7270400 bytes
    Database mounted.
    ORA-01113: file 4 needs media recovery
    ORA-01110: data file 4: '/data/oracle/u01/oradata/dw/users01.dbf'
 
idle> recover database
    Media recovery complete.
    idle> alter database open;
Database altered.
idle> select * from t;
     ID
    ----------
         1
         2
         3
         5

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/29076828/viewspace-1196308/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: flashback与timestamp
下一篇: 冷备与恢复
请登录后发表评论 登录
全部评论

注册时间:2013-10-24

  • 博文量
    21
  • 访问量
    35529