oracle 11g RMAN:Active Database Duplication for standby database 建立dg 命令解讀,rmanduplication

來源:互聯網
上載者:User

oracle 11g RMAN:Active Database Duplication for standby database 建立dg 命令解讀,rmanduplication
基於生產的duplicate 複製,如果事先沒有手動設定pfile(設定記憶體,進程,dg相關配置參數,資料庫相關路徑參數)則會出現各種參數無法轉換的問題;
因為duplicate 會從生產自動拷貝pfile,控制檔案,密碼檔案過來,如果主庫和備庫環境不一樣(資料庫軟體路徑,資料檔案儲存路徑)
如果沒在duplicate的命令中完整指定新環境備庫的各種參數涉及路徑,及轉換參數,就會預設使用從主庫拷貝過來的spfile中的參數設定(會忽略oracle 自訂的的預設配置:比如adr 預設會放在ORACLE_BASE下,所有參數配置一切以主庫拷貝過來的spfile 為準);

鑒於那些對原來主庫環境,和oracle資料庫參數不是特別瞭解的同學,就不建議使用這種配置了,折騰!

-------注意如果=備庫和主庫的$ORACLE_BASE/$ORACLE_HOME/資料存放路徑 任意一個不同,則必須配置一下的參數 
run {
allocate channel prmy1 type disk;
allocate channel prmy2 type disk;
allocate channel prmy3 type disk;
allocate channel prmy4 type disk;
allocate auxiliary channel stby type disk;

duplicate target database for standby from active database
dorecover
spfile
  parameter_value_convert 'ora11g','lixora'
  set db_unique_name='orcl'
  set standby_file_management='AUTO'
  SET FAL_SERVER="ora11g" 
  SET LOG_ARCHIVE_DEST_1='LOCATION=/oracle/app/oracle/oradata/arch VALID_FOR=(ALL_LOGFILE,ALL_ROLE) DB_UNIQUE_NAME=lixora'
  set log_archive_dest_2='service=ora11g ASYNC valid_for=(ONLINE_LOGFILE,PRIMARY_ROLE) db_unique_name=ora11g'    
  SET CONTROL_FILES '/oracle/app/oracle/oradata/control01.ctl'
  set diagnostic_dest='/oracle/app/oracle'
  set audit_file_dest='/oracle/app/oracle'
  set DB_FILE_NAME_CONVERT='/u01/app/ora11/oradata/ORA11G/datafile/','/oracle/app/oracle/oradata/'
  SET LOG_FILE_NAME_CONVERT '/u01/app/ora11/oradata/ORA11G/onlinelog/', '/oracle/app/oracle/oradata/'   
  set db_create_file_dest='/oracle/app/oracle/oradata/'
  set db_recovery_file_dest='/oracle/app/oracle/oradata/'
  #SET SGA_MAX_SIZE 200M               
  #SET SGA_TARGET 185M
NOFILENAMECHECK;
}


這些個存放目錄:閃回區目錄,adr目錄,審計日誌目錄, Oracle-managed 資料檔案目錄 等等,一定要注意啊

------------這裡解釋使用類上述命令執行後的日子輸出,來理解使用上述命令初始化備庫的原理:

$rman target sys/sys@chicago auxiliary sys/sys@boston
connected to target database: CHICAGO (DBID=761464750)
connected to auxiliary database: CHICAGO (not mounted)
RMAN> run {
allocate channel prmy1 type disk;
allocate channel prmy2 type disk;
allocate channel prmy3 type disk;
allocate channel prmy4 type disk;
allocate auxiliary channel stby type disk;
duplicate target database for standby from active database
spfile
  parameter_value_convert 'chicago','boston'
  set db_unique_name='boston'
  set db_file_name_convert='/chicago/','/boston/'
  set log_file_name_convert='/chicago/','/boston/'
  set control_files='/u01/app/oracle/oradata/control01.ctl'
  set log_archive_max_processes='5'
  set fal_client='boston'
  set fal_server='chicago'
  set standby_file_management='AUTO'
  set log_archive_config='dg_config=(chicago,boston)'
  set log_archive_dest_2='service=chicago ASYNCvalid_for=(ONLINE_LOGFILE,PRIMARY_ROLE) db_unique_name=chicago'
;
}

using target database control file instead of recovery catalog
allocated channel: prmy1                    ---------這個就不多說了:分配通道
channel prmy1: SID=147 device type=DISK
allocated channel: prmy2
channel prmy2: SID=130 device type=DISK
allocated channel: prmy3
channel prmy3: SID=137 device type=DISK
allocated channel: prmy4
channel prmy4: SID=170 device type=DISK
allocated channel: stby
channel stby: SID=98 device type=DISK


Starting Duplicate Db at 19-MAY-08
contents of Memory Script:
{
backup as copy reuse      -------------拷貝主庫密碼檔案,spfile參數檔案
file '/u02/app/oracle/product/11.1.0/db_1/dbs/orapwcore' auxiliary format'/u02/app/oracle/product/11.1.0/db_1/dbs/orapwcore1' 
file'/u02/app/oracle/product/11.1.0/db_1/dbs/spfilecore.ora' auxiliary format'/u02/app/oracle/product/11.1.0/db_1/dbs/spfilecore1.ora' ;
sql clone "alter system set spfile= ''/u02/app/oracle/product/11.1.0/db_1/dbs/spfilecore1.ora''";
}
executing Memory Script    ----

Starting backup at 19-MAY-08
Finished backup at 19-MAY-08

sql statement: alter system set spfile= ''/u02/app/oracle/product/11.1.0/db_1/dbs/spfilecore1.ora''   -----在修改

contents of Memory Script:  -----------------------這雷根據設定我們在run 指令碼中spfile 標註下的一些參數設定, RMAN會自動產生以下指令碼
{
sql clone "alter system set audit_file_dest =''/u02/app/oracle/admin/boston/adump'' comment='''' scope=spfile";
sql clone "alter system set dispatchers =''(PROTOCOL=TCP) (SERVICE=core1XDB)'' comment='''' scope=spfile";
sql clone "alter system set log_archive_dest_2 =''service=core11 arch async VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) db_unique_name=boston'' comment='''' 

scope=spfile";
sql clone "alter system set db_unique_name =''boston'' comment='''' scope=spfile";
sql clone "alter system set db_file_name_convert =''/chicago/'', ''/boston/'' comment='''' scope=spfile";
sql clone "alter system set log_file_name_convert =''/chicago/'', ''/boston/'' comment='''' scope=spfile";
sql clone "alter system set control_files =''/u01/app/oracle/oradata/control01.ctl'' comment='''' scope=spfile";
sql clone "alter system set log_archive_max_processes =5 comment='''' scope=spfile";
sql clone "alter system set fal_client =''boston'' comment='''' scope=spfile";
sql clone "alter system set fal_server =''chicago'' comment='''' scope=spfile";
sql clone "alter system set standby_file_management =''AUTO'' comment='''' scope=spfile";
sql clone "alter system set log_archive_config =''dg_config=(chicago,boston)'' comment='''' scope=spfile";
sql clone "alter system set log_archive_dest_2 =''service=chicago ASYNC valid_for=(ONLINE_LOGFILE,PRIMARY_ROLE) db_unique_name=chicago'' comment='''' scope=spfile";
shutdown clone immediate;   ----------------因為在使用這種方式建立備庫時,我們只需要配置一個包含db_name,db_unique_name,block_size 這個三個參數,並把備庫啟動到 nomount 狀態下,主要的目的就是為了讓rman拷貝主庫的spfile 和密碼檔案
startup clone nomount ;
}
executing Memory Script


sql statement: alter system set audit_file_dest = ''/u02/app/oracle/admin/boston/adump'' comment= '''' scope=spfile
sql statement: alter system set dispatchers = ''(PROTOCOL=TCP) (SERVICE=core1XDB)'' comment= '''' scope=spfile
sql statement: alter system set log_archive_dest_2 = ''service=core11 arch async VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) db_unique_name=boston'' comment= '''' 


scope=spfile
sql statement: alter system set db_unique_name = ''boston'' comment= '''' scope=spfile
sql statement: alter system set db_file_name_convert = ''/chicago/'', ''/boston/'' comment= '''' scope=spfile
sql statement: alter system set log_file_name_convert = ''/chicago/'', ''/boston/'' comment= '''' scope=spfile
sql statement: alter system set control_files = ''/u01/app/oracle/oradata/control01.ctl'' comment= '''' scope=spfile
sql statement: alter system set log_archive_max_processes = 5 comment= '''' scope=spfile
sql statement: alter system set fal_client = ''boston'' comment= '''' scope=spfile
sql statement: alter system set fal_server = ''chicago'' comment= '''' scope=spfile
sql statement: alter system set standby_file_management = ''AUTO'' comment= '''' scope=spfile
sql statement: alter system set log_archive_config = ''dg_config=(chicago,boston)'' comment= '''' scope=spfile
sql statement: alter system set log_archive_dest_2 = ''service=chicago ASYNC valid_for=(ONLINE_LOGFILE,PRIMARY_ROLE) db_unique_name=chicago'' comment= '''' 

scope=spfile

Oracle instance shut down    --------------這裡重啟是為了使用更新過的spfile

connected to auxiliary database (not started)
Oracle instance started

Total System Global Area 845348864 bytes

Fixed Size 1303188 bytes
Variable Size 482348396 bytes
Database Buffers 356515840 bytes
Redo Buffers 5181440 bytes
contents of Memory Script:  ---------------開始拷貝standby 控制檔案,並傳到備庫的相應位置
{
backup as copy current controlfile for standby auxiliary format '/u01/app/oracle/oradata/control01.ctl';
sql clone 'alter database mount standby database';
}
executing Memory Script

Starting backup at 19-MAY-08
channel prmy1: starting datafile copy
copying standby control file
output file name=/u02/app/oracle/product/11.1.0/db_1/dbs/snapcf_chicago.f tag=TAG20080519T173406 RECID=2 STAMP=655148053
channel prmy1: datafile copy complete, elapsed time: 00:00:03
Finished backup at 19-MAY-08
sql statement: alter database mount standby database    ----------------------mount 備庫,準備修改初始化的資料檔案路徑,並拷貝到備庫

contents of Memory Script:
{
set newname for tempfile 1 to"/u02/app/oracle/oradata/boston/temp01.dbf";
switch clone tempfile all;
set newname for datafile 1 to "/u02/app/oracle/oradata/boston/system01.dbf";
set newname for datafile 2 to "/u02/app/oracle/oradata/boston/sysaux01.dbf";
set newname for datafile 3 to "/u02/app/oracle/oradata/boston/undotbs01.dbf";
set newname for datafile 4 to "/u02/app/oracle/oradata/boston/users01.dbf";
backup as copy reuse
datafile 1 auxiliary format "/u02/app/oracle/oradata/boston/system01.dbf" 
datafile 2 auxiliary format "/u02/app/oracle/oradata/boston/sysaux01.dbf" 
datafile 3 auxiliary format "/u02/app/oracle/oradata/boston/undotbs01.dbf" 
datafile 4 auxiliary format "/u02/app/oracle/oradata/boston/users01.dbf" ;
sql 'alter system archive log current';
}
executing Memory Script

executing command: SET NEWNAME

renamed tempfile 1 to /u02/app/oracle/oradata/boston/temp01.dbf in control file

executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME

Starting backup at 19-MAY-08
channel prmy1: starting datafile copy
input datafile file number=00001 name=/u02/app/oracle/oradata/chicago/system01.dbf
channel prmy2: starting datafile copy
input datafile file number=00002 name=/u02/app/oracle/oradata/chicago/sysaux01.dbf
channel prmy3: starting datafile copy
input datafile file number=00003 name=/u02/app/oracle/oradata/chicago/undotbs01.dbf
channel prmy4: starting datafile copy
input datafile file number=00004 name=/u02/app/oracle/oradata/chicago/users01.dbf
output file name=/u02/app/oracle/oradata/boston/undotbs01.dbf tag=TAG20080519T173421 RECID=0 STAMP=0
channel prmy3: datafile copy complete, elapsed time: 00:00:24
output file name=/u02/app/oracle/oradata/boston/users01.dbf tag=TAG20080519T173421 RECID=0 STAMP=0
channel prmy4: datafile copy complete, elapsed time: 00:00:16
output file name=/u02/app/oracle/oradata/boston/system01.dbf tag=TAG20080519T173421 RECID=0 STAMP=0
channel prmy1: datafile copy complete, elapsed time: 00:02:32
output file name=/u02/app/oracle/oradata/boston/sysaux01.dbf tag=TAG20080519T173421 RECID=0 STAMP=0
channel prmy2: datafile copy complete, elapsed time: 00:02:32
Finished backup at 19-MAY-08

sql statement: alter system archive log current

contents of Memory Script:
{
switch clone datafile all;   ---------修改standby 控制檔案,更新standby 控制檔案中的新資料檔案路徑
}
executing Memory Script

datafile 1 switched to datafile copy
input datafile copy RECID=2 STAMP=655148231 file name=/u02/app/oracle/oradata/boston/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=3 STAMP=655148231 file name=/u02/app/oracle/oradata/boston/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=4 STAMP=655148231 file name=/u02/app/oracle/oradata/boston/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=5 STAMP=655148231 file name=/u02/app/oracle/oradata/boston/users01.dbf
Finished Duplicate Db at 19-MAY-08
released channel: prmy1
released channel: prmy2
released channel: prmy3
released channel: prmy4



到這裡備庫環境已經全部初始化完畢,免去了我們以前需要,手動在備庫配置pfile參數檔案,手動拷貝密碼檔案到備庫,建立standby控制並拷貝到備庫,拷貝資料檔案備份到備庫 等等步驟但是看到這裡,還是有個疑惑的oracle 是怎麼直接拷貝那些密碼檔案,參數檔案,控制檔案,資料檔案到備庫的?這裡猜測應該是調用了rman 某些介面,說的直白點就是和nbu 那些第三方資料備份軟體用的那一招,現在oracle自己覺得這些個介面也可以這麼用,於是乎在11g(11.1.0.6 開始) 中推出了 active—database duplicate  關於這個feature oracle官方是這麼講的:
Active database duplication copies the live target database over the network to the auxiliary destination and then creates the duplicate database.
The duplication work is performed by an auxiliary channel.This channel corresponds to a server session on the auxiliary instance on the auxiliary host.


以下為 Basic Steps to  ACTIVE database duplication 過程中rman乾的事情 :
As part of the duplicating operation, RMAN automates the following steps: 
1. Creates a control file for the duplicate database 
2. Restarts the auxiliary instance and mounts the duplicate control file 
3. Creates the duplicate datafiles and recovers them with incremental backups and archived redo logs. 
4. Opens the duplicate database with the RESETLOGS option 

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.