基於時間執行資料庫不完全恢復
在基於時間點恢復:
---準備環境:RMAN全庫備份:
---檢視資料庫的歸檔模式:
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 11
Next log sequence to archive 13
Current log sequence 13
SQL>
---使用rman並檢視引數:
[oracle@enmo ~]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Mon Nov 7 11:30:28 2016
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: PROD (DBID=338469376)
RMAN> show all;
using target database control file instead of recovery catalog
RMAN configuration parameters for database with db_unique_name PROD are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '/u01/app/backup/db_%U.rmn';
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/snapcf_PROD.f'; # default
RMAN>
---備份全庫:
RMAN> backup as compressed backupset full database;
Starting backup at 07-NOV-16
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=37 device type=DISK
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/app/oracle/oradata/PROD/system01.dbf
input datafile file number=00002 name=/u01/app/oracle/oradata/PROD/sysaux01.dbf
input datafile file number=00005 name=/u01/app/oracle/oradata/PROD/example01.dbf
input datafile file number=00003 name=/u01/app/oracle/oradata/PROD/undotbs01.dbf
input datafile file number=00006 name=/u01/app/oracle/oradata/PROD/ts_xxf_01.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/PROD/users01.dbf
channel ORA_DISK_1: starting piece 1 at 07-NOV-16
channel ORA_DISK_1: finished piece 1 at 07-NOV-16
piece handle=/u01/app/backup/db_09rkah18_1_1.rmn tag=TAG20161107T113152 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:02:17
Finished backup at 07-NOV-16
Starting Control File and SPFILE Autobackup at 07-NOV-16
piece handle=/u01/app/oracle/fast_recovery_area/PROD/autobackup/2016_11_07/o1_mf_s_927286449_d1zxkkxq_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 07-NOV-16
#備份完成。
---準備環境:測試表及資料:
suxing@PROD>create table t1 as select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') as dd from dual;
Table created.
suxing@PROD>
--檢視錶t1的資料:
suxing@PROD>select * from t1;
DD
-------------------
2016-11-07 11:37:02
suxing@PROD>create table t2 as select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') as dd from dual;
Table created.
suxing@PROD>select * from t2;
DD
-------------------
2016-11-07 11:40:42
--刪除表t1:
suxing@PROD>drop table t1 purge;
Table dropped.
--重啟資料庫到mount狀態並透過rman恢復資料庫:
sys@PROD>shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
---刪除所有資料檔案:
[oracle@enmo ~]$ cd /u01/app/oracle/oradata/PROD/
[oracle@enmo PROD]$ ls
control01.ctl myspace01.dbf redo01.log redo03.log system01.dbf ts_xxf_01.dbf users01.dbf
example01.dbf myspace1.dbf redo02.log sysaux01.dbf temp01.dbf undotbs01.dbf
[oracle@enmo PROD]$
[oracle@enmo PROD]$ rm *.dbf
[oracle@enmo PROD]$ la
-bash: la: command not found
[oracle@enmo PROD]$ ls
control01.ctl redo01.log redo02.log redo03.log
[oracle@enmo PROD]$
---透過rman做不完全恢復資料庫:
[oracle@enmo ~]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Mon Nov 7 11:48:54 2016
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database (not started)
RMAN>
RMAN> startup mount
Oracle instance started
database mounted
Total System Global Area 835104768 bytes
Fixed Size 2257840 bytes
Variable Size 507513936 bytes
Database Buffers 322961408 bytes
Redo Buffers 2371584 bytes
#RMAN> run
{
sql 'alter session set nls_date_format="yyyy-mm-dd hh24:mi:ss"';
set until time = '2016-11-07 11:37:02';
restore database;
recover database;
alter database open resetlogs;
}#草稿
RMAN> run
2> {
3> sql 'alter session set nls_date_format="yyyy-mm-dd hh24:mi:ss"';
4> set until time = '2016-11-07 11:37:02';
5> restore database;
6> recover database;
7> alter database open resetlogs;
8> }
using target database control file instead of recovery catalog
sql statement: alter session set nls_date_format="yyyy-mm-dd hh24:mi:ss"
executing command: SET until clause
Starting restore at 07-NOV-16
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=18 device type=DISK
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to /u01/app/oracle/oradata/PROD/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /u01/app/oracle/oradata/PROD/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/PROD/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/PROD/users01.dbf
channel ORA_DISK_1: restoring datafile 00005 to /u01/app/oracle/oradata/PROD/example01.dbf
channel ORA_DISK_1: restoring datafile 00006 to /u01/app/oracle/oradata/PROD/ts_xxf_01.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/backup/db_09rkah18_1_1.rmn
channel ORA_DISK_1: piece handle=/u01/app/backup/db_09rkah18_1_1.rmn tag=TAG20161107T113152
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:04:32
Finished restore at 07-NOV-16
Starting recover at 07-NOV-16
using channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time: 00:00:02
Finished recover at 07-NOV-16
database opened
RMAN>
---檢視錶:
suxing@PROD>select tname from tab where tname like 'T_';
TNAME
------------------------------
T1
suxing@PROD>
---檢視系統的資料檔案:
[oracle@enmo ~]$ cd -
/u01/app/oracle/oradata/PROD
[oracle@enmo PROD]$
[oracle@enmo PROD]$
[oracle@enmo PROD]$ ls
control01.ctl redo01.log redo03.log system01.dbf ts_xxf_01.dbf users01.dbf
example01.dbf redo02.log sysaux01.dbf temp01.dbf undotbs01.dbf
#已經恢復成功。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/31392094/viewspace-2127957/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- ORACLE資料庫基於時間點的不完全恢復Oracle資料庫
- 備份與恢復:Polardb資料庫資料基於時間點恢復資料庫
- (Les16 執行資料庫恢復)-表空間恢復資料庫
- 基於percona xtrabackup之innobackupex實現基於時間點資料庫恢復資料庫
- 如何進行Oracle資料庫不完全恢復RBOracle資料庫
- 【北亞資料恢復】oracle資料庫執行truncate table命令怎麼恢復資料?資料恢復Oracle資料庫
- 大事務導致資料庫恢復時間長資料庫
- 12C針對cdb全備與 PDB執行不完全恢復(基於SCN)
- mongodb 基於oplog的時間點恢復MongoDB
- 【資料庫資料恢復】SQL Server資料庫磁碟空間不足的資料恢復案例資料庫資料恢復SQLServer
- MySQL binlog基於時間點恢復資料失敗是什麼鬼?MySql
- DM8 基於時間點的恢復
- DM7使用DMRMAN執行RAC資料庫恢復資料庫
- 【資料庫資料恢復】SAP資料庫資料恢復案例資料庫資料恢復
- 寶塔資料庫恢復 mysql資料庫丟失恢復 mysql資料庫刪除庫恢復 寶塔mysql資料庫恢復資料庫MySql
- 基於MySQL資料庫討論虛擬機器資料恢復MySql資料庫虛擬機資料恢復
- 【資料庫資料恢復】Sql Server資料庫資料恢復案例資料庫資料恢復SQLServer
- PG 資料庫的 表的不完全恢復的簡易方法資料庫
- 基於GTID恢復誤篡改資料
- 【資料庫資料恢復】透過恢復NDF檔案修復資料庫的資料恢復過程資料庫資料恢復
- 7.5 使用binary log 做基於時間點的恢復
- 資料庫修復資料恢復資料庫資料恢復
- 【資料庫資料恢復】磁碟空間不足導致sql server錯誤的資料恢復資料庫資料恢復SQLServer
- BBED 修改oracle 資料檔案的 SCN 號來做資料庫不完全恢復。Oracle資料庫
- PostgreSQL從入門到精通 - 第40講:資料庫不完全恢復SQL資料庫
- DM7使用DMRMAN執行資料庫還原和恢復資料庫
- 聊聊基於docker部署的mysql如何進行資料恢復DockerMySql資料恢復
- 【資料庫資料恢復】如何恢復Oracle資料庫truncate表的資料資料庫資料恢復Oracle
- 【資料庫資料恢復】windows server下SqlServer資料庫的資料恢復資料庫資料恢復WindowsServerSQL
- DM7使用DMRMAN恢復資料庫到指定時間點/LSN資料庫
- 【資料庫資料恢復】誤truncate table的Oracle資料庫資料恢復方案資料庫資料恢復Oracle
- 【資料庫資料恢復】oracle資料庫誤truncate table怎麼恢復資料?資料庫資料恢復Oracle
- 【資料庫資料恢復】linux系統下MYSQL資料庫資料恢復案例資料庫資料恢復LinuxMySql
- 【資料庫資料恢復】Oracle資料庫誤truncate table的資料恢復案例資料庫資料恢復Oracle
- 伺服器資料恢復—透過拼接資料庫碎片恢復SqlServer資料庫資料的資料恢復案例伺服器資料恢復資料庫SQLServer
- Oracle 不完全恢復Oracle
- 【資料庫資料恢復】MS SQL資料庫附加資料庫出錯怎麼恢復資料?資料庫資料恢復SQL
- sybase資料庫恢復資料庫
- Sybase ASE資料庫恢復,Sybase資料恢復,資料誤刪除恢復工具READSYBDEVICE資料庫資料恢復dev