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
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&

InnoDB는 Redologs 및 Undologs를 사용하여 데이터 일관성과 신뢰성을 보장합니다. 1. Redologs는 사고 복구 및 거래 지속성을 보장하기 위해 데이터 페이지 수정을 기록합니다. 2. 결점은 원래 데이터 값을 기록하고 트랜잭션 롤백 및 MVCC를 지원합니다.

설명 명령에 대한 주요 메트릭에는 유형, 키, 행 및 추가가 포함됩니다. 1) 유형은 쿼리의 액세스 유형을 반영합니다. 값이 높을수록 Const와 같은 효율이 높아집니다. 2) 키는 사용 된 인덱스를 표시하고 NULL은 인덱스가 없음을 나타냅니다. 3) 행은 스캔 한 행의 수를 추정하여 쿼리 성능에 영향을 미칩니다. 4) Extra는 최적화해야한다는 Filesort 프롬프트 사용과 같은 추가 정보를 제공합니다.

Temporary를 사용하면 MySQL 쿼리에 임시 테이블을 생성해야 할 필요성이 있으며, 이는 별개의, 그룹 비 또는 비 인덱스 열을 사용하여 순서대로 발견됩니다. 인덱스 발생을 피하고 쿼리를 다시 작성하고 쿼리 성능을 향상시킬 수 있습니다. 구체적으로, 설명 출력에 사용되는 경우, MySQL은 쿼리를 처리하기 위해 임시 테이블을 만들어야 함을 의미합니다. 이것은 일반적으로 다음과 같은 경우에 발생합니다. 1) 별개 또는 그룹을 사용할 때 중복 제거 또는 그룹화; 2) OrderBy가 비 인덱스 열이 포함되어있을 때 정렬하십시오. 3) 복잡한 하위 쿼리 또는 조인 작업을 사용하십시오. 최적화 방법은 다음과 같습니다. 1) Orderby 및 GroupB

MySQL/InnoDB는 4 개의 트랜잭션 격리 수준을 지원합니다. Readuncommitted, ReadCommitted, ReturableRead 및 Serializable. 1. READUCMITTED는 커밋되지 않은 데이터를 읽을 수 있으므로 더러운 판독 값을 유발할 수 있습니다. 2. ReadCommitted는 더러운 읽기를 피하지만 반복 할 수없는 독서가 발생할 수 있습니다. 3. RepeatableRead는 더러운 읽기와 반복 할 수없는 독서를 피하는 기본 레벨이지만 팬텀 독서가 발생할 수 있습니다. 4. 직렬화 가능한 것은 모든 동시성 문제를 피하지만 동시성을 줄입니다. 적절한 격리 수준을 선택하려면 균형 잡힌 데이터 일관성 및 성능 요구 사항이 필요합니다.

MySQL은 웹 응용 프로그램 및 컨텐츠 관리 시스템에 적합하며 오픈 소스, 고성능 및 사용 편의성에 인기가 있습니다. 1) PostgreSQL과 비교하여 MySQL은 간단한 쿼리 및 높은 동시 읽기 작업에서 더 잘 수행합니다. 2) Oracle과 비교할 때 MySQL은 오픈 소스와 저렴한 비용으로 인해 중소 기업에서 더 인기가 있습니다. 3) Microsoft SQL Server와 비교하여 MySQL은 크로스 플랫폼 응용 프로그램에 더 적합합니다. 4) MongoDB와 달리 MySQL은 구조화 된 데이터 및 트랜잭션 처리에 더 적합합니다.

MySQL Index Cardinality는 쿼리 성능에 중대한 영향을 미칩니다. 1. 높은 카디널리티 인덱스는 데이터 범위를보다 효과적으로 좁히고 쿼리 효율성을 향상시킬 수 있습니다. 2. 낮은 카디널리티 인덱스는 전체 테이블 스캔으로 이어질 수 있으며 쿼리 성능을 줄일 수 있습니다. 3. 관절 지수에서는 쿼리를 최적화하기 위해 높은 카디널리티 시퀀스를 앞에 놓아야합니다.

MySQL 학습 경로에는 기본 지식, 핵심 개념, 사용 예제 및 최적화 기술이 포함됩니다. 1) 테이블, 행, 열 및 SQL 쿼리와 같은 기본 개념을 이해합니다. 2) MySQL의 정의, 작업 원칙 및 장점을 배우십시오. 3) 인덱스 및 저장 절차와 같은 기본 CRUD 작업 및 고급 사용량을 마스터합니다. 4) 인덱스의 합리적 사용 및 최적화 쿼리와 같은 일반적인 오류 디버깅 및 성능 최적화 제안에 익숙합니다. 이 단계를 통해 MySQL의 사용 및 최적화를 완전히 파악할 수 있습니다.

MySQL의 실제 응용 프로그램에는 기본 데이터베이스 설계 및 복잡한 쿼리 최적화가 포함됩니다. 1) 기본 사용 : 사용자 정보 삽입, 쿼리, 업데이트 및 삭제와 같은 사용자 데이터를 저장하고 관리하는 데 사용됩니다. 2) 고급 사용 : 전자 상거래 플랫폼의 주문 및 재고 관리와 같은 복잡한 비즈니스 로직을 처리합니다. 3) 성능 최적화 : 인덱스, 파티션 테이블 및 쿼리 캐시를 사용하여 합리적으로 성능을 향상시킵니다.


핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

AI Hentai Generator
AI Hentai를 무료로 생성하십시오.

인기 기사

뜨거운 도구

에디트플러스 중국어 크랙 버전
작은 크기, 구문 강조, 코드 프롬프트 기능을 지원하지 않음

VSCode Windows 64비트 다운로드
Microsoft에서 출시한 강력한 무료 IDE 편집기

MinGW - Windows용 미니멀리스트 GNU
이 프로젝트는 osdn.net/projects/mingw로 마이그레이션되는 중입니다. 계속해서 그곳에서 우리를 팔로우할 수 있습니다. MinGW: GCC(GNU Compiler Collection)의 기본 Windows 포트로, 기본 Windows 애플리케이션을 구축하기 위한 무료 배포 가능 가져오기 라이브러리 및 헤더 파일로 C99 기능을 지원하는 MSVC 런타임에 대한 확장이 포함되어 있습니다. 모든 MinGW 소프트웨어는 64비트 Windows 플랫폼에서 실행될 수 있습니다.

SublimeText3 Linux 새 버전
SublimeText3 Linux 최신 버전

DVWA
DVWA(Damn Vulnerable Web App)는 매우 취약한 PHP/MySQL 웹 애플리케이션입니다. 주요 목표는 보안 전문가가 법적 환경에서 자신의 기술과 도구를 테스트하고, 웹 개발자가 웹 응용 프로그램 보안 프로세스를 더 잘 이해할 수 있도록 돕고, 교사/학생이 교실 환경 웹 응용 프로그램에서 가르치고 배울 수 있도록 돕는 것입니다. 보안. DVWA의 목표는 다양한 난이도의 간단하고 간단한 인터페이스를 통해 가장 일반적인 웹 취약점 중 일부를 연습하는 것입니다. 이 소프트웨어는
