0

0

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

php中文网

php中文网

发布时间:2016-06-07 14:55:51

|

1498人浏览过

|

来源于php中文网

原创

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

      高端时尚购物网店
      高端时尚购物网店

      1、系统基于网上流行被广泛使用的商城平台延续开发,集百家之所长,技术领先、功能完备;不需要懂技术,只要会打字3分钟即可以建立一个功能完备的网上商城; 2、安装方便:只需传到您的虚拟空间即可; 3、界面由专业设计师设计,时尚简约,采用人性化的布局,是一套纯专业高端网上购物平台。应用本系统更能有效地提高产品档次,树立网店及商品品牌! 4、全面优化代码提供系统的执行效率,并且针对搜索引擎做了代码优化,使

      下载
  • 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&

热门AI工具

更多
DeepSeek
DeepSeek

幻方量化公司旗下的开源大模型平台

豆包大模型
豆包大模型

字节跳动自主研发的一系列大型语言模型

通义千问
通义千问

阿里巴巴推出的全能AI助手

腾讯元宝
腾讯元宝

腾讯混元平台推出的AI助手

文心一言
文心一言

文心一言是百度开发的AI聊天机器人,通过对话可以生成各种形式的内容。

讯飞写作
讯飞写作

基于讯飞星火大模型的AI写作工具,可以快速生成新闻稿件、品宣文案、工作总结、心得体会等各种文文稿

即梦AI
即梦AI

一站式AI创作平台,免费AI图片和视频生成。

ChatGPT
ChatGPT

最最强大的AI聊天机器人程序,ChatGPT不单是聊天机器人,还能进行撰写邮件、视频脚本、文案、翻译、代码等任务。

相关专题

更多
JavaScript浏览器渲染机制与前端性能优化实践
JavaScript浏览器渲染机制与前端性能优化实践

本专题围绕 JavaScript 在浏览器中的执行与渲染机制展开,系统讲解 DOM 构建、CSSOM 解析、重排与重绘原理,以及关键渲染路径优化方法。内容涵盖事件循环机制、异步任务调度、资源加载优化、代码拆分与懒加载等性能优化策略。通过真实前端项目案例,帮助开发者理解浏览器底层工作原理,并掌握提升网页加载速度与交互体验的实用技巧。

1

2026.03.06

Rust内存安全机制与所有权模型深度实践
Rust内存安全机制与所有权模型深度实践

本专题围绕 Rust 语言核心特性展开,深入讲解所有权机制、借用规则、生命周期管理以及智能指针等关键概念。通过系统级开发案例,分析内存安全保障原理与零成本抽象优势,并结合并发场景讲解 Send 与 Sync 特性实现机制。帮助开发者真正理解 Rust 的设计哲学,掌握在高性能与安全性并重场景中的工程实践能力。

21

2026.03.05

PHP高性能API设计与Laravel服务架构实践
PHP高性能API设计与Laravel服务架构实践

本专题围绕 PHP 在现代 Web 后端开发中的高性能实践展开,重点讲解基于 Laravel 框架构建可扩展 API 服务的核心方法。内容涵盖路由与中间件机制、服务容器与依赖注入、接口版本管理、缓存策略设计以及队列异步处理方案。同时结合高并发场景,深入分析性能瓶颈定位与优化思路,帮助开发者构建稳定、高效、易维护的 PHP 后端服务体系。

106

2026.03.04

AI安装教程大全
AI安装教程大全

2026最全AI工具安装教程专题:包含各版本AI绘图、AI视频、智能办公软件的本地化部署手册。全篇零基础友好,附带最新模型下载地址、一键安装脚本及常见报错修复方案。每日更新,收藏这一篇就够了,让AI安装不再报错!

50

2026.03.04

Swift iOS架构设计与MVVM模式实战
Swift iOS架构设计与MVVM模式实战

本专题聚焦 Swift 在 iOS 应用架构设计中的实践,系统讲解 MVVM 模式的核心思想、数据绑定机制、模块拆分策略以及组件化开发方法。内容涵盖网络层封装、状态管理、依赖注入与性能优化技巧。通过完整项目案例,帮助开发者构建结构清晰、可维护性强的 iOS 应用架构体系。

87

2026.03.03

C++高性能网络编程与Reactor模型实践
C++高性能网络编程与Reactor模型实践

本专题围绕 C++ 在高性能网络服务开发中的应用展开,深入讲解 Socket 编程、多路复用机制、Reactor 模型设计原理以及线程池协作策略。内容涵盖 epoll 实现机制、内存管理优化、连接管理策略与高并发场景下的性能调优方法。通过构建高并发网络服务器实战案例,帮助开发者掌握 C++ 在底层系统与网络通信领域的核心技术。

27

2026.03.03

Golang 测试体系与代码质量保障:工程级可靠性建设
Golang 测试体系与代码质量保障:工程级可靠性建设

Go语言测试体系与代码质量保障聚焦于构建工程级可靠性系统。本专题深入解析Go的测试工具链(如go test)、单元测试、集成测试及端到端测试实践,结合代码覆盖率分析、静态代码扫描(如go vet)和动态分析工具,建立全链路质量监控机制。通过自动化测试框架、持续集成(CI)流水线配置及代码审查规范,实现测试用例管理、缺陷追踪与质量门禁控制,确保代码健壮性与可维护性,为高可靠性工程系统提供质量保障。

79

2026.02.28

Golang 工程化架构设计:可维护与可演进系统构建
Golang 工程化架构设计:可维护与可演进系统构建

Go语言工程化架构设计专注于构建高可维护性、可演进的企业级系统。本专题深入探讨Go项目的目录结构设计、模块划分、依赖管理等核心架构原则,涵盖微服务架构、领域驱动设计(DDD)在Go中的实践应用。通过实战案例解析接口抽象、错误处理、配置管理、日志监控等关键工程化技术,帮助开发者掌握构建稳定、可扩展Go应用的最佳实践方法。

61

2026.02.28

Golang 性能分析与运行时机制:构建高性能程序
Golang 性能分析与运行时机制:构建高性能程序

Go语言以其高效的并发模型和优异的性能表现广泛应用于高并发、高性能场景。其运行时机制包括 Goroutine 调度、内存管理、垃圾回收等方面,深入理解这些机制有助于编写更高效稳定的程序。本专题将系统讲解 Golang 的性能分析工具使用、常见性能瓶颈定位及优化策略,并结合实际案例剖析 Go 程序的运行时行为,帮助开发者掌握构建高性能应用的关键技能。

50

2026.02.28

热门下载

更多
网站特效
/
网站源码
/
网站素材
/
前端模板

精品课程

更多
相关推荐
/
热门推荐
/
最新课程
CSS3 教程
CSS3 教程

共18课时 | 6.7万人学习

Rust 教程
Rust 教程

共28课时 | 6.6万人学习

Django 教程
Django 教程

共28课时 | 4.8万人学习

关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号