目录
Oracle Study之--基于ASM的TSPITR(基于表空间的完全恢复)
Understanding RMAN TSPITR
RMAN TSPITR Concepts
Performing Basic RMAN TSPITR
首页 数据库 mysql教程 OracleStudy之--基于ASM的TSPITR(基于表空间的完全恢复)

OracleStudy之--基于ASM的TSPITR(基于表空间的完全恢复)

Jun 07, 2016 pm 02:55 PM
asm 基于

Oracle Study之--基于ASM的TSPITR(基于表空间的完全恢复) 系统环境: 操作系统:AIX5.3-08 数据库: Oracle 10gR2 Understanding RMAN TSPITR In order to use TSPITR effectively, you need to understand what problems it can solve for you, what the

Oracle Study之--基于ASM的TSPITR(基于表空间的完全恢复)

系统环境:

操作系统:AIX5.3-08

数据库:  Oracle 10gR2

Understanding RMAN TSPITR

In order to use TSPITR effectively, you need to understand what problems it can solve for you, what the major elements used in TSPITR are, what RMAN does during TSPITR, and limitations on when and how it can be applied.

RMAN TSPITR Concepts

Figure 8-1, "Tablespace Point-in-Time Recovery (TSPITR) Architecture" illustrates the context within which TSPITR takes place, and a general outline of the process.

Figure 8-1 Tablespace Point-in-Time Recovery (TSPITR) Architecture

wKiom1TIXrnRCEMWAAGW05m6DzE496.jpg


Description of "Figure 8-1 Tablespace Point-in-Time Recovery (TSPITR) Architecture"

The figure contains the following entities:

  • The target instance, containing the tablespace to be recovered

  • The Recovery Manager client

  • The control file and (optional) recovery catalog, used for the RMAN repository records of backup activity

  • Archived redo logs and backup sets from the target database, which are the source of the reconstructed tablespace.

  • The auxiliary instance, an Oracle database instance used in the recovery process to perform the actual work of recovery.

There are four other important terms related to TSPITR, which will be used in the rest of this discussion:

  • The target time, the point in time or SCN that the tablespace will be left at after TSPITR

  • The recovery set, which consists of the datafiles containing the tablespaces to be recovered;

  • The auxiliary set, which includes datafiles required for TSPITR of the recovery set which are not themselves part of the recovery set. The auxiliary set typically includes:

    The auxiliary instance has other files associated with it, such as a control file, parameter file, and online logs, but they are not part of the auxiliary set.

    • A copy of the SYSTEM tablespace

    • Datafiles containing rollback or undo segments from the target instance

    • In some cases, a temporary tablespace, used during the export of database objects from the auxiliary instance

  • The auxiliary destination, an optional location on disk which can be used to store any of the auxiliary set datafiles, control files and online logs of the auxiliary instance during TSPITR. Files stored here can be deleted after TSPITR is complete.

Performing Basic RMAN TSPITR

Having selected your tablespaces to recover and your target time, you are now ready to perform RMAN TSPITR. You have a few different options available to you:

  • Fully automated TSPITR--in which you specify an auxiliary destination and let RMAN manage all aspects of the TSPITR. This is the simplest way to perform TSPITR, and is recommended unless you specifically need more control over the location of recovery set files after TSPITR or auxiliary set files during TSPITR, or control over the channel configurations or some other aspect of your auxiliary instance.

  • Customized TSPITR with an automatic auxiliary instance--in which you base your TSPITR on the behavior of fully automated TSPITR, possibly still using an auxiliary destination, but customize one or more aspects of the behavior, such as the location of auxiliary set or recovery set files, or specifying initialization parameters or channel configurations for the auxiliary instance created and managed by RMAN.

  • TSPITR with your own auxiliary instance--in which you take responsibility for setting up, starting, stopping and cleaning up the auxiliary instance used in TSPITR, and possibly also manage the TSPITR process using some of the methods available in customized TSPITR with an automatic auxiliary instance.

案例分析:

    用户在过去的时间点对emp1表做了误操作,需要通过物理备份恢复到过去的数据,本案例采用基于表空间的不完全恢复来实现对表的恢复!

1、案例测试环境

SQL> show parameter name
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_file_name_convert                 string
db_name                              string      zsdb
db_unique_name                       string      zsdb
global_names                         boolean     FALSE
instance_name                        string      zsdb
lock_name_space                      string
log_file_name_convert                string
service_names                        string      zsdb
SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
+DG1/zsdb/datafile/system.257.870003801
+DG1/zsdb/datafile/undotbs1.260.870004111
+DG1/zsdb/datafile/sysaux.258.870003999
+DG1/zsdb/datafile/users.262.870004141
+DG1/zsdb/datafile/zstb.259.870004085
+DG1/zsdb/datafile/testtb.261.870004125
6 rows selected.
SQL> col member for a50
SQL> select group#,member from v$logfile;
    GROUP# MEMBER
---------- --------------------------------------------------
         4 +DG1/zsdb/onlinelog/group_4.266.870004663
         4 +RCY1/zsdb/onlinelog/group_4.256.870004669
         5 +DG1/zsdb/onlinelog/group_5.267.870004689
         5 +RCY1/zsdb/onlinelog/group_5.257.870004693
SQL> set linesize 120
SQL> r
  1* select file_id,file_name,tablespace_name from dba_data_files
   FILE_ID FILE_NAME                                          TABLESPACE_NAME
---------- -------------------------------------------------- ------------------------------
         4 +DG1/zsdb/datafile/users.262.870004141             USERS
         3 +DG1/zsdb/datafile/sysaux.258.870003999            SYSAUX
         2 +DG1/zsdb/datafile/undotbs1.260.870004111          UNDOTBS1
         1 +DG1/zsdb/datafile/system.257.870003801            SYSTEM
         5 +DG1/zsdb/datafile/zstb.259.870004085              ZSTB
         6 +DG1/zsdb/datafile/testtb.261.870004125            TESTTB
6 rows selected.
登录后复制

2、建立测试

SQL> select * from tab;
TNAME                          TABTYPE  CLUSTERID
------------------------------ ------- ----------
DEPT                           TABLE
EMP                            TABLE
BONUS                          TABLE
SALGRADE                       TABLE
TB_EMP                         TABLE
TB_DEPT                        TABLE
TB1                            TABLE
EMP1                           TABLE
8 rows selected.

SQL> select table_name,tablespace_name from user_tables;
TABLE_NAME                     TABLESPACE_NAME
------------------------------ ------------------------------
DEPT                           USERS
EMP                            USERS
BONUS                          USERS
SALGRADE                       USERS
TB_EMP                         TESTTB
TB_DEPT                        TESTTB
TB1                            USERS
EMP1                           ZSTB
8 rows selected.

10:43:58 SQL> insert into emp1 select * from emp;
14 rows created.

10:44:10 SQL> commit;
Commit complete.

10:44:12 SQL> select * from emp1;
     EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
---------- ---------- --------- ---------- --------- ---------- ---------- ----------
      9999 SMITH      CLERK           7902 17-DEC-80        800                    20
      7369 SMITH      CLERK           7902 17-DEC-80        800                    20
      7499 ALLEN      SALESMAN        7698 20-FEB-81       1600        300         30
      7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
      7566 JONES      MANAGER         7839 02-APR-81       2975                    20
      7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
      7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30
      7782 CLARK      MANAGER         7839 09-JUN-81       2450                    10
      7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20
      7839 KING       PRESIDENT            17-NOV-81       5000                    10
      7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30
     EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
---------- ---------- --------- ---------- --------- ---------- ---------- ----------
      7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20
      7900 JAMES      CLERK           7698 03-DEC-81        950                    30
      7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
      7934 MILLER     CLERK           7782 23-JAN-82       1300                    10
15 rows selected.

10:44:34 SQL> update emp1 set sal=9000 ;    
15 rows updated.

10:44:47 SQL> commit;
Commit complete.

10:44:49 SQL> select * from emp1;
     EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
---------- ---------- --------- ---------- --------- ---------- ---------- ----------
      9999 SMITH      CLERK           7902 17-DEC-80       9000                    20
      7369 SMITH      CLERK           7902 17-DEC-80       9000                    20
      7499 ALLEN      SALESMAN        7698 20-FEB-81       9000        300         30
      7521 WARD       SALESMAN        7698 22-FEB-81       9000        500         30
      7566 JONES      MANAGER         7839 02-APR-81       9000                    20
      7654 MARTIN     SALESMAN        7698 28-SEP-81       9000       1400         30
      7698 BLAKE      MANAGER         7839 01-MAY-81       9000                    30
      7782 CLARK      MANAGER         7839 09-JUN-81       9000                    10
      7788 SCOTT      ANALYST         7566 19-APR-87       9000                    20
      7839 KING       PRESIDENT            17-NOV-81       9000                    10
      7844 TURNER     SALESMAN        7698 08-SEP-81       9000          0         30
     EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
---------- ---------- --------- ---------- --------- ---------- ---------- ----------
      7876 ADAMS      CLERK           7788 23-MAY-87       9000                    20
      7900 JAMES      CLERK           7698 03-DEC-81       9000                    30
      7902 FORD       ANALYST         7566 03-DEC-81       9000                    20
      7934 MILLER     CLERK           7782 23-JAN-82       9000                    10
15 rows selected.

表被误操作前的scn:
SQL> select current_scn from v$database;
CURRENT_SCN
-----------
     988659
     
10:44:54 SQL> truncate table emp1 ;
Table truncated.

10:46:28 SQL> select * from emp1;
no rows selected

10:46:33 SQL> insert into emp1 select * from emp where rownum=1;
1 row created.

10:46:45 SQL> update emp1 set empno=9999;
1 row updated.

10:46:53 SQL> commit;
Commit complete.

10:46:56 SQL> select * from emp1;
     EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
---------- ---------- --------- ---------- --------- ---------- ---------- ----------
      9999 SMITH      CLERK           7902 17-DEC-80        800                    20
登录后复制

3、检查表空间自包含

SQL> exec DBMS_TTS.TRANSPORT_SET_CHECK('ZSTB',TRUE);
PL/SQL procedure successfully completed.
SQL> select * from TRANSPORT_SET_VIOLATIONS t;
no rows selected
登录后复制

4、通过rman做TSPITR

[10:49:12 oracle@aix217: dbs]$mkdir /home/oracle/zsdb
[10:49:23 oracle@aix217: dbs]$cd /home/oracle/zsdb
[10:49:30 oracle@aix217: zsdb]$rman target /
Recovery Manager: Release 10.2.0.1.0 - Production on Wed Jan 28 10:49:35 2015
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
connected to target database: ZSDB (DBID=3945368821)
RMAN>  recover tablespace zstb until scn 988659
2> ;
Starting recover at 28-JAN-15
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=125 devtype=DISK
RMAN-05026: WARNING: presuming following set of tablespaces applies to specified point in time
List of tablespaces expected to have UNDO segments
tablespace SYSTEM
tablespace UNDOTBS1
Creating automatic instance, with SID='pgoi'
initialization parameters used for automatic instance:
db_name=ZSDB
compatible=10.2.0.1.0
db_block_size=8192
db_files=200
db_unique_name=tspitr_ZSDB_pgoi
large_pool_size=1M
shared_pool_size=110M
#No auxiliary parameter file used
#No auxiliary destination in use
#Use default controlfile
starting up automatic instance ZSDB
Oracle instance started
Total System Global Area     205520896 bytes
Fixed Size                     2019680 bytes
Variable Size                146804384 bytes
Database Buffers              50331648 bytes
Redo Buffers                   6365184 bytes
Automatic instance created
Removing automatic instance
shutting down automatic instance 
Oracle instance shut down
Automatic instance removed
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 01/28/2015 10:50:09
RMAN-05002: aborting point-in-time tablespace recovery
RMAN-05517: temporary file +DG1/zsdb/tempfile/temp.265.870004489 conflicts with file used by target database
RMAN-05001: auxiliary filename +DG1/zsdb/datafile/undotbs1.260.870004111 conflicts with a file used by the target database
RMAN-05001: auxiliary filename +DG1/zsdb/datafile/system.257.870003801 conflicts with a file used by the target database
登录后复制

---在做TSPITR时,需要建立Auxiliary Instance,需要转储system、undotbs,应该将Auxiliary Instance的datafile与原库存储到不同的diskgroup。

5、建立ASM diskgroup

[11:05:43 root@aix217: /]#lsvg rootvg
VOLUME GROUP:       rootvg                   VG IDENTIFIER:  0000c9a20000d700000001447571be5b
VG STATE:           active                   PP SIZE:        128 megabyte(s)
VG PERMISSION:      read/write               TOTAL PPs:      546 (69888 megabytes)
MAX LVs:            256                      FREE PPs:       85 (10880 megabytes)
LVs:                14                       USED PPs:       461 (59008 megabytes)
OPEN LVs:           12                       QUORUM:         2 (Enabled)
TOTAL PVs:          1                        VG DESCRIPTORS: 2
STALE PVs:          0                        STALE PPs:      0
ACTIVE PVs:         1                        AUTO ON:        yes
MAX PPs per VG:     32512                                     
MAX PPs per PV:     1016                     MAX PVs:        32
LTG size (Dynamic): 256 kilobyte(s)          AUTO SYNC:      no
HOT SPARE:          no                       BB POLICY:      relocatable 

[11:06:27 root@aix217: /]#mklv -y 'lv_aux' -t 'raw' rootvg 30
lv_aux

[11:07:39 root@aix217: /]#ls -l /dev |grep aux
brw-rw----    1 root     system       10, 15 Jan 28 11:07 lv_aux
brw-rw----    1 oracle   dba          70,  7 Jan 14 16:26 rac_sysaux
crw-rw----    1 root     system       10, 15 Jan 28 11:07 rlv_aux
crw-rw----    1 oracle   dba          70,  7 Jan 14 16:26 rrac_sysaux

[11:07:50 root@aix217: /]#chown oracle:dba /dev/*lv_aux
[11:08:21 root@aix217: /]#chmod 660 /dev/*lv_aux
[11:08:29 root@aix217: /]#ls -l /dev |grep aux
brw-rw----    1 oracle   dba          10, 15 Jan 28 11:07 lv_aux
crw-rw----    1 oracle   dba          10, 15 Jan 28 11:07 rlv_aux

SQL> create diskgroup dg2 external redundancy
  2  disk '/dev/rlv_aux';
Diskgroup created.
SQL> select name ,state from v$asm_diskgroup;
NAME                           STATE
------------------------------ -----------
DG1                            MOUNTED
RCY1                           MOUNTED
DG2                            MOUNTED
登录后复制

6、再次做TSPITR

[11:13:58 oracle@aix217: ~]$rman target /
Recovery Manager: Release 10.2.0.1.0 - Production on Wed Jan 28 11:14:07 2015
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
RMAN-06900: WARNING: unable to generate V$RMAN_STATUS or V$RMAN_OUTPUT row
RMAN-06901: WARNING: disabling update of the V$RMAN_STATUS and V$RMAN_OUTPUT rows
ORACLE error from target database: 
ORA-29701: unable to connect to Cluster Manager
connected to target database: ZSDB (DBID=3945368821)
RMAN> RUN
2> {
3>   SET NEWNAME FOR DATAFILE 1 to '+dg2';
4>    SET NEWNAME FOR DATAFILE 2 to '+dg2';
5>   RECOVER TABLESPACE zstb until scn 988659
6>      AUXILIARY DESTINATION '+DG2';
}
7> 
executing command: SET NEWNAME
using target database control file instead of recovery catalog
executing command: SET NEWNAME
Starting recover at 28-JAN-15
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=125 devtype=DISK
RMAN-05026: WARNING: presuming following set of tablespaces applies to specified point in time
List of tablespaces expected to have UNDO segments
tablespace SYSTEM
tablespace UNDOTBS1

建立并启动辅助实例:
Creating automatic instance, with SID='qauC'
initialization parameters used for automatic instance:
db_name=ZSDB
compatible=10.2.0.1.0
db_block_size=8192
db_files=200
db_unique_name=tspitr_ZSDB_qauC
large_pool_size=1M
shared_pool_size=110M
#No auxiliary parameter file used
db_create_file_dest=+DG2
control_files=+DG2/cntrl_tspitr_ZSDB_qauC.f


starting up automatic instance ZSDB
Oracle instance started
Total System Global Area     205520896 bytes
Fixed Size                     2019680 bytes
Variable Size                146804384 bytes
Database Buffers              50331648 bytes
Redo Buffers                   6365184 bytes
Automatic instance created
contents of Memory Script:
{
# set the until clause
set until  scn 988659;
# restore the controlfile
restore clone controlfile;
# mount the controlfile
sql clone 'alter database mount clone database';
# archive current online log for tspitr to a resent until time
sql 'alter system archive log current';
# avoid unnecessary autobackups for structural changes during TSPITR
sql 'begin dbms_backup_restore.AutoBackupFlag(FALSE); end;';
}
executing Memory Script
executing command: SET until clause
Starting restore at 28-JAN-15
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=33 devtype=DISK
channel ORA_AUX_DISK_1: starting datafile backupset restore
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: reading from backup piece /backup/backupctl_ZSDB_ncptrifa_1_1.ctl
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/backup/backupctl_ZSDB_ncptrifa_1_1.ctl tag=BKCTL
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:38
output filename=+DG2/cntrl_tspitr_zsdb_qauc.f
Finished restore at 28-JAN-15
sql statement: alter database mount clone database
sql statement: alter system archive log current
sql statement: begin dbms_backup_restore.AutoBackupFlag(FALSE); end;
released channel: ORA_DISK_1
released channel: ORA_AUX_DISK_1
contents of Memory Script:
{
# generated tablespace point-in-time recovery script
# set the until clause
set until  scn 988659;
plsql <<<-- tspitr_2
declare
  sqlstatement       varchar2(512);
  offline_not_needed exception;
  pragma exception_init(offline_not_needed, -01539);
begin
  sqlstatement := 'alter tablespace '||  'ZSTB' ||' offline for recover';
  krmicd.writeMsg(6162, sqlstatement);
  krmicd.execSql(sqlstatement);
exception
  when offline_not_needed then
    null;
end; >>>;
# set a destination filename for restore
set newname for datafile  1 to 
 "+DG2";
# set a destination filename for restore
set newname for datafile  2 to 
 "+DG2";
# set an omf destination tempfile
set newname for clone tempfile  2 to new;
# set a destination filename for restore
set newname for datafile  5 to 
 "+DG1/zsdb/datafile/zstb.259.870004085";
# rename all tempfiles
switch clone tempfile all;
# restore the tablespaces in the recovery set plus the auxilliary tablespaces
restore clone datafile  1, 2, 5;
switch clone datafile all;
#online the datafiles restored or flipped
sql clone "alter database datafile  1 online";
#online the datafiles restored or flipped
sql clone "alter database datafile  2 online";
#online the datafiles restored or flipped
sql clone "alter database datafile  5 online";
# make the controlfile point at the restored datafiles, then recover them
recover clone database tablespace  "ZSTB", "SYSTEM", "UNDOTBS1" delete archivelog;
alter clone database open resetlogs;
# PLUG HERE the creation of a temporary tablespace if export fails due to lack
# of temporary space.
# For example in Unix these two lines would do that:
#sql clone "create tablespace aux_tspitr_tmp
#           datafile ''/tmp/aux_tspitr_tmp.dbf'' size 500K";
}
executing Memory Script
executing command: SET until clause
sql statement: alter tablespace ZSTB offline for recover
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
renamed temporary file 2 to +DG2 in control file
Starting restore at 28-JAN-15
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=36 devtype=DISK
channel ORA_AUX_DISK_1: starting datafile backupset restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00002 to +DG2
restoring datafile 00005 to +DG1/zsdb/datafile/zstb.259.870004085
channel ORA_AUX_DISK_1: reading from backup piece /backup/inc0_ZSDB_mbptna6f_1_1
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/backup/inc0_ZSDB_maptna6d_1_1 tag=INC0
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:01:05
Finished restore at 28-JAN-15
datafile 1 switched to datafile copy
input datafile copy recid=48 stamp=870175071 filename=+DG2/tspitr_zsdb_qauc/datafile/system.258.870175007
datafile 2 switched to datafile copy
input datafile copy recid=49 stamp=870175071 filename=+DG2/tspitr_zsdb_qauc/datafile/undotbs1.257.870174973
sql statement: alter database datafile  1 online
sql statement: alter database datafile  2 online
sql statement: alter database datafile  5 online
Starting recover at 28-JAN-15
using channel ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: starting incremental datafile backupset restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
destination for restore of datafile 00001: +DG2/tspitr_zsdb_qauc/datafile/system.258.870175007
channel ORA_AUX_DISK_1: reading from backup piece /backup/inc1_ZSDB_mhptnb2j_1_1
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/backup/inc1_ZSDB_mhptnb2j_1_1 tag=INC1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
channel ORA_AUX_DISK_1: starting incremental datafile backupset restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
destination for restore of datafile 00005: +DG1/zsdb/datafile/zstb.259.870004085
destination for restore of datafile 00002: +DG2/tspitr_zsdb_qauc/datafile/undotbs1.257.870174973
channel ORA_AUX_DISK_1: reading from backup piece /backup/inc1_ZSDB_miptnb2l_1_1
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/backup/inc1_ZSDB_miptnb2l_1_1 tag=INC1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:02
channel ORA_AUX_DISK_1: starting incremental datafile backupset restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
destination for restore of datafile 00001: +DG2/tspitr_zsdb_qauc/datafile/system.258.870175007
channel ORA_AUX_DISK_1: reading from backup piece /backup/inc1_ZSDB_moptnbuk_1_1
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/backup/inc1_ZSDB_moptnbuk_1_1 tag=INC1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
channel ORA_AUX_DISK_1: starting incremental datafile backupset restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
destination for restore of datafile 00005: +DG1/zsdb/datafile/zstb.259.870004085
destination for restore of datafile 00002: +DG2/tspitr_zsdb_qauc/datafile/undotbs1.257.870174973
channel ORA_AUX_DISK_1: reading from backup piece /backup/inc1_ZSDB_mpptnbum_1_1
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/backup/inc1_ZSDB_mpptnbum_1_1 tag=INC1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:02
channel ORA_AUX_DISK_1: starting incremental datafile backupset restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
destination for restore of datafile 00001: +DG2/tspitr_zsdb_qauc/datafile/system.258.870175007
channel ORA_AUX_DISK_1: reading from backup piece /backup/inc1_ZSDB_mvptncqp_1_1
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/backup/inc1_ZSDB_mvptncqp_1_1 tag=INC1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:02
channel ORA_AUX_DISK_1: starting incremental datafile backupset restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
destination for restore of datafile 00005: +DG1/zsdb/datafile/zstb.259.870004085
destination for restore of datafile 00002: +DG2/tspitr_zsdb_qauc/datafile/undotbs1.257.870174973
channel ORA_AUX_DISK_1: reading from backup piece /backup/inc1_ZSDB_n0ptncqr_1_1
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/backup/inc1_ZSDB_n0ptncqr_1_1 tag=INC1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:02
channel ORA_AUX_DISK_1: starting incremental datafile backupset restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
destination for restore of datafile 00001: +DG2/tspitr_zsdb_qauc/datafile/system.258.870175007
channel ORA_AUX_DISK_1: reading from backup piece /backup/inc1_ZSDB_n6ptridv_1_1
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/backup/inc1_ZSDB_n6ptridv_1_1 tag=INC1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:02
channel ORA_AUX_DISK_1: starting incremental datafile backupset restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
destination for restore of datafile 00005: +DG1/zsdb/datafile/zstb.259.870004085
destination for restore of datafile 00002: +DG2/tspitr_zsdb_qauc/datafile/undotbs1.257.870174973
channel ORA_AUX_DISK_1: reading from backup piece /backup/inc1_ZSDB_n7ptrie1_1_1
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/backup/inc1_ZSDB_n7ptrie1_1_1 tag=INC1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
starting media recovery
channel ORA_AUX_DISK_1: starting archive log restore to default destination
channel ORA_AUX_DISK_1: restoring archive log
archive log thread=1 sequence=181
channel ORA_AUX_DISK_1: reading from backup piece /backup/arch_ZSDB_nbptriev_1_1
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/backup/arch_ZSDB_nbptriev_1_1 tag=BACKCH
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
archive log filename=/u01/app/oracle/product/10.2.0/db_1/dbs/arch1_181_869671369.dbf thread=1 sequence=181
channel clone_default: deleting archive log(s)
archive log filename=/u01/app/oracle/product/10.2.0/db_1/dbs/arch1_181_869671369.dbf recid=568 stamp=870175096
channel ORA_AUX_DISK_1: starting archive log restore to default destination
channel ORA_AUX_DISK_1: restoring archive log
archive log thread=1 sequence=182
channel ORA_AUX_DISK_1: reading from backup piece /backup/arch_ZSDB_nhptrjca_1_1
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/backup/arch_ZSDB_nhptrjca_1_1 tag=BACKCH
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:04
archive log filename=/u01/app/oracle/product/10.2.0/db_1/dbs/arch1_182_869671369.dbf thread=1 sequence=182
channel clone_default: deleting archive log(s)
archive log filename=/u01/app/oracle/product/10.2.0/db_1/dbs/arch1_182_869671369.dbf recid=569 stamp=870175100
media recovery complete, elapsed time: 00:00:02
Finished recover at 28-JAN-15
database opened
contents of Memory Script:
{
# export the tablespaces in the recovery set
host 'exp userid =\"/@\(DESCRIPTION=\(ADDRESS=\(PROTOCOL=beq\)\(PROGRAM=/u01/app/oracle/product/10.2.0/db_1/bin/oracle\)\(ARGV0=oracleqauC\)\(ARGS=^'\(DESCRIPTION=\(LOCAL=YES\)\(ADDRESS=\(PROTOCOL=beq\)\)\)^'\)\(ENVS=^'ORACLE_SID=qauC^'\)\)\(CONNECT_DATA=\(SID=qauC\)\)\) as sysdba\" point_in_time_recover=y tablespaces=
 ZSTB file=
tspitr_a.dmp';
# shutdown clone before import
shutdown clone immediate
# import the tablespaces in the recovery set
host 'imp userid =\"/@ as sysdba\" point_in_time_recover=y file=
tspitr_a.dmp';
# online/offline the tablespace imported
sql "alter tablespace  ZSTB online";
sql "alter tablespace  ZSTB offline";
# enable autobackups in case user does open resetlogs from RMAN after TSPITR
sql 'begin dbms_backup_restore.AutoBackupFlag(TRUE); end;';
}
executing Memory Script

从Auxiliary Instance导出恢复后的数据:
Export: Release 10.2.0.1.0 - Production on Wed Jan 28 11:18:41 2015
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP and Data Mining options
Export done in US7ASCII character set and AL16UTF16 NCHAR character set
server uses ZHS16GBK character set (possible charset conversion)
Note: table data (rows) will not be exported
About to export Tablespace Point-in-time Recovery objects...
For tablespace ZSTB ...
. exporting cluster definitions
. exporting table definitions
. . exporting table                           EMP1
EXP-00091: Exporting questionable statistics.
. . exporting table                           TEST
. exporting referential integrity constraints
. exporting triggers
. end point-in-time recovery
Export terminated successfully with warnings.
host command complete
database closed
database dismounted
Oracle instance shut down
Import: Release 10.2.0.1.0 - Production on Wed Jan 28 11:19:25 2015
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP and Data Mining options
Export file created by EXPORT:V10.02.01 via conventional path
About to import Tablespace Point-in-time Recovery objects...

导入恢复后的数据到主库:
import done in US7ASCII character set and AL16UTF16 NCHAR character set
import server uses ZHS16GBK character set (possible charset conversion)
. importing SYS's objects into SYS
. importing SCOTT's objects into SCOTT
. . importing table                         "EMP1"
. importing TEST's objects into TEST
. . importing table                         "TEST"
. importing SYS's objects into SYS
Import terminated successfully without warnings.
host command complete
sql statement: alter tablespace  ZSTB online
sql statement: alter tablespace  ZSTB offline
sql statement: begin dbms_backup_restore.AutoBackupFlag(TRUE); end;
Removing automatic instance
Automatic instance removed
auxiliary instance file +DG2/cntrl_tspitr_zsdb_qauc.f deleted
Removing automatic instance
Automatic instance removed
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 01/28/2015 11:19:50
ORA-15045: ASM file name '+DG2' is not in reference form
登录后复制

错误信息:
    在recovery完成后,会删除Auxiliary Instance的文件,因为文件放在ASM diskgroup下,故删除失败,可以考虑将Auxiliary Instance文件放在文件系统下。
    [11:32:21 oracle@aix217: ~]$asmcmd
ASMCMD> ls
DG1/
DG2/
RCY1/
ASMCMD> cd dg2
ASMCMD> ls
TSPITR_ZSDB_QAUC/
ASMCMD> cd TSPITR_ZSDB_QAUC/
ASMCMD> ls
DATAFILE/
ONLINELOG/
TEMPFILE/
ASMCMD>

恢复脚本:        
RUN
 {
   SET NEWNAME FOR DATAFILE 1 to '+dg2';
   SET NEWNAME FOR DATAFILE 2 to '+dg2';
   RECOVER TABLESPACE zstb until scn 988659
   AUXILIARY DESTINATION '/home/oracle/zsdb';
}
登录后复制


7、验证数据恢复

SQL> conn scott/tiger
Connected.
SQL> select * from emp1;
select * from emp1
              *
ERROR at line 1:
ORA-00376: file 5 cannot be read at this time
ORA-01110: data file 5: '+DG1/zsdb/datafile/zstb.259.870004085'
SQL> conn /as sysdba
Connected.
SQL> alter database datafile 5&
登录后复制
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

Video Face Swap

Video Face Swap

使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

<🎜>:泡泡胶模拟器无穷大 - 如何获取和使用皇家钥匙
4 周前 By 尊渡假赌尊渡假赌尊渡假赌
北端:融合系统,解释
4 周前 By 尊渡假赌尊渡假赌尊渡假赌
Mandragora:巫婆树的耳语 - 如何解锁抓钩
3 周前 By 尊渡假赌尊渡假赌尊渡假赌

热工具

记事本++7.3.1

记事本++7.3.1

好用且免费的代码编辑器

SublimeText3汉化版

SublimeText3汉化版

中文版,非常好用

禅工作室 13.0.1

禅工作室 13.0.1

功能强大的PHP集成开发环境

Dreamweaver CS6

Dreamweaver CS6

视觉化网页开发工具

SublimeText3 Mac版

SublimeText3 Mac版

神级代码编辑软件(SublimeText3)

热门话题

Java教程
1674
14
CakePHP 教程
1429
52
Laravel 教程
1333
25
PHP教程
1278
29
C# 教程
1257
24
MySQL的角色:Web应用程序中的数据库 MySQL的角色:Web应用程序中的数据库 Apr 17, 2025 am 12:23 AM

MySQL在Web应用中的主要作用是存储和管理数据。1.MySQL高效处理用户信息、产品目录和交易记录等数据。2.通过SQL查询,开发者能从数据库提取信息生成动态内容。3.MySQL基于客户端-服务器模型工作,确保查询速度可接受。

说明InnoDB重做日志和撤消日志的作用。 说明InnoDB重做日志和撤消日志的作用。 Apr 15, 2025 am 12:16 AM

InnoDB使用redologs和undologs确保数据一致性和可靠性。1.redologs记录数据页修改,确保崩溃恢复和事务持久性。2.undologs记录数据原始值,支持事务回滚和MVCC。

MySQL与其他编程语言:一种比较 MySQL与其他编程语言:一种比较 Apr 19, 2025 am 12:22 AM

MySQL与其他编程语言相比,主要用于存储和管理数据,而其他语言如Python、Java、C 则用于逻辑处理和应用开发。 MySQL以其高性能、可扩展性和跨平台支持着称,适合数据管理需求,而其他语言在各自领域如数据分析、企业应用和系统编程中各有优势。

初学者的MySQL:开始数据库管理 初学者的MySQL:开始数据库管理 Apr 18, 2025 am 12:10 AM

MySQL的基本操作包括创建数据库、表格,及使用SQL进行数据的CRUD操作。1.创建数据库:CREATEDATABASEmy_first_db;2.创建表格:CREATETABLEbooks(idINTAUTO_INCREMENTPRIMARYKEY,titleVARCHAR(100)NOTNULL,authorVARCHAR(100)NOTNULL,published_yearINT);3.插入数据:INSERTINTObooks(title,author,published_year)VA

MySQL与其他数据库:比较选项 MySQL与其他数据库:比较选项 Apr 15, 2025 am 12:08 AM

MySQL适合Web应用和内容管理系统,因其开源、高性能和易用性而受欢迎。1)与PostgreSQL相比,MySQL在简单查询和高并发读操作上表现更好。2)相较Oracle,MySQL因开源和低成本更受中小企业青睐。3)对比MicrosoftSQLServer,MySQL更适合跨平台应用。4)与MongoDB不同,MySQL更适用于结构化数据和事务处理。

解释InnoDB缓冲池及其对性能的重要性。 解释InnoDB缓冲池及其对性能的重要性。 Apr 19, 2025 am 12:24 AM

InnoDBBufferPool通过缓存数据和索引页来减少磁盘I/O,提升数据库性能。其工作原理包括:1.数据读取:从BufferPool中读取数据;2.数据写入:修改数据后写入BufferPool并定期刷新到磁盘;3.缓存管理:使用LRU算法管理缓存页;4.预读机制:提前加载相邻数据页。通过调整BufferPool大小和使用多个实例,可以优化数据库性能。

MySQL:结构化数据和关系数据库 MySQL:结构化数据和关系数据库 Apr 18, 2025 am 12:22 AM

MySQL通过表结构和SQL查询高效管理结构化数据,并通过外键实现表间关系。1.创建表时定义数据格式和类型。2.使用外键建立表间关系。3.通过索引和查询优化提高性能。4.定期备份和监控数据库确保数据安全和性能优化。

学习MySQL:新用户的分步指南 学习MySQL:新用户的分步指南 Apr 19, 2025 am 12:19 AM

MySQL值得学习,因为它是强大的开源数据库管理系统,适用于数据存储、管理和分析。1)MySQL是关系型数据库,使用SQL操作数据,适合结构化数据管理。2)SQL语言是与MySQL交互的关键,支持CRUD操作。3)MySQL的工作原理包括客户端/服务器架构、存储引擎和查询优化器。4)基本用法包括创建数据库和表,高级用法涉及使用JOIN连接表。5)常见错误包括语法错误和权限问题,调试技巧包括检查语法和使用EXPLAIN命令。6)性能优化涉及使用索引、优化SQL语句和定期维护数据库。

See all articles