oracle end backup,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.
總結
以上是生活随笔為你收集整理的oracle end backup,oracle-backup-hot backup的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: linux oracle bad elf
- 下一篇: oracle级联删除表空间,Oracle