2013年7月26日 星期五

Oracle 11g-手動 Duplicate database (異機使用RMAN備份檔)

說起來本章算是半人工狀態進行 Duplicate 資料庫到其他台,為什說是半人工狀態呢?
因為整個過程人工的部分都在做環境設定,直到最後仍需要RAMN所產生的備份檔進行還原
接下來我會先模擬一個情境狀態接下來在一步一步說明該如何操作!!

情境:


A同事說: 我需要一個平台測試我的SQL或是內容...但我不想搞壞現有的DB
B同事說: 我需要安裝一個Patch但我也不想搞壞現有的DB
C同事說: 我想要練習一下DB管理,但我也能搞壞現有的DB
老闆說: 我希望公司就算沒有錢做Cluster的機器.....但還是希望這台壞掉以後能有一台加減頂一
               下.....不管怎樣你自己想個辦法解決一下


所以說....用手上現有空閒的硬體複製一個一模一樣的DB就可以暫時解決這個問題
Duplicate database時最好兩邊的版本都是一樣的比較不會有問題

來吧~ 看看怎樣進行下一步









Step 1. 安裝 Oracle 用Linux 作業系統

如果還未曾安裝過請參閱我的文章:  [Oracle 11g-安裝Oracle 用Linux OS 及設定]


Step 2.安裝 Grid Infrastructure 

如果還未曾安裝過請參閱我的文章: [Oracle 11g-安裝Grid Infrastructure]

Step 3.安裝 Database Software
如果還未曾安裝過請參閱我的文章:  [Oracle 11g-安裝Oracle database software]
(這裡只要把軟體裝起來就可以不用新增Database)


Step 4.切換至oracle帳號,手動新增Oracle 環境變數
(必做! 如果不做的話很多東西都沒辦法執行)

[root@oracleEXdb bin]# vi /etc/oratab

# This file is used by ORACLE utilities.  It is created by root.sh
# and updated by the Database Configuration Assistant when creating
# a database.

# A colon, ':', is used as the field terminator.  A new line terminates
# the entry.  Lines beginning with a pound sign, '#', are comments.
#
# Entries are of the form:
#   $ORACLE_SID:$ORACLE_HOME:<N|Y>:
#
# The first and second fields are the system identifier and home
# directory of the database respectively.  The third filed indicates
# to the dbstart utility that the database should , "Y", or should not,
# "N", be brought up at system boot time.
#
# Multiple entries with the same $ORACLE_SID are not allowed.
#
#
+ASM:/u01/app/oracle/product/11.2.0/grid:N   << 目前只有ASM
orcl3:/u03/app/oracle/product/11.2.0/dbhome_1:N  <<新增一行環境變數(請依據實際情況對應)

Step 5.建立全新密碼檔並確認是否以建立完成

[root@oracleEXdb bin]# orapwd file=$ORACLE_HOME/dbs/orapworcl3 password=oracle entries=10

密碼檔檔案格式如下:
UNIX:$ORACLE_HOME/dbs/orapw$ORACLE_SID                       


檢查:

[root@oracleEXdb dbs]# pwd
/u03/app/oracle/product/11.2.0/dbhome_1/dbs
[root@oracleEXdb dbs]# ls -al

-rw-r--r--  1 oracle oinstall 2851 May 15  2009 init.ora
-rw-r-----  1 root   root     2560 Jul 25 10:23 orapworcl3



Step 6.建立Listener

不想手動建立Tnsnames.ora的話,可以去拿Grid Infrastructure /network/admin下的listener.ora 複製到database softeare  /network/admin下並更名為 Tnsnames.ora

(這裡有個疑問是? 為什麼不直接建在Grid 下就好了呢?)


[oracle@oracleEXdb ~]$ . oraenv
ORACLE_SID = [oracle] ? +ASM
The Oracle base for ORACLE_HOME=/u01/app/oracle/product/11.2.0/grid is /u01/app/oracle
[oracle@oracleEXdb ~]$ cd $ORACLE_HOME/network/admin/
[oracle@oracleEXdb admin]$ ls -al

drwxr-xr-x  3 oracle oinstall 4096 Jul 24 00:50 .
drwxr-xr-x 11 oracle oinstall 4096 Jul 24 00:43 ..
-rw-r--r--  1 oracle oinstall  437 Jul 24 00:50 listener.ora
-rw-r--r--  1 oracle oinstall  371 Jul 24 00:50 listener.ora.bak.oracleexdb
drwxr-xr-x  2 oracle oinstall 4096 Jul 24 00:39 samples
-rw-r--r--  1 oracle oinstall  187 May  9  2007 shrept.lst
-rw-r--r--  1 oracle oinstall  219 Jul 24 00:50 sqlnet.ora
[oracle@oracleEXdb admin]$ cat listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/grid/network/admin/listener.ora
# Generated by Oracle configuration tools.

[oracle@oracleEXdb admin]$ cp listener.ora /u03/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora


Step 6-1.修改Tnsnames.ora內容  (紅字部分要注意一下)
 ORCL3=
 (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = oracleEXdb)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = orcl3)
    )
  )


完成後測試一下

[root@oracleEXdb admin]# tnsping orcl3

TNS Ping Utility for Linux: Version 11.2.0.1.0 - Production on 25-JUL-2013 11:03:47
Copyright (c) 1997, 2009, Oracle.  All rights reserved.
Used parameter files:
/u03/app/oracle/product/11.2.0/dbhome_1/network/admin/sqlnet.ora
Used TNSNAMES adapter to resolve the alias

Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = oracleEXdb)
(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = orcl3))
TNS-12533: TNS:illegal ADDRESS parameters

(到這步驟其實只測試到listener ,使用的連線方式可以後面在設定即可 ex: EZCONNECT or....)



Step 7 .取得Target database 相關資料 (紅字部分要注意一下)

目前需要資料為:   1. pfile  2.controlfile 3.datafile 4.archivelog


Step 7-1 匯出pfile
在target端操作匯出pfile (用途:要在目地端上能夠操作必須要用pfile去匯入spfile)
SQL> create pfile ='/home/oracle/pfile_20130725' from spfile;

Step 7-2 備份Controlfile

RMAN> backup current controlfile format '/home/oracle/backup_controlfile_20130725.bak';
Starting backup at 25-JUL-13
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
using channel ORA_DISK_4
using channel ORA_DISK_5
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
channel ORA_DISK_1: starting piece 1 at 25-JUL-13
channel ORA_DISK_1: finished piece 1 at 25-JUL-13
piece handle=/home/oracle/backup_controlfile_20130725.bak tag=TAG20130725T042523 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 25-JUL-13

Step 7-3 備份Database 

RMAN> backup database format '/home/oracle/backup20130725_datafile%U.bak';
Starting backup at 25-JUL-13
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
using channel ORA_DISK_4
using channel ORA_DISK_5
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=+DATA/orcl/datafile/system.256.820621145
channel ORA_DISK_1: starting piece 1 at 25-JUL-13
channel ORA_DISK_2: starting full datafile backup set
channel ORA_DISK_2: specifying datafile(s) in backup set
input datafile file number=00002 name=+DATA/orcl/datafile/sysaux.257.818332275
channel ORA_DISK_2: starting piece 1 at 25-JUL-13
channel ORA_DISK_3: starting full datafile backup set
channel ORA_DISK_3: specifying datafile(s) in backup set
input datafile file number=00003 name=+DATA/orcl/datafile/undotbs1.258.818332275
channel ORA_DISK_3: starting piece 1 at 25-JUL-13
channel ORA_DISK_4: starting full datafile backup set
channel ORA_DISK_4: specifying datafile(s) in backup set
input datafile file number=00004 name=+DATA/orcl/datafile/users.259.820605537
input datafile file number=00005 name=+DATA/orcl/datafile/example.265.818332605
channel ORA_DISK_4: starting piece 1 at 25-JUL-13
channel ORA_DISK_5: starting full datafile backup set
channel ORA_DISK_5: specifying datafile(s) in backup set
input datafile file number=00006 name=/u02/oradata/orcl/demots01.dbf
input datafile file number=00007 name=/u02/oradata/orcl/frankts01.dbf
channel ORA_DISK_5: starting piece 1 at 25-JUL-13
channel ORA_DISK_5: finished piece 1 at 25-JUL-13
piece handle=/home/oracle/backup20130725_datafilebsofjld4_1_1.bak tag=TAG20130725T041834 comment=NONE
channel ORA_DISK_5: backup set complete, elapsed time: 00:01:15
channel ORA_DISK_5: starting full datafile backup set
channel ORA_DISK_5: specifying datafile(s) in backup set
input datafile file number=00008 name=/u02/oradata/orcl/index_ts01.dbf
input datafile file number=00010 name=/u02/oradata/orcl/fda_ts01.dbf
channel ORA_DISK_5: starting piece 1 at 25-JUL-13
channel ORA_DISK_5: finished piece 1 at 25-JUL-13
piece handle=/home/oracle/backup20130725_datafilebtofjlfg_1_1.bak tag=TAG20130725T041834 comment=NONE
channel ORA_DISK_5: backup set complete, elapsed time: 00:00:26
channel ORA_DISK_4: finished piece 1 at 25-JUL-13
piece handle=/home/oracle/backup20130725_datafilebrofjld0_1_1.bak tag=TAG20130725T041834 comment=NONE
channel ORA_DISK_4: backup set complete, elapsed time: 00:01:54
channel ORA_DISK_3: finished piece 1 at 25-JUL-13
piece handle=/home/oracle/backup20130725_datafilebqofjlcs_1_1.bak tag=TAG20130725T041834 comment=NONE
channel ORA_DISK_3: backup set complete, elapsed time: 00:02:39
channel ORA_DISK_2: finished piece 1 at 25-JUL-13
piece handle=/home/oracle/backup20130725_datafilebpofjlcs_1_1.bak tag=TAG20130725T041834 comment=NONE
channel ORA_DISK_2: backup set complete, elapsed time: 00:03:30
channel ORA_DISK_1: finished piece 1 at 25-JUL-13
piece handle=/home/oracle/backup20130725_datafileboofjlcs_1_1.bak tag=TAG20130725T041834 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:03:40
Finished backup at 25-JUL-13

Step 7-4 備份Archivelog

RMAN> backup archivelog all format '/home/oracle/backup_archovelog_20130725_P%U.bak' ;
Starting backup at 25-JUL-13
current log archived
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
using channel ORA_DISK_4
using channel ORA_DISK_5
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=10 RECID=502 STAMP=821122249
input archived log thread=1 sequence=57 RECID=638 STAMP=821657498
channel ORA_DISK_1: starting piece 1 at 25-JUL-13
channel ORA_DISK_2: starting archived log backup set
channel ORA_DISK_2: specifying archived log(s) in backup set
input archived log thread=1 sequence=58 RECID=641 STAMP=821657780
input archived log thread=1 sequence=59 RECID=644 STAMP=821659305
channel ORA_DISK_2: starting piece 1 at 25-JUL-13
channel ORA_DISK_3: starting archived log backup set
channel ORA_DISK_3: specifying archived log(s) in backup set
input archived log thread=1 sequence=60 RECID=647 STAMP=821659401
input archived log thread=1 sequence=61 RECID=650 STAMP=821664053
channel ORA_DISK_3: starting piece 1 at 25-JUL-13
channel ORA_DISK_4: starting archived log backup set
channel ORA_DISK_4: specifying archived log(s) in backup set
input archived log thread=1 sequence=62 RECID=653 STAMP=821675444
input archived log thread=1 sequence=63 RECID=656 STAMP=821677787
channel ORA_DISK_4: starting piece 1 at 25-JUL-13
channel ORA_DISK_5: starting archived log backup set
channel ORA_DISK_5: specifying archived log(s) in backup set
input archived log thread=1 sequence=64 RECID=659 STAMP=821688328
input archived log thread=1 sequence=65 RECID=662 STAMP=821688838
channel ORA_DISK_5: starting piece 1 at 25-JUL-13
channel ORA_DISK_1: finished piece 1 at 25-JUL-13
piece handle=/home/oracle/backup_archovelog_20130725_Pc3ofjuga_1_1.bak tag=TAG20130725T065400 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:26
channel ORA_DISK_2: finished piece 1 at 25-JUL-13
piece handle=/home/oracle/backup_archovelog_20130725_Pc4ofjuga_1_1.bak tag=TAG20130725T065400 comment=NONE
channel ORA_DISK_2: backup set complete, elapsed time: 00:00:22
channel ORA_DISK_3: finished piece 1 at 25-JUL-13
piece handle=/home/oracle/backup_archovelog_20130725_Pc5ofjuge_1_1.bak tag=TAG20130725T065400 comment=NONE
channel ORA_DISK_3: backup set complete, elapsed time: 00:00:14
channel ORA_DISK_4: finished piece 1 at 25-JUL-13
piece handle=/home/oracle/backup_archovelog_20130725_Pc6ofjugm_1_1.bak tag=TAG20130725T065400 comment=NONE
channel ORA_DISK_4: backup set complete, elapsed time: 00:00:09
channel ORA_DISK_5: finished piece 1 at 25-JUL-13
piece handle=/home/oracle/backup_archovelog_20130725_Pc7ofjugu_1_1.bak tag=TAG20130725T065400 comment=NONE
channel ORA_DISK_5: backup set complete, elapsed time: 00:00:03
Finished backup at 25-JUL-13


***請將上述這些需要的資料完成後利用FTP SERVER或是其他方法將這些檔案複製到目的端 
      的 /home/oracle中 ****


Step 8 . 手動建立資料夾路徑

必須在目的地端伺服器下建立幾個資料夾,在建立之前老實說我也不確定到底要建到多深的層次,這裡有兩種選擇可供參考一種是用OS command tree指令讀取一下Target的目錄結構,只要跟你原來Instance有的資料夾就一併建回去,另一個則是參考剛剛匯出來的pfile裡面有什摩路徑就跟著建回去即可

(這裡我研究一下在跟你說用哪一種好


a.使用tree 指令讀取一下Target的目錄結構

[oracle@oracledb oracle]$ tree /u01/app/oracle/ -L 5 -d

/u01/app/oracle/
|-- admin
|   |
|   |
|   |-- orcl
|   |   |-- adump
|   |   |-- dpdump
|   |   `-- pfile
|
|-- cfgtoollogs
|   |
|   |-- dbca
|   |   |-- orcl
|   |
|   |    
|   |-- emca
|   |   |-- orcl
|   |
|-- diag
|   |-- rdbms
|   |   |-- orcl
|   |   |   `-- orcl
|   |   |       |-- alert
|   |   |       |-- cdump
|   |   |       |-- hm
|   |   |       |-- incident
|   |   |       |-- incpkg
|   |   |       |-- ir
|   |   |       |-- lck
|   |   |       |-- metadata
|   |   |       |-- stage
|   |   |       |-- sweep
|   |   |       `-- trace
`-- product
    `-- 11.2.0
        |-- dbhome_1
        |   |-- oracledb_orcl

        |   |   `-- sysman


b.使用pfile內容的路徑
(每個人的pfile內容事實上都不相同,只要注意一點如果你的目的端的instance 跟路徑都不相同你這裡就全數都要改)

紅字部分就是我要改的東西,請改成你目的端的資訊
例如:  

來源端                                     目的端
==============================
主機名稱 :oracledb                                主機名稱:oracleEX3
Insatnce: orcl                                            Instance: orcl3
主要資料夾: /u01                                   主要資料夾: /03
次要datafile資料夾: /u02                        次要datafile資料夾: /u04


orcl.__db_cache_size=79691776
orcl.__java_pool_size=4194304
orcl.__large_pool_size=8388608
orcl.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
orcl.__pga_aggregate_target=209715200
orcl.__sga_target=314572800
orcl.__shared_io_pool_size=0
orcl.__shared_pool_size=205520896
orcl.__streams_pool_size=8388608
*.audit_file_dest='/u01/app/oracle/admin/orcl/adump'
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.control_files='+DATA/orcl/controlfile/current.332.820661737','+FRA/orcl/controlfile/current.449.820661741'
*.db_block_size=8192
*.db_create_file_dest='+DATA'
*.db_domain=''  <<如果你有的話填入吧
*.db_name='orcl'
*.db_recovery_file_dest='+FRA'
*.db_recovery_file_dest_size=10737418240
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)'
*.fast_start_mttr_target=0
*.filesystemio_options='SETALL'
*.job_queue_processes=1000
*.log_archive_dest_1='LOCATION=USE_DB_RECOVERY_FILE_DEST MANDATORY   <<這個可以不用(因為是走ASM)
REOPEN=300'
*.log_archive_dest_2='LOCATION=/u02/oradata/archive OPTIONAL REOPEN=300'
*.log_archive_dest_3='LOCATION=+DATA OPTIONAL REOPEN=300'
*.log_archive_format='%t_%s_%r.dbf'
*.memory_target=524288000
*.open_cursors=300
*.pga_aggregate_target=0
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.resource_manager_plan=''
orcl.resource_manager_plan=''

*.undo_tablespace='UNDOTBS1'

c.(關於PFILE這段我個人有點疑問,因為感覺就是少了點甚麼所以回頭去Show parameter 所有的資訊比對了一下,跟路徑或是instance有關的名稱這些都是沒出現的。經驗證後以下這些事會自動產生的所以就不用擔心嚕~ 害我擔心了一下下 ~呼

background_dump_dest  string /u01/app/oracle/diag/rdbms/orcl/orcl/trace
user_dump_dest  string  /u01/app/oracle/diag/rdbms/orcl/orcl/trace
core_dump_dest  string /u01/app/oracle/diag/rdbms/orcl/orcl/cdump
dg_broker_config_file1          string /u01/app/oracle/product/11.2.0/dbhome_1/dbs/dr1orcl.dat
dg_broker_config_file2  string /u01/app/oracle/product/11.2.0/dbhome_1/dbs/dr2orcl.dat
diagnostic_dest          string /u01/app/oracle
spfile                  string /u01/app/oracle/product/11.2.0/dbhome_1/dbs/spfileorcl.ora
instance_name          string orcl
service_names          string orcl



所以統整一下我的做法:

1.先將b部分PFILE中現有的資料更改後並且建立對應的資料夾
2.把改好的PFIEL 匯入SPFILE中   (請務必先建立資料夾在匯入不然到時對應不起來的時候系
    統會報錯而不讓你進入SQL>)
    指令:    SQL> create spfile from pfile='/home/oracle/pfile_20130725';

3.把a部分用tree產生的結構拉出來一起建資料夾,這樣就萬無一失

整個看起來好像就很複雜,但我的目的就是不想要後面在去一個一個修正或是遇到問題,不如在此時就先全數搞定我覺得比較好。




Step 9 . 將Instance 開至nomount狀態


[oracle@oracleEXdb ~]$ sqlplus "/as sysdba"
SQL*Plus: Release 11.2.0.1.0 Production on Thu Jul 25 23:38:57 2013
Copyright (c) 1982, 2009, Oracle.  All rights reserved.
Connected to an idle instance.

SQL> startup nomount
ORACLE instance started.

Total System Global Area  523108352 bytes
Fixed Size     1337632 bytes
Variable Size   436209376 bytes
Database Buffers    79691776 bytes
Redo Buffers     5869568 bytes
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

Step 10 . 進行Duplicate

開啟RMAN並輸入以下指令

rman target sys/oracle@192.168.56.2:1521/orcl auxiliary / 請把紅字部分改成你自己的Target DB位置與帳號密碼

[oracle@oracleEXdb ~]$ rman target sys/oracle@192.168.56.2:1521/orcl auxiliary /

Recovery Manager: Release 11.2.0.1.0 - Production on Thu Jul 25 23:39:34 2013
Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

connected to target database: ORCL (DBID=1346113250)
connected to auxiliary database: ORCL3 (not mounted)

設定兩個Channel (如果需要在多一點話請自己在加上去即可)

RMAN> run {
2> allocate auxiliary channel aux1 device type disk;
3> allocate auxiliary channel aux2 device type disk;
4> duplicate target database to orcl3;}

using target database control file instead of recovery catalog
allocated channel: aux1
channel aux1: SID=23 device type=DISK

allocated channel: aux2
channel aux2: SID=24 device type=DISK

Starting Duplicate Db at 25-JUL-13

contents of Memory Script:
{
   sql clone "alter system set  control_files =
  ''+DATA/orcl3/controlfile/current.257.821741447'', ''+FRAEX3/orcl3/controlfile/current.256.821741451'' comment=
 ''Set by RMAN'' scope=spfile";
   sql clone "alter system set  db_name =
 ''ORCL'' comment=
 ''Modified by RMAN duplicate'' scope=spfile";
   sql clone "alter system set  db_unique_name =
 ''ORCL3'' comment=
 ''Modified by RMAN duplicate'' scope=spfile";
   shutdown clone immediate;
   startup clone force nomount
   restore clone primary controlfile;
   alter clone database mount;
}
executing Memory Script

sql statement: alter system set  control_files =   ''+DATA/orcl3/controlfile/current.257.821741447'', ''+FRAEX3/orcl3/controlfile/current.256.821741451'' comment= ''Set by RMAN'' scope=spfile

sql statement: alter system set  db_name =  ''ORCL'' comment= ''Modified by RMAN duplicate'' scope=spfile

sql statement: alter system set  db_unique_name =  ''ORCL3'' comment= ''Modified by RMAN duplicate'' scope=spfile

Oracle instance shut down

Oracle instance started

Total System Global Area     523108352 bytes

Fixed Size                     1337632 bytes
Variable Size                436209376 bytes
Database Buffers              79691776 bytes
Redo Buffers                   5869568 bytes
allocated channel: aux1
channel aux1: SID=22 device type=DISK
allocated channel: aux2
channel aux2: SID=23 device type=DISK

Starting restore at 25-JUL-13

channel aux1: starting datafile backup set restore
channel aux1: restoring control file
channel aux1: reading from backup piece +FRA/orcl/autobackup/2013_07_25/s_821717576.395.821717579
channel aux1: ORA-19870: error while restoring backup piece +FRA/orcl/autobackup/2013_07_25/s_821717576.395.821717579
ORA-19505: failed to identify file "+FRA/orcl/autobackup/2013_07_25/s_821717576.395.821717579"
ORA-17503: ksfdopn:2 Failed to open file +FRA/orcl/autobackup/2013_07_25/s_821717576.395.821717579
ORA-15001: diskgroup "FRA" does not exist or is not mounted
ORA-15001: diskgroup "FRA" does not exist or is not mounte
failover to previous backup

channel aux1: starting datafile backup set restore
channel aux1: restoring control file
channel aux1: reading from backup piece /home/oracle/bk1/backup_ctl.bak
channel aux1: piece handle=/home/oracle/bk1/backup_ctl.bak tag=TAG20130725T145249
channel aux1: restored backup piece 1
channel aux1: restore complete, elapsed time: 00:00:07
output file name=+DATA/orcl3/controlfile/current.257.821741447
output file name=+FRAEX3/orcl3/controlfile/current.256.821741451
Finished restore at 25-JUL-13

database mounted
Using previous duplicated file +DATA/orcl3/datafile/system.266.821741633 for datafile 1 with checkpoint SCN of 4418570
Using previous duplicated file +DATA/orcl3/datafile/sysaux.265.821741633 for datafile 2 with checkpoint SCN of 4418571
Using previous duplicated file +DATA/orcl3/datafile/undotbs1.263.821741547 for datafile 3 with checkpoint SCN of 4418573
Using previous duplicated file +DATA/orcl3/datafile/users.262.821741547 for datafile 4 with checkpoint SCN of 4418575
Using previous duplicated file +DATA/orcl3/datafile/example.264.821741549 for datafile 5 with checkpoint SCN of 4418575
Using previous duplicated file +DATA/orcl3/datafile/demots1.258.821741491 for datafile 6 with checkpoint SCN of 4418577
Using previous duplicated file +DATA/orcl3/datafile/frankts.260.821741495 for datafile 7 with checkpoint SCN of 4418577
Using previous duplicated file +DATA/orcl3/datafile/index_ts.259.821741493 for datafile 8 with checkpoint SCN of 4418617
Using previous duplicated file +DATA/orcl3/datafile/fda_ts.261.821741495 for datafile 10 with checkpoint SCN of 4418617

contents of Memory Script:
{
   catalog clone datafilecopy  "+DATA/orcl3/datafile/system.266.821741633",
 "+DATA/orcl3/datafile/sysaux.265.821741633",
 "+DATA/orcl3/datafile/undotbs1.263.821741547",
 "+DATA/orcl3/datafile/users.262.821741547",
 "+DATA/orcl3/datafile/example.264.821741549",
 "+DATA/orcl3/datafile/demots1.258.821741491",
 "+DATA/orcl3/datafile/frankts.260.821741495",
 "+DATA/orcl3/datafile/index_ts.259.821741493",
 "+DATA/orcl3/datafile/fda_ts.261.821741495";
   switch clone datafile  1 to datafilecopy
 "+DATA/orcl3/datafile/system.266.821741633";
   switch clone datafile  2 to datafilecopy
 "+DATA/orcl3/datafile/sysaux.265.821741633";
   switch clone datafile  3 to datafilecopy
 "+DATA/orcl3/datafile/undotbs1.263.821741547";
   switch clone datafile  4 to datafilecopy
 "+DATA/orcl3/datafile/users.262.821741547";
   switch clone datafile  5 to datafilecopy
 "+DATA/orcl3/datafile/example.264.821741549";
   switch clone datafile  6 to datafilecopy
 "+DATA/orcl3/datafile/demots1.258.821741491";
   switch clone datafile  7 to datafilecopy
 "+DATA/orcl3/datafile/frankts.260.821741495";
   switch clone datafile  8 to datafilecopy
 "+DATA/orcl3/datafile/index_ts.259.821741493";
   switch clone datafile  10 to datafilecopy
 "+DATA/orcl3/datafile/fda_ts.261.821741495";
}
executing Memory Script

cataloged datafile copy
datafile copy file name=+DATA/orcl3/datafile/system.266.821741633 RECID=25 STAMP=821749271
cataloged datafile copy
datafile copy file name=+DATA/orcl3/datafile/sysaux.265.821741633 RECID=26 STAMP=821749271
cataloged datafile copy
datafile copy file name=+DATA/orcl3/datafile/undotbs1.263.821741547 RECID=27 STAMP=821749271
cataloged datafile copy
datafile copy file name=+DATA/orcl3/datafile/users.262.821741547 RECID=28 STAMP=821749271
cataloged datafile copy
datafile copy file name=+DATA/orcl3/datafile/example.264.821741549 RECID=29 STAMP=821749271
cataloged datafile copy
datafile copy file name=+DATA/orcl3/datafile/demots1.258.821741491 RECID=30 STAMP=821749271
cataloged datafile copy
datafile copy file name=+DATA/orcl3/datafile/frankts.260.821741495 RECID=31 STAMP=821749271
cataloged datafile copy
datafile copy file name=+DATA/orcl3/datafile/index_ts.259.821741493 RECID=32 STAMP=821749271
cataloged datafile copy
datafile copy file name=+DATA/orcl3/datafile/fda_ts.261.821741495 RECID=33 STAMP=821749271

datafile 1 switched to datafile copy
input datafile copy RECID=25 STAMP=821749271 file name=+DATA/orcl3/datafile/system.266.821741633

datafile 2 switched to datafile copy
input datafile copy RECID=26 STAMP=821749271 file name=+DATA/orcl3/datafile/sysaux.265.821741633

datafile 3 switched to datafile copy
input datafile copy RECID=27 STAMP=821749271 file name=+DATA/orcl3/datafile/undotbs1.263.821741547

datafile 4 switched to datafile copy
input datafile copy RECID=28 STAMP=821749271 file name=+DATA/orcl3/datafile/users.262.821741547

datafile 5 switched to datafile copy
input datafile copy RECID=29 STAMP=821749271 file name=+DATA/orcl3/datafile/example.264.821741549

datafile 6 switched to datafile copy
input datafile copy RECID=30 STAMP=821749271 file name=+DATA/orcl3/datafile/demots1.258.821741491

datafile 7 switched to datafile copy
input datafile copy RECID=31 STAMP=821749271 file name=+DATA/orcl3/datafile/frankts.260.821741495

datafile 8 switched to datafile copy
input datafile copy RECID=32 STAMP=821749271 file name=+DATA/orcl3/datafile/index_ts.259.821741493

datafile 10 switched to datafile copy
input datafile copy RECID=33 STAMP=821749271 file name=+DATA/orcl3/datafile/fda_ts.261.821741495

contents of Memory Script:
{
   set until scn  4469462;
   recover
   clone database
    delete archivelog
   ;
}
executing Memory Script

executing command: SET until clause

Starting recover at 25-JUL-13

starting media recovery

channel aux1: starting archived log restore to default destination
channel aux1: restoring archived log
archived log thread=1 sequence=64
channel aux1: restoring archived log
archived log thread=1 sequence=65
channel aux1: reading from backup piece /home/oracle/bk1/backup_archive_all_ckofkqgk_1_1.bak
channel aux2: starting archived log restore to default destination
channel aux2: restoring archived log
archived log thread=1 sequence=66
channel aux2: restoring archived log
archived log thread=1 sequence=67
channel aux2: restoring archived log
archived log thread=1 sequence=68
channel aux2: reading from backup piece /home/oracle/bk1/backup_archive_all_clofkqgr_1_1.bak
channel aux1: piece handle=/home/oracle/bk1/backup_archive_all_ckofkqgk_1_1.bak tag=TAG20130725T145146
channel aux1: restored backup piece 1
channel aux1: restore complete, elapsed time: 00:00:07
archived log file name=+FRAEX3/orcl3/archivelog/2013_07_25/thread_1_seq_64.257.821749277 thread=1 sequence=64
channel clone_default: deleting archived log(s)
archived log file name=+FRAEX3/orcl3/archivelog/2013_07_25/thread_1_seq_64.257.821749277 RECID=676 STAMP=821749283
archived log file name=+FRAEX3/orcl3/archivelog/2013_07_25/thread_1_seq_65.259.821749279 thread=1 sequence=65
channel clone_default: deleting archived log(s)
archived log file name=+FRAEX3/orcl3/archivelog/2013_07_25/thread_1_seq_65.259.821749279 RECID=674 STAMP=821749281
channel aux2: piece handle=/home/oracle/bk1/backup_archive_all_clofkqgr_1_1.bak tag=TAG20130725T145146
channel aux2: restored backup piece 1
channel aux2: restore complete, elapsed time: 00:00:24
archived log file name=+FRAEX3/orcl3/archivelog/2013_07_25/thread_1_seq_66.258.821749277 thread=1 sequence=66
channel clone_default: deleting archived log(s)
archived log file name=+FRAEX3/orcl3/archivelog/2013_07_25/thread_1_seq_66.258.821749277 RECID=678 STAMP=821749286
archived log file name=+FRAEX3/orcl3/archivelog/2013_07_25/thread_1_seq_67.260.821749279 thread=1 sequence=67
channel clone_default: deleting archived log(s)
archived log file name=+FRAEX3/orcl3/archivelog/2013_07_25/thread_1_seq_67.260.821749279 RECID=677 STAMP=821749283
archived log file name=+FRAEX3/orcl3/archivelog/2013_07_25/thread_1_seq_68.261.821749281 thread=1 sequence=68
channel clone_default: deleting archived log(s)
archived log file name=+FRAEX3/orcl3/archivelog/2013_07_25/thread_1_seq_68.261.821749281 RECID=675 STAMP=821749282
media recovery complete, elapsed time: 00:00:24
Finished recover at 25-JUL-13

contents of Memory Script:
{
   shutdown clone immediate;
   startup clone nomount;
   sql clone "alter system set  db_name =
 ''ORCL3'' comment=
 ''Reset to original value by RMAN'' scope=spfile";
   sql clone "alter system reset  db_unique_name scope=spfile";
   shutdown clone immediate;
   startup clone nomount;
}
executing Memory Script

database dismounted
Oracle instance shut down

connected to auxiliary database (not started)
Oracle instance started

Total System Global Area     523108352 bytes

Fixed Size                     1337632 bytes
Variable Size                436209376 bytes
Database Buffers              79691776 bytes
Redo Buffers                   5869568 bytes
allocated channel: aux1
channel aux1: SID=22 device type=DISK
allocated channel: aux2
channel aux2: SID=23 device type=DISK

sql statement: alter system set  db_name =  ''ORCL3'' comment= ''Reset to original value by RMAN'' scope=spfile

sql statement: alter system reset  db_unique_name scope=spfile

Oracle instance shut down

connected to auxiliary database (not started)
Oracle instance started

Total System Global Area     523108352 bytes

Fixed Size                     1337632 bytes
Variable Size                436209376 bytes
Database Buffers              79691776 bytes
Redo Buffers                   5869568 bytes
allocated channel: aux1
channel aux1: SID=22 device type=DISK
allocated channel: aux2
channel aux2: SID=23 device type=DISK
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "ORCL3" RESETLOGS ARCHIVELOG
  MAXLOGFILES     16
  MAXLOGMEMBERS      3
  MAXDATAFILES      100
  MAXINSTANCES     8
  MAXLOGHISTORY      292
 LOGFILE
  GROUP  1  SIZE 50 M ,
  GROUP  2  SIZE 50 M ,
  GROUP  3  SIZE 50 M ,
  GROUP  4  SIZE 50 M
 DATAFILE
  '+DATA/orcl3/datafile/system.266.821741633'
 CHARACTER SET ZHT16MSWIN950


contents of Memory Script:
{
   set newname for clone tempfile  1 to new;
   switch clone tempfile all;
   catalog clone datafilecopy  "+DATA/orcl3/datafile/sysaux.265.821741633",
 "+DATA/orcl3/datafile/undotbs1.263.821741547",
 "+DATA/orcl3/datafile/users.262.821741547",
 "+DATA/orcl3/datafile/example.264.821741549",
 "+DATA/orcl3/datafile/demots1.258.821741491",
 "+DATA/orcl3/datafile/frankts.260.821741495",
 "+DATA/orcl3/datafile/index_ts.259.821741493",
 "+DATA/orcl3/datafile/fda_ts.261.821741495";
   switch clone datafile all;
   switch clone datafile  2 to datafilecopy
 "+DATA/orcl3/datafile/sysaux.265.821741633";
   switch clone datafile  3 to datafilecopy
 "+DATA/orcl3/datafile/undotbs1.263.821741547";
   switch clone datafile  4 to datafilecopy
 "+DATA/orcl3/datafile/users.262.821741547";
   switch clone datafile  5 to datafilecopy
 "+DATA/orcl3/datafile/example.264.821741549";
   switch clone datafile  6 to datafilecopy
 "+DATA/orcl3/datafile/demots1.258.821741491";
   switch clone datafile  7 to datafilecopy
 "+DATA/orcl3/datafile/frankts.260.821741495";
   switch clone datafile  8 to datafilecopy
 "+DATA/orcl3/datafile/index_ts.259.821741493";
   switch clone datafile  10 to datafilecopy
 "+DATA/orcl3/datafile/fda_ts.261.821741495";
}
executing Memory Script

executing command: SET NEWNAME

renamed tempfile 1 to +DATA in control file

cataloged datafile copy
datafile copy file name=+DATA/orcl3/datafile/sysaux.265.821741633 RECID=1 STAMP=821749350
cataloged datafile copy
datafile copy file name=+DATA/orcl3/datafile/undotbs1.263.821741547 RECID=2 STAMP=821749350
cataloged datafile copy
datafile copy file name=+DATA/orcl3/datafile/users.262.821741547 RECID=3 STAMP=821749350
cataloged datafile copy
datafile copy file name=+DATA/orcl3/datafile/example.264.821741549 RECID=4 STAMP=821749350
cataloged datafile copy
datafile copy file name=+DATA/orcl3/datafile/demots1.258.821741491 RECID=5 STAMP=821749350
cataloged datafile copy
datafile copy file name=+DATA/orcl3/datafile/frankts.260.821741495 RECID=6 STAMP=821749350
cataloged datafile copy
datafile copy file name=+DATA/orcl3/datafile/index_ts.259.821741493 RECID=7 STAMP=821749350
cataloged datafile copy
datafile copy file name=+DATA/orcl3/datafile/fda_ts.261.821741495 RECID=8 STAMP=821749350


datafile 2 switched to datafile copy
input datafile copy RECID=1 STAMP=821749350 file name=+DATA/orcl3/datafile/sysaux.265.821741633

datafile 3 switched to datafile copy
input datafile copy RECID=2 STAMP=821749350 file name=+DATA/orcl3/datafile/undotbs1.263.821741547

datafile 4 switched to datafile copy
input datafile copy RECID=3 STAMP=821749350 file name=+DATA/orcl3/datafile/users.262.821741547

datafile 5 switched to datafile copy
input datafile copy RECID=4 STAMP=821749350 file name=+DATA/orcl3/datafile/example.264.821741549

datafile 6 switched to datafile copy
input datafile copy RECID=5 STAMP=821749350 file name=+DATA/orcl3/datafile/demots1.258.821741491

datafile 7 switched to datafile copy
input datafile copy RECID=6 STAMP=821749350 file name=+DATA/orcl3/datafile/frankts.260.821741495

datafile 8 switched to datafile copy
input datafile copy RECID=7 STAMP=821749350 file name=+DATA/orcl3/datafile/index_ts.259.821741493

datafile 10 switched to datafile copy
input datafile copy RECID=8 STAMP=821749350 file name=+DATA/orcl3/datafile/fda_ts.261.821741495

contents of Memory Script:
{
   Alter clone database open resetlogs;
}
executing Memory Script

database opened
Finished Duplicate Db at 25-JUL-13
released channel: aux1
released channel: aux2

恭喜你如果整個過程都沒有錯誤,那你已經完成整個過程了




Step 11. 驗證1

[oracle@oracledb ~]$ sqlplus "/as sysdba"

SQL*Plus: Release 11.2.0.1.0 Production on Thu Jul 25 15:40:44 2013
Copyright (c) 1982, 2009, Oracle.  All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, Automatic Storage Management, OLAP, Data Mining
and Real Application Testing options

SQL> select count(*) from michael_qq;

  COUNT(*)
----------
     72715


Step 12. 驗證2
[oracle@oracleEXdb ~]$ rman target /
Recovery Manager: Release 11.2.0.1.0 - Production on Fri Jul 26 00:10:04 2013
Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
connected to target database: ORCL3 (DBID=752858017) 
db name與DBID也都不一樣了


RMAN> report schema;

using target database control file instead of recovery catalog
Report of database schema for database with db_unique_name ORCL3

List of Permanent Datafiles
===========================
File Size(MB) Tablespace           RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1    840      SYSTEM               ***     +DATA/orcl3/datafile/system.266.821741633
2    800      SYSAUX               ***     +DATA/orcl3/datafile/sysaux.265.821741633
3    325      UNDOTBS1             ***     +DATA/orcl3/datafile/undotbs1.263.821741547
4    120      USERS                ***     +DATA/orcl3/datafile/users.262.821741547
5    100      EXAMPLE              ***     +DATA/orcl3/datafile/example.264.821741549
6    100      DEMOTS1              ***     +DATA/orcl3/datafile/demots1.258.821741491
7    100      FRANKTS              ***     +DATA/orcl3/datafile/frankts.260.821741495
8    100      INDEX_TS             ***     +DATA/orcl3/datafile/index_ts.259.821741493
10   100      FDA_TS               ***     +DATA/orcl3/datafile/fda_ts.261.821741495

List of Temporary Files
=======================
File Size(MB) Tablespace           Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1    3482     TEMP                 32767       +DATA/orcl3/tempfile/temp.271.821749413


****如果您喜歡我的內容請給我一點鼓勵,當然如果我的內容不好
    也請您給予寶貴建議以做為檢討的基礎****

沒有留言:

張貼留言