RMAN duplicat database

huzhichengforce發表於2014-07-30
先在備庫裡面安裝好資料庫軟體既可
1、11G 線上複製資料庫流程很簡單
  1.1 主庫生成pfile 傳送到備庫
  1.2 主庫的密碼檔案傳送到備庫
  1.3 配置好網路監聽
  1.4 開始複製資料庫
2、實際操作步驟
  2.1 
  主庫建立pfile 給備庫使用
  sql>create pfile='/u01/init.ora' from spfile
  傳送到備庫
  scp /u01/init.ora:root@192.168.88.16:/u01/init.ora  -----可以存放在任何oracle 訪問的目錄 但是要自己能夠記得 到時候startup 的時候需要使用
  傳送密碼檔案給備庫
  在$ORACLE_HOME/dbs 下找到 orapwsid 的檔案傳送到備庫的 $ORACLE_HOME/dbs 下面
  在備庫編輯init.ora 用作備庫的初始化檔案
  這是編輯後的檔案
*.audit_file_dest='/u01/admin/orcl/adump'
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.control_files='/u01/oradata/orcl/control01.ctl','/u01/flash_recovery_area/orcl/control02.ctl','/u01/oradata/orcl/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='orcl'
*.db_recovery_file_dest='/u01/flash_recovery_area'
*.db_recovery_file_dest_size=4070572032
*.diagnostic_dest='/u01'
*.memory_target=977272832
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.star_transformation_enabled='TRUE'
*.undo_tablespace='UNDOTBS1'
db_file_name_convert=('/u01/oradata/og1/','/u01/oradata/orcl/','/u01/oracle/dbs/','/u01/oradata/orcl/')
log_file_name_convert=('/u01/oradata/og1/','/u01/oradata/orcl')
這裡只改幾個引數
*.audit_file_dest---這裡我們要建立幾個目錄/u01/admin/orcl/adump 資料庫軟體裝好後 ORACLE_BASE 下面是沒有admin 這個目錄的 需要我們自己建立
*.control_files--- 控制檔案這裡我們也要建立一個資料夾/u01/oradata/orcl/
*.db_name=
*.db_recovery_file_dest--- 也要建立目錄
db_file_name_convert---- 這裡DB_FILE_NAME_CONVERT DB_FILE_NAME_CONVERT = 'string1' , 'string2' , 'string3' , 'string4' 
string1 is the pattern of the primary database filename
string2 is the pattern of the standby database filename
string3 is the pattern of the primary database filename
string4 is the pattern of the standby database filename---- 例如 我主庫有好幾個資料夾 放資料檔案  
log_file_name_convert----存放redo 日誌檔案地方也要建立目錄
總結下: 由於我們備庫只安裝了軟體沒有建立例項 所以有些目錄是沒有的 需要我們自己建立  也就是說上面使用到的目錄 全部要在備庫中先建立好 並且 許可權給 ORACLE 使用者
3、配置網路監聽
主庫listener.ora 靜態監聽格式如下
LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = ogg1.localdomain)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )


SID_LIST_LISTENER =
  (SID_LIST =
(SID_DESC =
(ORACLE_HOME = /u01/oracle)
(SID_NAME =og1)
)
(SID_DESC =
(ORACLE_HOME = /u01/oracle)
(SID_NAME =og1)
)
  )




ADR_BASE_LISTENER = /u01




備庫:listener.ora
SID_LIST_LISTENER =
  (SID_LIST =
(SID_DESC =
(ORACLE_HOME = /u01/oracle)
(SID_NAME =orcl)
)
(SID_DESC =
(ORACLE_HOME = /u01/oracle)
(SID_NAME =orcl)
)
  )
LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = backup.localdomain)(PORT = 1521))
    )
  )


ADR_BASE_LISTENER = /u01
lsnrctl stop /start 重啟監聽
4、複製資料庫
在備庫
  rman target sys/oracle@og1 auxiliary sys/oracle@orcl
  注意sys/oracle@og1 為連線源庫
      sys/oracle@orcl為連線本機也就是備庫
      rman>duplicate target database to orcl from active database;
       duplicate target database to orcl from active database;


Starting Duplicate Db at 30-JUL-14
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=18 device type=DISK


contents of Memory Script:
{
   sql clone "create spfile from memory";
}
executing Memory Script


sql statement: create spfile from memory


contents of Memory Script:
{
   shutdown clone immediate;
   startup clone nomount;
}
executing Memory Script


Oracle instance shut down


connected to auxiliary database (not started)
Oracle instance started


Total System Global Area     972898304 bytes


Fixed Size                     2219272 bytes
Variable Size                570426104 bytes
Database Buffers             394264576 bytes
Redo Buffers                   5988352 bytes


contents of Memory Script:
{
   sql clone "alter system set  db_name = 
 ''OG1'' comment=
 ''Modified by RMAN duplicate'' scope=spfile";
   sql clone "alter system set  db_unique_name = 
 ''ORCL'' comment=
 ''Modified by RMAN duplicate'' scope=spfile";
   shutdown clone immediate;
   startup clone force nomount
   backup as copy current controlfile auxiliary format  '/u01/oradata/orcl/control01.ctl';
   restore clone controlfile to  '/u01/flash_recovery_area/orcl/control02.ctl' from 
 '/u01/oradata/orcl/control01.ctl';
   restore clone controlfile to  '/u01/oradata/orcl/control02.ctl' from 
 '/u01/oradata/orcl/control01.ctl';
   alter clone database mount;
}
executing Memory Script


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


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


Oracle instance shut down


Oracle instance started


Total System Global Area     972898304 bytes


Fixed Size                     2219272 bytes
Variable Size                570426104 bytes
Database Buffers             394264576 bytes
Redo Buffers                   5988352 bytes


Starting backup at 30-JUL-14
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=42 device type=DISK
channel ORA_DISK_1: starting datafile copy
copying current control file
output file name=/u01/oracle/dbs/snapcf_og1.f tag=TAG20140730T221208 RECID=4 STAMP=854316729
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
Finished backup at 30-JUL-14


Starting restore at 30-JUL-14
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=19 device type=DISK


channel ORA_AUX_DISK_1: copied control file copy
Finished restore at 30-JUL-14


Starting restore at 30-JUL-14
using channel ORA_AUX_DISK_1


channel ORA_AUX_DISK_1: copied control file copy
Finished restore at 30-JUL-14


database mounted


contents of Memory Script:
{
   set newname for datafile  1 to 
 "/u01/oradata/orclsystem01.dbf";
   set newname for datafile  2 to 
 "/u01/oradata/orclsysaux01.dbf";
   set newname for datafile  3 to 
 "/u01/oradata/orclundotbs01.dbf";
   set newname for datafile  4 to 
 "/u01/oradata/orclusers01.dbf";
   set newname for datafile  5 to 
 "/u01/oradata/orcloggfile.dbf";
   set newname for datafile  6 to 
 "/u01/oradata/orclggddl.dbf";
   backup as copy reuse
   datafile  1 auxiliary format 
 "/u01/oradata/orclsystem01.dbf"   datafile 
 2 auxiliary format 
 "/u01/oradata/orclsysaux01.dbf"   datafile 
 3 auxiliary format 
 "/u01/oradata/orclundotbs01.dbf"   datafile 
 4 auxiliary format 
 "/u01/oradata/orclusers01.dbf"   datafile 
 5 auxiliary format 
 "/u01/oradata/orcloggfile.dbf"   datafile 
 6 auxiliary format 
 "/u01/oradata/orclggddl.dbf"   ;
   sql 'alter system archive log current';
}
executing Memory Script


executing command: SET NEWNAME


executing command: SET NEWNAME


executing command: SET NEWNAME


executing command: SET NEWNAME


executing command: SET NEWNAME


executing command: SET NEWNAME


Starting backup at 30-JUL-14
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00002 name=/u01/oradata/og1/sysaux01.dbf
output file name=/u01/oradata/orclsysaux01.dbf tag=TAG20140730T221219
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:45
channel ORA_DISK_1: starting datafile copy
input datafile file number=00001 name=/u01/oradata/og1/system01.dbf
output file name=/u01/oradata/orclsystem01.dbf tag=TAG20140730T221219
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:35
channel ORA_DISK_1: starting datafile copy
input datafile file number=00006 name=/u01/oracle/dbs/ggddl.dbf
output file name=/u01/oradata/orclggddl.dbf tag=TAG20140730T221219
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting datafile copy
input datafile file number=00003 name=/u01/oradata/og1/undotbs01.dbf
output file name=/u01/oradata/orclundotbs01.dbf tag=TAG20140730T221219
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting datafile copy
input datafile file number=00005 name=/u01/oradata/og1/oggfile.dbf
output file name=/u01/oradata/orcloggfile.dbf tag=TAG20140730T221219
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=/u01/oradata/og1/users01.dbf
output file name=/u01/oradata/orclusers01.dbf tag=TAG20140730T221219
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 30-JUL-14


sql statement: alter system archive log current


contents of Memory Script:
{
   backup as copy reuse
   archivelog like  "/u01/flash_recovery_area/OG1/archivelog/2014_07_30/o1_mf_1_172_9xkzg3ob_.arc" auxiliary format 
 "/u01/flash_recovery_area/ORCL/archivelog/2014_07_30/o1_mf_1_172_%u_.arc"   ;
   catalog clone recovery area;
   switch clone datafile all;
}
executing Memory Script


Starting backup at 30-JUL-14
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log copy
input archived log thread=1 sequence=172 RECID=168 STAMP=854316868
output file name=/u01/flash_recovery_area/ORCL/archivelog/2014_07_30/o1_mf_1_172_1ipenlq4_.arc RECID=0 STAMP=0
channel ORA_DISK_1: archived log copy complete, elapsed time: 00:00:03
Finished backup at 30-JUL-14


searching for all files in the recovery area


List of Files Unknown to the Database
=====================================
File Name: /u01/flash_recovery_area/ORCL/archivelog/2014_07_30/o1_mf_1_172_1ipenlq4_.arc
cataloging files...
cataloging done


List of Cataloged Files
=======================
File Name: /u01/flash_recovery_area/ORCL/archivelog/2014_07_30/o1_mf_1_172_1ipenlq4_.arc


datafile 1 switched to datafile copy
input datafile copy RECID=4 STAMP=854316939 file name=/u01/oradata/orclsystem01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=5 STAMP=854316939 file name=/u01/oradata/orclsysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=6 STAMP=854316939 file name=/u01/oradata/orclundotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=7 STAMP=854316940 file name=/u01/oradata/orclusers01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=8 STAMP=854316940 file name=/u01/oradata/orcloggfile.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=9 STAMP=854316940 file name=/u01/oradata/orclggddl.dbf


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


executing command: SET until clause


Starting recover at 30-JUL-14
using channel ORA_AUX_DISK_1


starting media recovery


archived log for thread 1 with sequence 172 is already on disk as file /u01/flash_recovery_area/ORCL/archivelog/2014_07_30/o1_mf_1_172_1ipenlq4_.arc
archived log file name=/u01/flash_recovery_area/ORCL/archivelog/2014_07_30/o1_mf_1_172_1ipenlq4_.arc thread=1 sequence=172
media recovery complete, elapsed time: 00:00:00
Finished recover at 30-JUL-14


contents of Memory Script:
{
   shutdown clone immediate;
   startup clone nomount;
   sql clone "alter system set  db_name = 
 ''ORCL'' 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     972898304 bytes


Fixed Size                     2219272 bytes
Variable Size                570426104 bytes
Database Buffers             394264576 bytes
Redo Buffers                   5988352 bytes


sql statement: alter system set  db_name =  ''ORCL'' 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     972898304 bytes


Fixed Size                     2219272 bytes
Variable Size                570426104 bytes
Database Buffers             394264576 bytes
Redo Buffers                   5988352 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "ORCL" RESETLOGS ARCHIVELOG 
  MAXLOGFILES     16
  MAXLOGMEMBERS      3
  MAXDATAFILES      100
  MAXINSTANCES     8
  MAXLOGHISTORY      292
 LOGFILE
  GROUP  1 ( '/u01/oradata/orclredo01.log' ) SIZE 50 M  REUSE,
  GROUP  2 ( '/u01/oradata/orclredo02.log' ) SIZE 50 M  REUSE,
  GROUP  3 ( '/u01/oradata/orclredo03.log' ) SIZE 50 M  REUSE
 DATAFILE
  '/u01/oradata/orclsystem01.dbf'
 CHARACTER SET AL32UTF8




contents of Memory Script:
{
   set newname for tempfile  1 to 
 "/u01/oradata/orcltemp01.dbf";
   switch clone tempfile all;
   catalog clone datafilecopy  "/u01/oradata/orclsysaux01.dbf", 
 "/u01/oradata/orclundotbs01.dbf", 
 "/u01/oradata/orclusers01.dbf", 
 "/u01/oradata/orcloggfile.dbf", 
 "/u01/oradata/orclggddl.dbf";
   switch clone datafile all;
}
executing Memory Script


executing command: SET NEWNAME


renamed tempfile 1 to /u01/oradata/orcltemp01.dbf in control file


cataloged datafile copy
datafile copy file name=/u01/oradata/orclsysaux01.dbf RECID=1 STAMP=854316955
cataloged datafile copy
datafile copy file name=/u01/oradata/orclundotbs01.dbf RECID=2 STAMP=854316956
cataloged datafile copy
datafile copy file name=/u01/oradata/orclusers01.dbf RECID=3 STAMP=854316956
cataloged datafile copy
datafile copy file name=/u01/oradata/orcloggfile.dbf RECID=4 STAMP=854316956
cataloged datafile copy
datafile copy file name=/u01/oradata/orclggddl.dbf RECID=5 STAMP=854316956


datafile 2 switched to datafile copy
input datafile copy RECID=1 STAMP=854316955 file name=/u01/oradata/orclsysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=2 STAMP=854316956 file name=/u01/oradata/orclundotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=3 STAMP=854316956 file name=/u01/oradata/orclusers01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=4 STAMP=854316956 file name=/u01/oradata/orcloggfile.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=5 STAMP=854316956 file name=/u01/oradata/orclggddl.dbf


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


database opened
Finished Duplicate Db at 30-JUL-14

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26764973/viewspace-1242461/,如需轉載,請註明出處,否則將追究法律責任。

相關文章