通過IMAGE COPY技術(shù),可以得到一個(gè)數(shù)據(jù)庫的完整副本,快速打開數(shù)據(jù)庫,避免數(shù)據(jù)庫還原和恢復(fù)的漫長時(shí)間。下面是利用IMAGE COPY進(jìn)行一個(gè)數(shù)據(jù)庫完整恢復(fù)的案例。由于該測試是在同一臺數(shù)據(jù)庫主機(jī)上面進(jìn)行,因此需要注意ORACLE_SID環(huán)境變量,以及相關(guān)路徑下的文件不能被覆蓋。
洪江ssl適用于網(wǎng)站、小程序/APP、API接口等需要進(jìn)行數(shù)據(jù)傳輸應(yīng)用場景,ssl證書未來市場廣闊!成為創(chuàng)新互聯(lián)建站的ssl證書銷售渠道,可以享受市場價(jià)格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:028-86922220(備注:SSL證書合作)期待與您的合作!--1. 創(chuàng)建DB 0級 IMAGE COPY 備份
[oracle@sqlaudit ~]$ rman target / RMAN> BACKUP AS COPY INCREMENTAL LEVEL 0 TAG 'SRCDB-IMAGE' DATABASE FORMAT '/oradata/srcdb_img/SRCDB-LVL0-%U';--2. 創(chuàng)建測試數(shù)據(jù)
[oracle@sqlaudit ~]$ sqlplus / as sysdba SQL> create table scott.test_backup 2 as 3 select rownum rn from dual connect by rownum <= 1000000;--3. 創(chuàng)建DB 1級 IMAGE COPY 備份
RMAN> BACKUP INCREMENTAL LEVEL 1 FOR RECOVER OF TAG 'SRCDB-IMAGE' DATABASE FORMAT '/oradata/srcdb_img/SRCDB-LVL1-%U' PLUS ARCHIVELOG; Starting backup at 2018-01-31 07:48:41 current log archived using channel ORA_DISK_1 channel ORA_DISK_1: starting archived log backup set channel ORA_DISK_1: specifying archived log(s) in backup set input archived log thread=1 sequence=2 RECID=1 STAMP=961989888 input archived log thread=1 sequence=3 RECID=2 STAMP=966842424 input archived log thread=1 sequence=4 RECID=3 STAMP=966842833 input archived log thread=1 sequence=5 RECID=4 STAMP=966842838 input archived log thread=1 sequence=6 RECID=5 STAMP=966842911 input archived log thread=1 sequence=7 RECID=6 STAMP=966842915 input archived log thread=1 sequence=8 RECID=7 STAMP=966844055 input archived log thread=1 sequence=9 RECID=8 STAMP=966844059 input archived log thread=1 sequence=10 RECID=9 STAMP=966844121 channel ORA_DISK_1: starting piece 1 at 2018-01-31 07:48:42 channel ORA_DISK_1: finished piece 1 at 2018-01-31 07:48:43 piece handle=/oracle/app/oracle/product/11.2.0.4/db_1/dbs/12sq1nmp_1_1 tag=SRCDB-IMAGE comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01 Finished backup at 2018-01-31 07:48:43 Starting backup at 2018-01-31 07:48:43 using channel ORA_DISK_1 channel ORA_DISK_1: starting incremental level 1 datafile backup set channel ORA_DISK_1: specifying datafile(s) in backup set input datafile file number=00001 name=/oracle/app/oracle/oradata/srcdb/system01.dbf input datafile file number=00002 name=/oracle/app/oracle/oradata/srcdb/sysaux01.dbf input datafile file number=00005 name=/oracle/app/oracle/oradata/srcdb/ggtbs01.dbf input datafile file number=00003 name=/oracle/app/oracle/oradata/srcdb/undotbs01.dbf input datafile file number=00004 name=/oracle/app/oracle/oradata/srcdb/users01.dbf channel ORA_DISK_1: starting piece 1 at 2018-01-31 07:48:43 channel ORA_DISK_1: finished piece 1 at 2018-01-31 07:48:44 piece handle=/oradata/srcdb_img/SRCDB-LVL1-13sq1nmr_1_1 tag=SRCDB-IMAGE comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01 channel ORA_DISK_1: starting incremental level 1 datafile backup set channel ORA_DISK_1: specifying datafile(s) in backup set including current control file in backup set including current SPFILE in backup set channel ORA_DISK_1: starting piece 1 at 2018-01-31 07:48:45 channel ORA_DISK_1: finished piece 1 at 2018-01-31 07:48:46 piece handle=/oradata/srcdb_img/SRCDB-LVL1-14sq1nms_1_1 tag=SRCDB-IMAGE comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01 Finished backup at 2018-01-31 07:48:46 Starting backup at 2018-01-31 07:48:46 current log archived using channel ORA_DISK_1 channel ORA_DISK_1: starting archived log backup set channel ORA_DISK_1: specifying archived log(s) in backup set input archived log thread=1 sequence=11 RECID=10 STAMP=966844126 channel ORA_DISK_1: starting piece 1 at 2018-01-31 07:48:46 channel ORA_DISK_1: finished piece 1 at 2018-01-31 07:48:47 piece handle=/oracle/app/oracle/product/11.2.0.4/db_1/dbs/15sq1nmu_1_1 tag=SRCDB-IMAGE comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01 Finished backup at 2018-01-31 07:48:47--4. 對 DB 0級 IMAGE COPY 備份進(jìn)行恢復(fù)操作
RMAN> RECOVER COPY OF DATABASE WITH TAG 'SRCDB-IMAGE'; Starting recover at 2018-01-31 07:48:57 using channel ORA_DISK_1 channel ORA_DISK_1: starting incremental datafile backup set restore channel ORA_DISK_1: specifying datafile copies to recover recovering datafile copy file number=00001 name=/oradata/srcdb_img/SRCDB-LVL0-data_D-SRCDB_I-595837900_TS-SYSTEM_FNO-1_0nsq1niv recovering datafile copy file number=00002 name=/oradata/srcdb_img/SRCDB-LVL0-data_D-SRCDB_I-595837900_TS-SYSAUX_FNO-2_0osq1nj2 recovering datafile copy file number=00003 name=/oradata/srcdb_img/SRCDB-LVL0-data_D-SRCDB_I-595837900_TS-UNDOTBS1_FNO-3_0qsq1njk recovering datafile copy file number=00004 name=/oradata/srcdb_img/SRCDB-LVL0-data_D-SRCDB_I-595837900_TS-USERS_FNO-4_0rsq1njl recovering datafile copy file number=00005 name=/oradata/srcdb_img/SRCDB-LVL0-data_D-SRCDB_I-595837900_TS-GGTBS_FNO-5_0psq1njh channel ORA_DISK_1: reading from backup piece /oradata/srcdb_img/SRCDB-LVL1-0vsq1nko_1_1 channel ORA_DISK_1: piece handle=/oradata/srcdb_img/SRCDB-LVL1-0vsq1nko_1_1 tag=SRCDB-IMAGE channel ORA_DISK_1: restored backup piece 1 channel ORA_DISK_1: restore complete, elapsed time: 00:00:01 channel ORA_DISK_1: starting incremental datafile backup set restore channel ORA_DISK_1: specifying datafile copies to recover recovering datafile copy file number=00001 name=/oradata/srcdb_img/SRCDB-LVL0-data_D-SRCDB_I-595837900_TS-SYSTEM_FNO-1_0nsq1niv recovering datafile copy file number=00002 name=/oradata/srcdb_img/SRCDB-LVL0-data_D-SRCDB_I-595837900_TS-SYSAUX_FNO-2_0osq1nj2 recovering datafile copy file number=00003 name=/oradata/srcdb_img/SRCDB-LVL0-data_D-SRCDB_I-595837900_TS-UNDOTBS1_FNO-3_0qsq1njk recovering datafile copy file number=00004 name=/oradata/srcdb_img/SRCDB-LVL0-data_D-SRCDB_I-595837900_TS-USERS_FNO-4_0rsq1njl recovering datafile copy file number=00005 name=/oradata/srcdb_img/SRCDB-LVL0-data_D-SRCDB_I-595837900_TS-GGTBS_FNO-5_0psq1njh channel ORA_DISK_1: reading from backup piece /oradata/srcdb_img/SRCDB-LVL1-13sq1nmr_1_1 channel ORA_DISK_1: piece handle=/oradata/srcdb_img/SRCDB-LVL1-13sq1nmr_1_1 tag=SRCDB-IMAGE channel ORA_DISK_1: restored backup piece 1 channel ORA_DISK_1: restore complete, elapsed time: 00:00:01 Finished recover at 2018-01-31 07:48:59--5. 源庫執(zhí)行備份控制文件操作,獲取日志中的信息
SQL> alter database backup controlfile to trace; -- Set #1. NORESETLOGS case STARTUP NOMOUNT CREATE CONTROLFILE REUSE DATABASE "SRCDB" NORESETLOGS FORCE LOGGING ARCHIVELOG ...... ;--6. 創(chuàng)建新的對象,用于后續(xù)完全恢復(fù)時(shí)進(jìn)行稽核
SQL> create table scott.test22 (id number); SQL> alter system switch logfile; SQL> shutdown immediate;--7. 創(chuàng)建 IMAGE COPY 數(shù)據(jù)庫所需的參數(shù)文件(參數(shù)文件中的db_name不能修改,audit_file_dest與control_files路徑要進(jìn)行調(diào)整)
[oracle@sqlaudit ~]$ cd $ORACLE_HOME/dbs [oracle@sqlaudit dbs]$ cp orapwsrcdb orapwsrcdbnew [oracle@sqlaudit dbs]$ strings spfilesrcdb.ora > initsrcdbnew.ora [oracle@sqlaudit dbs]$ cat initsrcdbnew.ora | grep '/oracle/' *.audit_file_dest='/oracle/app/oracle/admin/srcdbnew/adump' *.control_files='/oradata/srcdb_img/control01.ctl','/oradata/srcdb_img/control02.ctl' [oracle@sqlaudit dbs]$ mkdir -p /oracle/app/oracle/admin/srcdbnew/adump--8. 啟動數(shù)據(jù)庫實(shí)例
[oracle@sqlaudit dbs]$ export ORACLE_SID=srcdbnew [oracle@sqlaudit dbs]$ sqlplus / as sysdba SQL> startup nomount;--9. 復(fù)制在線日志文件到新目錄用于完全恢復(fù)
[oracle@sqlaudit archive]$ cp /oracle/app/oracle/oradata/srcdb/redo01.log /oradata/srcdb_img/redo01.log [oracle@sqlaudit archive]$ cp /oracle/app/oracle/oradata/srcdb/redo02.log /oradata/srcdb_img/redo02.log [oracle@sqlaudit archive]$ cp /oracle/app/oracle/oradata/srcdb/redo03.log /oradata/srcdb_img/redo03.log--10. 重建控制文件
CREATE CONTROLFILE REUSE DATABASE "SRCDB" NORESETLOGS MAXLOGFILES 16 MAXLOGMEMBERS 3 MAXDATAFILES 100 MAXINSTANCES 8 MAXLOGHISTORY 292 LOGFILE GROUP 1 '/oradata/srcdb_img/redo01.log' SIZE 50M BLOCKSIZE 512, GROUP 2 '/oradata/srcdb_img/redo02.log' SIZE 50M BLOCKSIZE 512, GROUP 3 '/oradata/srcdb_img/redo03.log' SIZE 50M BLOCKSIZE 512 DATAFILE '/oradata/srcdb_img/SRCDB-LVL0-data_D-SRCDB_I-595837900_TS-SYSTEM_FNO-1_0nsq1niv', '/oradata/srcdb_img/SRCDB-LVL0-data_D-SRCDB_I-595837900_TS-SYSAUX_FNO-2_0osq1nj2', '/oradata/srcdb_img/SRCDB-LVL0-data_D-SRCDB_I-595837900_TS-UNDOTBS1_FNO-3_0qsq1njk', '/oradata/srcdb_img/SRCDB-LVL0-data_D-SRCDB_I-595837900_TS-USERS_FNO-4_0rsq1njl', '/oradata/srcdb_img/SRCDB-LVL0-data_D-SRCDB_I-595837900_TS-GGTBS_FNO-5_0psq1njh' CHARACTER SET WE8MSWIN1252 ; SQL> SELECT NAME FROM V$DATAFILE;--11. 源庫檢查檢查需要注冊的日志文件
[oracle@sqlaudit dbs]$ export ORACLE_SID=srcdb SQL> startup mount; RMAN> list backup of archivelog all; BS Key Size Device Type Elapsed Time Completion Time ------- ---------- ----------- ------------ ------------------- 19 3.50K DISK 00:00:00 2018-01-31 07:48:46 BP Key: 19 Status: AVAILABLE Compressed: NO Tag: SRCDB-IMAGE Piece Name: /oracle/app/oracle/product/11.2.0.4/db_1/dbs/15sq1nmu_1_1 List of Archived Logs in backup set 19 Thrd Seq Low SCN Low Time Next SCN Next Time ---- ------- ---------- ------------------- ---------- --------- 1 11 969636 2018-01-31 07:48:41 969648 2018-01-31 07:48:46--12. 新庫注冊源庫的日志文件
SQL> ALTER DATABASE REGISTER LOGFILE '/oracle/archive/1_11_961988430.dbf'; SQL> ALTER DATABASE REGISTER LOGFILE '/oracle/archive/1_12_961988430.dbf'; SQL> ALTER DATABASE REGISTER LOGFILE '/oracle/archive/1_13_961988430.dbf'; SQL> ALTER DATABASE REGISTER LOGFILE '/oracle/archive/1_14_961988430.dbf'; SQL> RECOVER DATABASE; SQL> ALTER DATABASE OPEN;--13. 創(chuàng)建新的臨時(shí)文件
SQL> ALTER TABLESPACE TEMP ADD TEMPFILE '/oradata/srcdb_img/temp01.dbf' SIZE 100M AUTOEXTEND OFF;另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。