RMAN恢復單個表空間或被DROP/DELETE/TRUNCATE的表
1、初始化資料
JZH@jzh>create table t as select * from dba_objects;
Table created.
JZH@jzh>select count(*) from t;
COUNT(*)
----------
74756
JZH@jzh>select bytes/1024/1024 from dba_segments where segment_name='T';
BYTES/1024/1024
---------------
9
2、備份資料庫
[oracle@jzh5 oradata]$ rman target /
Recovery Manager: Release 11.2.0.3.0 - Production on Mon Dec 5 08:25:42 2016
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: JZH (DBID=249975939)
RMAN> run{
2> allocate channel d1 type disk;
3> allocate channel d2 type disk;
4> crosscheck archivelog all;
5> delete noprompt expired archivelog all;
6> backup as compressed backupset database format '/home/oracle/backup20161205/full_%d_%T_%s.bak';
7> sql 'alter system archive log current';
8> backup as compressed backupset filesperset 2 format '//home/oracle/backup20161205/arch_%d_%T_%s.bak' archivelog all;
9> backup current controlfile format '/home/oracle/backup20161205/ctl_%d_%T_%s.bak';
10> release channel d1;
11> release channel d2;
12> }
3、資料庫啟到nomount狀態
SYS@jzh>shu immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SYS@jzh>startup nomount
ORACLE instance started.
Total System Global Area 835104768 bytes
Fixed Size 2232960 bytes
Variable Size 482348416 bytes
Database Buffers 348127232 bytes
Redo Buffers 2396160 bytes
RMAN> restore controlfile from '/home/oracle/backup20161205/ctl_JZH_20161205_20.bak';
Starting restore at 05-DEC-16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=19 device type=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/u01/app/oracle/oradata/jzh/control01.ctl
output file name=/u01/app/oracle/fast_recovery_area/jzh/control02.ctl
Finished restore at 05-DEC-16
RMAN> sql "alter database mount clone database";
sql statement: alter database mount clone database
released channel: ORA_DISK_1
4、還原資料庫
RMAN> run {
2> allocate channel d1 type disk;
3> allocate channel d2 type disk;
4> set newname for datafile 1 to '/u01/app/oracle/oradata/jzh/system01.dbf';
5> set newname for datafile 2 to '/u01/app/oracle/oradata/jzh/sysaux01.dbf';
6> set newname for datafile 3 to '/u01/app/oracle/oradata/jzh/undotbs01.dbf';
7> set newname for datafile 4 to '/u01/app/oracle/oradata/jzh/users01.dbf';
8> restore tablespace system,undotbs1,sysaux,users;
9> sql"alter database datafile 5 offline drop";
10> switch datafile all;
11> sql"alter database datafile 1,2,3,4 online";
12> recover database skip forever tablespace example,temp;
13> release channel d1;
14> release channel d2;
15> }
allocated channel: d1
channel d1: SID=19 device type=DISK
allocated channel: d2
channel d2: SID=20 device type=DISK
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting restore at 05-DEC-16
channel d1: starting datafile backup set restore
channel d1: specifying datafile(s) to restore from backup set
channel d1: restoring datafile 00002 to /u01/app/oracle/oradata/jzh/sysaux01.dbf
channel d1: restoring datafile 00004 to /u01/app/oracle/oradata/jzh/users01.dbf
channel d1: reading from backup piece /home/oracle/backup20161205/full_JZH_20161205_22.bak
channel d2: starting datafile backup set restore
channel d2: specifying datafile(s) to restore from backup set
channel d2: restoring datafile 00001 to /u01/app/oracle/oradata/jzh/system01.dbf
channel d2: restoring datafile 00003 to /u01/app/oracle/oradata/jzh/undotbs01.dbf
channel d2: reading from backup piece /home/oracle/backup20161205/full_JZH_20161205_21.bak
channel d1: piece handle=/home/oracle/backup20161205/full_JZH_20161205_22.bak tag=TAG20161205T092012
channel d1: restored backup piece 1
channel d1: restore complete, elapsed time: 00:00:45
channel d2: piece handle=/home/oracle/backup20161205/full_JZH_20161205_21.bak tag=TAG20161205T092012
channel d2: restored backup piece 1
channel d2: restore complete, elapsed time: 00:01:05
Finished restore at 05-DEC-16
sql statement: alter database datafile 5 offline drop
sql statement: alter database datafile 1,2,3,4 online
Starting recover at 05-DEC-16
Executing: alter database datafile 5 offline drop
starting media recovery
archived log for thread 1 with sequence 169 is already on disk as file /u01/app/arch/1_169_891180422.dbf
archived log for thread 1 with sequence 170 is already on disk as file /u01/app/arch/1_170_891180422.dbf
archived log file name=/u01/app/arch/1_169_891180422.dbf thread=1 sequence=169
archived log file name=/u01/app/arch/1_170_891180422.dbf thread=1 sequence=170
RMAN-08187: WARNING: media recovery until SCN 1622249 complete
archived log file name=/u01/app/arch/1_170_891180422.dbf thread=1 sequence=171
released channel: d1
released channel: d2
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 12/05/2016 09:24:46
ORA-00283: recovery session canceled due to errors
RMAN-11003: failure during parse/execution of SQL statement: alter database recover logfile '/u01/app/arch/1_170_891180422.dbf'
ORA-00283: recovery session canceled due to errors
ORA-01112: media recovery not started
RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 171 and starting SCN of 1622249
5、重建控制檔案
SYS@jzh>alter database backup controlfile to trace as '/tmp/controlfile.sql';
Database altered.
SYS@jzh>shu immediate
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
SYS@jzh>startup nomount
ORACLE instance started.
Total System Global Area 835104768 bytes
Fixed Size 2232960 bytes
Variable Size 482348416 bytes
Database Buffers 348127232 bytes
Redo Buffers 2396160 bytes
SYS@jzh>CREATE CONTROLFILE REUSE DATABASE "JZH" RESETLOGS NOARCHIVELOG
2 MAXLOGFILES 16
3 MAXLOGMEMBERS 3
4 MAXDATAFILES 100
5 MAXINSTANCES 8
6 MAXLOGHISTORY 292
7 LOGFILE
8 GROUP 1 '/u01/app/oracle/oradata/jzh/redo01.log' SIZE 50M BLOCKSIZE 512,
9 GROUP 2 '/u01/app/oracle/oradata/jzh/redo02.log' SIZE 50M BLOCKSIZE 512,
10 GROUP 3 '/u01/app/oracle/oradata/jzh/redo03.log' SIZE 50M BLOCKSIZE 512
11 DATAFILE
12 '/u01/app/oracle/oradata/jzh/system01.dbf',
13 '/u01/app/oracle/oradata/jzh/sysaux01.dbf',
14 '/u01/app/oracle/oradata/jzh/undotbs01.dbf',
15 '/u01/app/oracle/oradata/jzh/users01.dbf'
16 CHARACTER SET AL32UTF8
17 ;
Control file created.
SYS@jzh>alter database open resetlogs;
Database altered.
SYS@jzh>select file#,name from v$dbfile;
FILE# NAME
---------- ------------------------------------------------------------
4 /u01/app/oracle/oradata/jzh/users01.dbf
3 /u01/app/oracle/oradata/jzh/undotbs01.dbf
2 /u01/app/oracle/oradata/jzh/sysaux01.dbf
1 /u01/app/oracle/oradata/jzh/system01.dbf
5 /u01/app/oracle/product/11.2.0/db_1/dbs/MISSING00005
6、驗證
[oracle@jzh5 ~]$ ls /u01/app/oracle/oradata/jzh
control01.ctl redo01.log redo02.log redo03.log sysaux01.dbf system01.dbf undotbs01.dbf users01.dbf------------example資料庫沒有還原出來
JZH@jzh>select count(*) from t;
COUNT(*)
----------
74756
JZH@jzh>select bytes/1024/1024 from dba_segments where segment_name='T';
BYTES/1024/1024
---------------
9
JZH@jzh>create table t as select * from dba_objects;
Table created.
JZH@jzh>select count(*) from t;
COUNT(*)
----------
74756
JZH@jzh>select bytes/1024/1024 from dba_segments where segment_name='T';
BYTES/1024/1024
---------------
9
2、備份資料庫
[oracle@jzh5 oradata]$ rman target /
Recovery Manager: Release 11.2.0.3.0 - Production on Mon Dec 5 08:25:42 2016
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: JZH (DBID=249975939)
RMAN> run{
2> allocate channel d1 type disk;
3> allocate channel d2 type disk;
4> crosscheck archivelog all;
5> delete noprompt expired archivelog all;
6> backup as compressed backupset database format '/home/oracle/backup20161205/full_%d_%T_%s.bak';
7> sql 'alter system archive log current';
8> backup as compressed backupset filesperset 2 format '//home/oracle/backup20161205/arch_%d_%T_%s.bak' archivelog all;
9> backup current controlfile format '/home/oracle/backup20161205/ctl_%d_%T_%s.bak';
10> release channel d1;
11> release channel d2;
12> }
3、資料庫啟到nomount狀態
SYS@jzh>shu immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SYS@jzh>startup nomount
ORACLE instance started.
Total System Global Area 835104768 bytes
Fixed Size 2232960 bytes
Variable Size 482348416 bytes
Database Buffers 348127232 bytes
Redo Buffers 2396160 bytes
RMAN> restore controlfile from '/home/oracle/backup20161205/ctl_JZH_20161205_20.bak';
Starting restore at 05-DEC-16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=19 device type=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/u01/app/oracle/oradata/jzh/control01.ctl
output file name=/u01/app/oracle/fast_recovery_area/jzh/control02.ctl
Finished restore at 05-DEC-16
RMAN> sql "alter database mount clone database";
sql statement: alter database mount clone database
released channel: ORA_DISK_1
4、還原資料庫
RMAN> run {
2> allocate channel d1 type disk;
3> allocate channel d2 type disk;
4> set newname for datafile 1 to '/u01/app/oracle/oradata/jzh/system01.dbf';
5> set newname for datafile 2 to '/u01/app/oracle/oradata/jzh/sysaux01.dbf';
6> set newname for datafile 3 to '/u01/app/oracle/oradata/jzh/undotbs01.dbf';
7> set newname for datafile 4 to '/u01/app/oracle/oradata/jzh/users01.dbf';
8> restore tablespace system,undotbs1,sysaux,users;
9> sql"alter database datafile 5 offline drop";
10> switch datafile all;
11> sql"alter database datafile 1,2,3,4 online";
12> recover database skip forever tablespace example,temp;
13> release channel d1;
14> release channel d2;
15> }
allocated channel: d1
channel d1: SID=19 device type=DISK
allocated channel: d2
channel d2: SID=20 device type=DISK
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting restore at 05-DEC-16
channel d1: starting datafile backup set restore
channel d1: specifying datafile(s) to restore from backup set
channel d1: restoring datafile 00002 to /u01/app/oracle/oradata/jzh/sysaux01.dbf
channel d1: restoring datafile 00004 to /u01/app/oracle/oradata/jzh/users01.dbf
channel d1: reading from backup piece /home/oracle/backup20161205/full_JZH_20161205_22.bak
channel d2: starting datafile backup set restore
channel d2: specifying datafile(s) to restore from backup set
channel d2: restoring datafile 00001 to /u01/app/oracle/oradata/jzh/system01.dbf
channel d2: restoring datafile 00003 to /u01/app/oracle/oradata/jzh/undotbs01.dbf
channel d2: reading from backup piece /home/oracle/backup20161205/full_JZH_20161205_21.bak
channel d1: piece handle=/home/oracle/backup20161205/full_JZH_20161205_22.bak tag=TAG20161205T092012
channel d1: restored backup piece 1
channel d1: restore complete, elapsed time: 00:00:45
channel d2: piece handle=/home/oracle/backup20161205/full_JZH_20161205_21.bak tag=TAG20161205T092012
channel d2: restored backup piece 1
channel d2: restore complete, elapsed time: 00:01:05
Finished restore at 05-DEC-16
sql statement: alter database datafile 5 offline drop
sql statement: alter database datafile 1,2,3,4 online
Starting recover at 05-DEC-16
Executing: alter database datafile 5 offline drop
starting media recovery
archived log for thread 1 with sequence 169 is already on disk as file /u01/app/arch/1_169_891180422.dbf
archived log for thread 1 with sequence 170 is already on disk as file /u01/app/arch/1_170_891180422.dbf
archived log file name=/u01/app/arch/1_169_891180422.dbf thread=1 sequence=169
archived log file name=/u01/app/arch/1_170_891180422.dbf thread=1 sequence=170
RMAN-08187: WARNING: media recovery until SCN 1622249 complete
archived log file name=/u01/app/arch/1_170_891180422.dbf thread=1 sequence=171
released channel: d1
released channel: d2
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 12/05/2016 09:24:46
ORA-00283: recovery session canceled due to errors
RMAN-11003: failure during parse/execution of SQL statement: alter database recover logfile '/u01/app/arch/1_170_891180422.dbf'
ORA-00283: recovery session canceled due to errors
ORA-01112: media recovery not started
RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 171 and starting SCN of 1622249
5、重建控制檔案
SYS@jzh>alter database backup controlfile to trace as '/tmp/controlfile.sql';
Database altered.
SYS@jzh>shu immediate
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
SYS@jzh>startup nomount
ORACLE instance started.
Total System Global Area 835104768 bytes
Fixed Size 2232960 bytes
Variable Size 482348416 bytes
Database Buffers 348127232 bytes
Redo Buffers 2396160 bytes
SYS@jzh>CREATE CONTROLFILE REUSE DATABASE "JZH" RESETLOGS NOARCHIVELOG
2 MAXLOGFILES 16
3 MAXLOGMEMBERS 3
4 MAXDATAFILES 100
5 MAXINSTANCES 8
6 MAXLOGHISTORY 292
7 LOGFILE
8 GROUP 1 '/u01/app/oracle/oradata/jzh/redo01.log' SIZE 50M BLOCKSIZE 512,
9 GROUP 2 '/u01/app/oracle/oradata/jzh/redo02.log' SIZE 50M BLOCKSIZE 512,
10 GROUP 3 '/u01/app/oracle/oradata/jzh/redo03.log' SIZE 50M BLOCKSIZE 512
11 DATAFILE
12 '/u01/app/oracle/oradata/jzh/system01.dbf',
13 '/u01/app/oracle/oradata/jzh/sysaux01.dbf',
14 '/u01/app/oracle/oradata/jzh/undotbs01.dbf',
15 '/u01/app/oracle/oradata/jzh/users01.dbf'
16 CHARACTER SET AL32UTF8
17 ;
Control file created.
SYS@jzh>alter database open resetlogs;
Database altered.
SYS@jzh>select file#,name from v$dbfile;
FILE# NAME
---------- ------------------------------------------------------------
4 /u01/app/oracle/oradata/jzh/users01.dbf
3 /u01/app/oracle/oradata/jzh/undotbs01.dbf
2 /u01/app/oracle/oradata/jzh/sysaux01.dbf
1 /u01/app/oracle/oradata/jzh/system01.dbf
5 /u01/app/oracle/product/11.2.0/db_1/dbs/MISSING00005
6、驗證
[oracle@jzh5 ~]$ ls /u01/app/oracle/oradata/jzh
control01.ctl redo01.log redo02.log redo03.log sysaux01.dbf system01.dbf undotbs01.dbf users01.dbf------------example資料庫沒有還原出來
JZH@jzh>select count(*) from t;
COUNT(*)
----------
74756
JZH@jzh>select bytes/1024/1024 from dba_segments where segment_name='T';
BYTES/1024/1024
---------------
9
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10271187/viewspace-2129793/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle RMAN 表空間恢復Oracle
- 【北亞資料恢復】誤操作導致雲伺服器表被truncate,表內資料被delete的資料恢復資料恢復伺服器delete
- undrop-for-innodb恢復drop的表
- 表空間TSPITR恢復-實驗
- 【Oracle 恢復表空間】 實驗Oracle
- 資料庫:drop、truncate、delete的區別資料庫delete
- SYSTEM 表空間管理及備份恢復
- (Les16 執行資料庫恢復)-表空間恢復資料庫
- Oracle drop分割槽表單個分割槽無法透過閃回恢復Oracle
- Oracle 12C新特性-RMAN恢復表Oracle
- Oracle單個資料檔案損壞,在Rman命令裡設定表空間、資料檔案offline方式來恢復最方便Oracle
- 資料庫關鍵詞 drop、truncate和delete的用法資料庫delete
- [20210527]rman與undo表空間備份.txt
- 【資料庫資料恢復】如何恢復Oracle資料庫truncate表的資料資料庫資料恢復Oracle
- 從全備中恢復單庫或單表,小心有坑!
- mysql 大表drop和truncate 技術風險點MySql
- [20190718]12c rman新特性 表恢復.txt
- 16、表空間 建立表空間
- 伺服器資料恢復—雲伺服器mysql資料庫表資料被delete的資料恢復案例伺服器資料恢復MySql資料庫delete
- MySQL 遷移表空間,備份單表MySql
- 表空間利用率及表空間的補充
- postgresql只有owner或usersuper許可權才能修改表結構或drop表SQL
- KingbaseES的表空間
- 臨時表空間被佔滿的原因查詢
- Oracle RMAN備份為什麼會大量使用temp表空間?Oracle
- RMAN增量恢復
- Oracle表空間Oracle
- oracle 表空間Oracle
- PostgreSQL 表空間SQL
- PostgreSQL:表空間SQL
- oracle 表移動表空間Oracle
- Oracle表移動表空間Oracle
- 當使用者無限制使用表空間配額且表空間有足夠空間時出現超出表空間的空間限額
- oracle表空間的整理Oracle
- Oracle 12C RMAN備份佔用大量臨時表空間Oracle
- PostgreSQL從小白到高手教程 - 第41講:postgres表空間備份與恢復SQL
- MySQL 中的共享表空間與獨立表空間如何選擇MySql
- 新建的表空間(或資料檔案)丟失以及控制檔案丟失,有新建表空間(或資料檔案)前的控制文
- 使用Xtrabackup完整備份中恢復單表