首页 > 代码库 > Oracle 11 g duplicate功能_复制dataguard备库
Oracle 11 g duplicate功能_复制dataguard备库
Qracle 11g duplicate功能
不用备份源库,通过网络复制出standby库
1.在standby上grid用户配置listener
注意是指定oracle用户的家目录:
监听状态:
[grid@dg ~]$lsnrctl
LSNRCTL for Linux:Version 11.2.0.4.0 - Production on 19-MAY-2014 18:46:15
Copyright (c)1991, 2013, Oracle. All rights reserved.
Welcome toLSNRCTL, type "help" for information.
LSNRCTL> status
Connecting to(DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of theLISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version11.2.0.4.0 - Production
Start Date 19-MAY-2014 17:24:26
Uptime 0 days 1 hr. 21 min. 53 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener ParameterFile /u01/app/11.2.0/grid/network/admin/listener.ora
Listener LogFile /u01/app/grid/diag/tnslsnr/dg/listener/alert/log.xml
ListeningEndpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=dg.cowell.com)(PORT=1521)))
ServicesSummary...
Service"+ASM" has 1 instance(s).
Instance "+ASM", status READY, has1 handler(s) for this service...
Service"standby" has 2 instance(s).
Instance "standby", status UNKNOWN,has 1 handler(s) for this service...
Instance "standby", status READY,has 1 handler(s) for this service...
The commandcompleted successfully
standby的参数文件:
standby.__db_cache_size=171966464
standby.__java_pool_size=4194304
standby.__large_pool_size=16777216
standby.__oracle_base=‘/u01/app/oracle‘#ORACLE_BASEset from environment
standby.__pga_aggregate_target=289406976
standby.__sga_target=360710144
standby.__shared_io_pool_size=0
standby.__shared_pool_size=163577856
standby.__streams_pool_size=0
*.audit_file_dest=‘/u01/app/oracle/admin/standby/adump‘
*.audit_trail=‘db‘
*.cluster_database=false
*.compatible=‘11.2.0.4.0‘
*.control_files=‘+DGDATA/standby/controlfile/standby.ctl01‘,‘+DGDATA/standby/controlfile/standby.ctl02‘
*.db_block_size=8192
*.db_create_file_dest=‘+DGDATA‘
*.db_domain=‘‘
*.db_name=‘ORCL‘
*.db_recovery_file_dest=‘+DGARCH‘
*.db_recovery_file_dest_size=4622123008
*.diagnostic_dest=‘/u01/app/oracle‘
*.dispatchers=‘(PROTOCOL=TCP)(SERVICE=standbyXDB)‘
*.log_archive_format=‘%t_%s_%r.arc‘
*.memory_target=834666496
*.nls_language=‘SIMPLIFIEDCHINESE‘
*.nls_territory=‘CHINA‘
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile=‘exclusive‘
*.sga_max_size=629145600
*.undo_tablespace=‘UNDOTBS1‘
*.db_unique_name=‘standby‘
#*.db_file_name_convert=‘+DATA/ORCL/DATAFILE‘,‘+DGDATA/standby/datafile/‘,‘+DATA/ORCL/TEMPFILE‘,‘+DGDATA/standby/tempfile/‘
#*.log_file_name_convert=‘+DATA/ORCL/ONLINELOG/‘,‘+DGDATA/standby/onlinelog/‘不用指定转换目录,否则会以下错误:
Starting restore at 2014-05-19 17:53:12
using channel ORA_AUX_DISK_1
DBGSQL: TARGET> begin :fhdbi :=dbms_rcvcat.getDbid; end;
DBGSQL: sqlcode = 6550
DBGSQL: B :fhdbi = 32767
RMAN-00571:===========================================================
RMAN-00569: =============== ERRORMESSAGE STACK FOLLOWS ===============
RMAN-00571:===========================================================
RMAN-03002: failure ofDuplicate Db command at 05/19/2014 17:53:12
RMAN-05501: abortingduplication of target database
RMAN-03015: error occurred instored script Memory Script
ORA-06550: line 1, column 17:
PLS-00201: identifier‘DBMS_RCVCAT.GETDBID‘ must be declared
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
*.log_archive_config=‘dg_config=(ORCL,standby)‘
*.log_archive_dest_1=‘location=+DGDATA/standby/archivelogvalid_for=(all_logfiles,all_roles) db_unique_name=standby‘
*.log_archive_dest_2=‘service=ORCLlgwr async valid_for=(online_logfiles,primary_role) db_unique_name=ORCL‘
*.log_archive_dest_state_1=enable
*.log_archive_dest_state_2=enable
*.log_archive_max_processes=10
*.fal_server=ORCL
*.fal_client=standby
*.standby_file_management=auto
用参数文件把standby库启到nomount:
SQL> startupnomount;
ORACLE instancestarted.
Total SystemGlobal Area 626327552 bytes
Fixed Size 2255832 bytes
Variable Size 373294120 bytes
Database Buffers 243269632 bytes
Redo Buffers 7507968 bytes
在主库上执行复制:
[oracle@node2 ~]$rman target / auxiliary sys/123123@192.168.1.220/standby
Recovery Manager:Release 11.2.0.4.0 - Production on Mon May 19 18:07:03 2014
Copyright (c)1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected totarget database: ORCL (DBID=1375715887)
connected toauxiliary database: ORCL (not mounted)
RMAN> duplicatetarget database for standby from active database nofilenamecheck;
Starting DuplicateDb at 2014-05-19 18:07:10
using targetdatabase control file instead of recovery catalog
allocated channel:ORA_AUX_DISK_1
channelORA_AUX_DISK_1: SID=131 device type=DISK
contents of MemoryScript:
{
backup as copy reuse
targetfile ‘/u01/app/oracle/product/11.2.0/db_1/dbs/orapwORCL2‘ auxiliary format
‘/u01/app/oracle/product/11.2.0/db_1/dbs/orapwstandby‘ ;
}
executing MemoryScript
Starting backup at2014-05-19 18:07:13
allocated channel:ORA_DISK_1
channelORA_DISK_1: SID=203 instance=ORCL2 device type=DISK
Finished backup at2014-05-19 18:07:15
contents of MemoryScript:
{
backup as copy current controlfile forstandby auxiliary format ‘+DGDATA/standby/controlfile/standby.ctl01‘;
restore clone controlfile to ‘+DGDATA/standby/controlfile/standby.ctl02‘from
‘+DGDATA/standby/controlfile/standby.ctl01‘;
}
executing MemoryScript
Starting backup at2014-05-19 18:07:16
using channel ORA_DISK_1
channelORA_DISK_1: starting datafile copy
copying standbycontrol file
output filename=/u01/app/oracle/product/11.2.0/db_1/dbs/snapcf_ORCL2.ftag=TAG20140519T180716 RECID=7 STAMP=847994856
channelORA_DISK_1: datafile copy complete, elapsed time: 00:00:07
Finished backup at2014-05-19 18:07:38
Starting restoreat 2014-05-19 18:07:39
using channelORA_AUX_DISK_1
channelORA_AUX_DISK_1: copied control file copy
Finished restoreat 2014-05-19 18:07:42
contents of MemoryScript:
{
sql clone ‘alter database mount standbydatabase‘;
}
executing MemoryScript
sql statement:alter database mount standby database
contents of MemoryScript:
{
set newname for clone tempfile 1 to new;
switch clone tempfile all;
set newname for clone datafile 1 to new;
set newname for clone datafile 2 to new;
set newname for clone datafile 3 to new;
set newname for clone datafile 4 to new;
set newname for clone datafile 5 to new;
set newname for clone datafile 6 to new;
set newname for clone datafile 7 to new;
backup as copy reuse
datafile 1 auxiliary format new
datafile 2 auxiliary format new
datafile 3 auxiliary format new
datafile 4 auxiliary format new
datafile 5 auxiliary format new
datafile 6 auxiliary format new
datafile 7 auxiliary format new
;
sql ‘alter system archive log current‘;
}
executing MemoryScript
executing command:SET NEWNAME
renamed tempfile 1to +DGDATA in control file
executing command:SET NEWNAME
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 at2014-05-19 18:07:53
using channelORA_DISK_1
channelORA_DISK_1: starting datafile copy
input datafilefile number=00007 name=+DATA/orcl/datafile/plsql.268.847985273
output filename=+DGDATA/standby/datafile/plsql.346.847994875 tag=TAG20140519T180754
channelORA_DISK_1: datafile copy complete, elapsed time: 00:05:48
channelORA_DISK_1: starting datafile copy
input datafilefile number=00001 name=+DATA/orcl/datafile/system.276.847934873
output filename=+DGDATA/standby/datafile/system.348.847995227 tag=TAG20140519T180754
channelORA_DISK_1: datafile copy complete, elapsed time: 00:01:55
channelORA_DISK_1: starting datafile copy
input datafilefile number=00002 name=+DATA/orcl/datafile/sysaux.277.847934879
output filename=+DGDATA/standby/datafile/sysaux.349.847995341 tag=TAG20140519T180754
channel ORA_DISK_1:datafile copy complete, elapsed time: 00:01:46
channelORA_DISK_1: starting datafile copy
input datafilefile number=00005 name=+DATA/orcl/datafile/example.284.847935325
output filename=+DGDATA/standby/datafile/example.350.847995447 tag=TAG20140519T180754
channelORA_DISK_1: datafile copy complete, elapsed time: 00:01:05
channelORA_DISK_1: starting datafile copy
input datafilefile number=00003 name=+DATA/orcl/datafile/undotbs1.278.847934879
output filename=+DGDATA/standby/datafile/undotbs1.383.847995513 tag=TAG20140519T180754
channelORA_DISK_1: datafile copy complete, elapsed time: 00:00:25
channelORA_DISK_1: starting datafile copy
input datafilefile number=00006 name=+DATA/orcl/datafile/undotbs2.285.847936921
output file name=+DGDATA/standby/datafile/undotbs2.313.847995539tag=TAG20140519T180754
channelORA_DISK_1: datafile copy complete, elapsed time: 00:00:07
channelORA_DISK_1: starting datafile copy
input datafilefile number=00004 name=+DATA/orcl/datafile/users.279.847934881
output filename=+DGDATA/standby/datafile/users.325.847995547 tag=TAG20140519T180754
channelORA_DISK_1: datafile copy complete, elapsed time: 00:00:07
Finished backup at2014-05-19 18:19:14
sql statement:alter system archive log current
contents of MemoryScript:
{
switch clone datafile all;
}
executing MemoryScript
datafile 1switched to datafile copy
input datafilecopy RECID=7 STAMP=847995571 filename=+DGDATA/standby/datafile/system.348.847995227
datafile 2switched to datafile copy
input datafilecopy RECID=8 STAMP=847995571 filename=+DGDATA/standby/datafile/sysaux.349.847995341
datafile 3switched to datafile copy
input datafilecopy RECID=9 STAMP=847995571 filename=+DGDATA/standby/datafile/undotbs1.383.847995513
datafile 4switched to datafile copy
input datafilecopy RECID=10 STAMP=847995571 filename=+DGDATA/standby/datafile/users.325.847995547
datafile 5switched to datafile copy
input datafilecopy RECID=11 STAMP=847995571 filename=+DGDATA/standby/datafile/example.350.847995447
datafile 6switched to datafile copy
input datafilecopy RECID=12 STAMP=847995571 filename=+DGDATA/standby/datafile/undotbs2.313.847995539
datafile 7switched to datafile copy
input datafilecopy RECID=13 STAMP=847995572 file name=+DGDATA/standby/datafile/plsql.346.847994875
Finished DuplicateDb at 2014-05-19 18:21:07
完成后,standby库被mounted:
以只读的形式打开standby库:
本文出自 “热爱生活” 博客,请务必保留此出处http://7642644.blog.51cto.com/7632644/1539702