oracle-backup-hot backup

hot backup

--**********************************
-- 1、环境确认 归档模式、路径、文件
--**********************************

alter system set log_archive_dest_1='location=/tools/ko16_arch' scope =both;
alter system set db_recovery_file_dest_size=5368709102;

SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /tools/ko16_arch
Oldest online log sequence     54
Next log sequence to archive   56
Current log sequence           56

set lines 200
col file_name format a50

select tablespace_name,file_name from dba_data_files;

TABLESPACE_NAME                FILE_NAME
------------------------------ --------------------------------------------------
SYSTEM                         /oracle/app/oracle/oradata/ko16/system01.dbf
SYSAUX                         /oracle/app/oracle/oradata/ko16/sysaux01.dbf
UNDOTBS1                       /oracle/app/oracle/oradata/ko16/undotbs01.dbf
USERS                          /oracle/app/oracle/oradata/ko16/users01.dbf

2、准备测试数据
conn scott/tiger

insert into t1 values(1,sysdate);
commit;
alter system switch logfile;
insert into t1 values(2,sysdate);
commit;
alter system switch logfile;

SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /tools/ko16_arch
Oldest online log sequence     56
Next log sequence to archive   58
Current log sequence           58

[oracle@dg1 ko16_arch]$ ll
total 988
-rw-r----- 1 oracle oinstall   4096 Mar 13 11:47 1_55_841493987.dbf
-rw-r----- 1 oracle oinstall 987136 Mar 13 12:10 1_56_841493987.dbf
-rw-r----- 1 oracle oinstall  16384 Mar 13 12:12 1_57_841493987.dbf

3、开始备份
alter tablespace SYSTEM begin backup;
!cp /oracle/app/oracle/oradata/ko16/system01.dbf /tools/ora_bak/0313
alter tablespace SYSTEM end backup;

alter tablespace SYSAUX begin backup;
!cp /oracle/app/oracle/oradata/ko16/sysaux01.dbf  /tools/ora_bak/0313
alter tablespace SYSAUX end backup;

alter tablespace UNDOTBS1 begin backup;
!cp /oracle/app/oracle/oradata/ko16/undotbs01.dbf  /tools/ora_bak/0313
alter tablespace UNDOTBS1 end backup;

alter tablespace USERS begin backup;
insert into scott.t1 values(3,sysdate);
commit;
alter system switch logfile;
insert into scott.t1 values(4,sysdate);
commit;
alter system switch logfile;

!cp /oracle/app/oracle/oradata/ko16/users01.dbf  /tools/ora_bak/0313
alter tablespace USERS end backup;

insert into scott.t1 values(5,sysdate);
insert into scott.t1 values(6,sysdate);
commit;
alter system switch logfile;

4、模拟数据损坏
rm -rf users01.dbf
将归档文件cp到磁带
shutdown abort

SQL> startup
ORACLE instance started.

Total System Global Area  521936896 bytes
Fixed Size                  2214936 bytes
Variable Size             364905448 bytes
Database Buffers          150994944 bytes
Redo Buffers                3821568 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 4 - see DBWR trace file
ORA-01110: data file 4: '/oracle/app/oracle/oradata/ko16/users01.dbf'

5、恢复
alter database datafile '/oracle/app/oracle/oradata/ko16/users01.dbf' offline ;
alter database open;

通知backup组将从磁带中恢复/oracle/app/oracle/oradata/ko16/users01.dbf及备份期间的归档日志

SQL> recover datafile '/oracle/app/oracle/oradata/ko16/users01.dbf';
ORA-00279: change 846808 generated at 03/13/2014 12:29:09 needed for thread 1
ORA-00289: suggestion : /tools/ko16_arch/1_58_841493987.dbf
ORA-00280: change 846808 for thread 1 is in sequence #58


Specify log: {=suggested | filename | AUTO | CANCEL}

ORA-00279: change 846816 generated at 03/13/2014 12:29:09 needed for thread 1
ORA-00289: suggestion : /tools/ko16_arch/1_59_841493987.dbf
ORA-00280: change 846816 for thread 1 is in sequence #59


Specify log: {=suggested | filename | AUTO | CANCEL}

Log applied.
Media recovery complete.


alter database datafile '/oracle/app/oracle/oradata/ko16/users01.dbf' online ;
select * from scott.t1;

        NO CDATE
---------- -------------------
         1 2014-03-13 12:07:53
         2 2014-03-13 12:12:03
         3 2014-03-13 12:29:32
         4 2014-03-13 12:29:48
         5 2014-03-13 12:31:24
         6 2014-03-13 12:31:24

6 rows selected.

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

转载于:http://blog.itpub.net/22193071/viewspace-1148757/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值