程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> Oracle數據庫 >> Oracle教程 >> oracle11gRMAN:ActiveDatabaseDuplicationforstandbydatabase創建dg命令解讀

oracle11gRMAN:ActiveDatabaseDuplicationforstandbydatabase創建dg命令解讀

編輯:Oracle教程

oracle11gRMAN:ActiveDatabaseDuplicationforstandbydatabase創建dg命令解讀


基於生產的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

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved