ITPub博客

首页 > 数据库 > Oracle > 利用热备恢复表空间

利用热备恢复表空间

原创 Oracle 作者:刘锡亚 时间:2017-04-05 22:09:20 0 删除 编辑

原理:

和冷备一致性关闭数据库后拷贝数据库文件备份相反,是在数据库处于开启状态下做的备份。
备份方式:在sqlplus中手工发起备份;利用rman工具备份

手工备份:alter tablespace XXX begin backup;
               操作系统层面拷贝数据文件到某个路径;
               alter tablespace XXX end backup;
rman工具备份: backup tablespace XXX;

  1. 开启归档

    点击(此处)折叠或打开

    1. SQL> archive log list;
    2. Database log mode No Archive Mode
    3. Automatic archival Disabled
    4. Archive destination /u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch
    5. Oldest online log sequence 4
    6. Current log sequence 6
    7. SQL> shutdown immediate;
    8. Database closed.
    9. Database dismounted.
    10. ORACLE instance shut down.
    11. SQL> startup mount;
    12. ORA-32004: obsolete or deprecated parameter(s) specified for RDBMS instance
    13. ORACLE instance started.

    14. Total System Global Area 217157632 bytes
    15. Fixed Size 2251816 bytes
    16. Variable Size 159384536 bytes
    17. Database Buffers 50331648 bytes
    18. Redo Buffers 5189632 bytes
    19. Database mounted.
    20. SQL> alter database archivelog;

    21. Database altered.

    22. SQL> alter database open;

    23. Database altered.

  2. 创建表空间

    点击(此处)折叠或打开

    1. SQL> create tablespace test01 datafile '/u01/app/oracle/oradata/PROD1/test01.dbf' size 10M autoextend on maxsize 2G;

    2. Tablespace created.


  3. 模拟业务

    点击(此处)折叠或打开

    1. SQL> create table test tablespace test01 as select * from dba_objects;

    2. Table created.

  4. 热备表空间

    点击(此处)折叠或打开

    1. alter tablespace test01 begin backup;

    2. Tablespace altered.

    3. SQL> !cp /u01/app/oracle/oradata/PROD1/test01.dbf /u01/app/oracle/oradata/PROD1/test01.dbf.bak

    4. SQL> alter tablespace test01 end backup;

    5. Tablespace altered.


  5. 模拟故障

    点击(此处)折叠或打开

    1. !rm /u01/app/oracle/oradata/PROD1/test01.dbf

    2. SQL> shutdown immediate;
    3. ORA-03113: end-of-file on communication channel
    4. Process ID: 19295
    5. Session ID: 16 Serial number: 3


    6. SQL> conn / as sysdba
    7. Connected to an idle instance.
    8. SQL> startup
    9. ORA-32004: obsolete or deprecated parameter(s) specified for RDBMS instance
    10. ORACLE instance started.

    11. Total System Global Area 217157632 bytes
    12. Fixed Size 2251816 bytes
    13. Variable Size 159384536 bytes
    14. Database Buffers 50331648 bytes
    15. Redo Buffers 5189632 bytes
    16. Database mounted.
    17. ORA-01157: cannot identify/lock data file 6 - see DBWR trace file
    18. ORA-01110: data file 6: '/u01/app/oracle/oradata/PROD1/test01.dbf'


  6. 恢复(mount状态下)

    点击(此处)折叠或打开

    1. SQL> !cp /u01/app/oracle/oradata/PROD1/test01.dbf.bak /u01/app/oracle/oradata/PROD1/test01.dbf

    2. SQL> recover datafile 6;
    3. Media recovery complete.
    4. SQL> alter database open;

  7. 验证

    点击(此处)折叠或打开

    1. SQL> select count(*) from test;

    2.   COUNT(*)
    3. ----------
    4.      86954

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

上一篇: 没有了~
请登录后发表评论 登录
全部评论

注册时间:2016-10-25

  • 博文量
    13
  • 访问量
    18653