利用热备恢复表空间

原理:

和冷备一致性关闭数据库后拷贝数据库文件备份相反,是在数据库处于开启状态下做的备份。
备份方式:在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博客 ” ,链接:http://blog.itpub.net/31405405/viewspace-2136670/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/31405405/viewspace-2136670/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值