使用duplicate创建dataguard

   晚上花了很长时间用duplicate创建了一个DG。其实真个过程都是比较容易的,只是自己有些地方因为经常不小心搞错,导致花了比较久,简单记录下:

   要注意db_name必须要一样。其中主库是orcl,备库是orcm。

主库的listener.ora设置

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.21)(PORT = 1521))
    )
  )
                                                                                                                                                                                        
ADR_BASE_LISTENER = /u01/app/oracle
                                                                                                                                                                                        
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = orcl)
      (ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)
      (SID_NAME = orcl)
    )
  )


主库的initorcl.ora增加的内容

*.db_name='orcl'
*.db_unique_name='orcl_pd'
*.log_archive_config='dg_config=(orcl_pd,orcl_st)'
*.log_archive_dest_1='location=/u01/archivelog valid_for=(all_logfiles,all_roles) db_unique_name=orcl_pd'
*.log_archive_dest_2='service=orcl_st reopen=120 lgwr async valid_for=(online_logfiles,primary_role) db_unique_name=orcl_st'
*.log_archive_dest_state_1=enable
*.log_archive_dest_state_2=enable
*.standby_file_management='auto'
*.fal_server='orcl_st'
*.fal_client='orcl_pd'



备库的listener.ora设置

STENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.22)(PORT = 1521))
    )
  )
                                                                                                                                                                       
ADR_BASE_LISTENER = /u01/app/oracle
                                                                                                                                                                       
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = orcm)
      (ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)
      (SID_NAME = orcm)
    )
  )


备库的initorcm.ora的设置

*.db_name=orcl
*.control_files='/u01/app/oracle/oradata/orcm/control01.ctl', '/u01/app/oracle/oradata/orcm/control02.ctl',
'/u01/app/oracle/oradata/orcm/control03.ctl'
*.db_unique_name='orcl_st'
*.log_archive_config='dg_config=(orcl_pd,orcl_st)'
*.log_archive_dest_1='location=/u01/archivelog valid_for=(all_logfiles,all_roles) db_unique_name=orcl_st'
*.log_archive_dest_2='service=orcl_pd reopen=120 lgwr async valid_for=(online_logfiles,primary_role) db_unique_name=orcl_pd'
*.log_archive_dest_state_1=enable
*.log_archive_dest_state_2=enable
*.standby_file_management='auto'
*.fal_server='orcl_pd'
*.fal_client='orcl_st'
*.log_file_name_convert='/u01/app/oracle/oradata/orcl','/u01/app/oracle/oradata/orcm'
*.db_file_name_convert='/u01/app/oracle/oradata/orcl','/u01/app/oracle/oradata/orcm'


主库和备库的tnsnames.ora设置


ORCL_ST =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.22)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = orcm)
    )
  )
                                                                                                                                                                                                               
ORCL_PD =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.21)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = orcl)
    )
  )


最后贴一下成功的喜悦,希望可以帮助到大家:

Starting Duplicate Db at 18-JUN-13
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=20 device type=DISK
contents of Memory Script:
{
   backup as copy reuse
   targetfile  '/u01/app/oracle/product/11.2.0/db_1/dbs/orapworcl' auxiliary format
 '/u01/app/oracle/product/11.2.0/db_1/dbs/orapworcm'   ;
}
executing Memory Script
Starting backup at 18-JUN-13
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=41 device type=DISK
Finished backup at 18-JUN-13
contents of Memory Script:
{
   backup as copy current controlfile for standby auxiliary format  '/u01/app/oracle/oradata/orcm/control01.ctl';
   restore clone controlfile to  '/u01/app/oracle/oradata/orcm/control02.ctl' from
 '/u01/app/oracle/oradata/orcm/control01.ctl';
   restore clone controlfile to  '/u01/app/oracle/oradata/orcm/control03.ctl' from
 '/u01/app/oracle/oradata/orcm/control01.ctl';
}
executing Memory Script
Starting backup at 18-JUN-13
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
copying standby control file
output file name=/u01/app/oracle/product/11.2.0/db_1/dbs/snapcf_orcl.f tag=TAG20130618T051238 RECID=2 STAMP=818399559
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
Finished backup at 18-JUN-13
Starting restore at 18-JUN-13
using channel ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: copied control file copy
Finished restore at 18-JUN-13
Starting restore at 18-JUN-13
using channel ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: copied control file copy
Finished restore at 18-JUN-13
contents of Memory Script:
{
   sql clone 'alter database mount standby database';
}
executing Memory Script
sql statement: alter database mount standby database
contents of Memory Script:
{
   set newname for tempfile  1 to
 "/u01/app/oracle/oradata/orcm/temp01.dbf";
   switch clone tempfile all;
   set newname for datafile  1 to
 "/u01/app/oracle/oradata/orcm/system01.dbf";
   set newname for datafile  2 to
 "/u01/app/oracle/oradata/orcm/sysaux01.dbf";
   set newname for datafile  3 to
 "/u01/app/oracle/oradata/orcm/undotbs01.dbf";
   set newname for datafile  4 to
 "/u01/app/oracle/oradata/orcm/users01.dbf";
   backup as copy reuse
   datafile  1 auxiliary format
 "/u01/app/oracle/oradata/orcm/system01.dbf"   datafile
 2 auxiliary format
 "/u01/app/oracle/oradata/orcm/sysaux01.dbf"   datafile
 3 auxiliary format
 "/u01/app/oracle/oradata/orcm/undotbs01.dbf"   datafile
 4 auxiliary format
 "/u01/app/oracle/oradata/orcm/users01.dbf"   ;
   sql 'alter system archive log current';
}
executing Memory Script
executing command: SET NEWNAME
renamed tempfile 1 to /u01/app/oracle/oradata/orcm/temp01.dbf in control file
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting backup at 18-JUN-13
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00001 name=/u01/app/oracle/oradata/orcl/system01.dbf
output file name=/u01/app/oracle/oradata/orcm/system01.dbf tag=TAG20130618T051251
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:02:02
channel ORA_DISK_1: starting datafile copy
input datafile file number=00002 name=/u01/app/oracle/oradata/orcl/sysaux01.dbf
output file name=/u01/app/oracle/oradata/orcm/sysaux01.dbf tag=TAG20130618T051251
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:04:37
channel ORA_DISK_1: starting datafile copy
input datafile file number=00003 name=/u01/app/oracle/oradata/orcl/undotbs01.dbf
output file name=/u01/app/oracle/oradata/orcm/undotbs01.dbf tag=TAG20130618T051251
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:36
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=/u01/app/oracle/oradata/orcl/users01.dbf
output file name=/u01/app/oracle/oradata/orcm/users01.dbf tag=TAG20130618T051251
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
Finished backup at 18-JUN-13
sql statement: alter system archive log current
contents of Memory Script:
{
   switch clone datafile all;
}
executing Memory Script
datafile 1 switched to datafile copy
input datafile copy RECID=2 STAMP=818401498 file name=/u01/app/oracle/oradata/orcm/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=3 STAMP=818401498 file name=/u01/app/oracle/oradata/orcm/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=4 STAMP=818401498 file name=/u01/app/oracle/oradata/orcm/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=5 STAMP=818401498 file name=/u01/app/oracle/oradata/orcm/users01.dbf
Finished Duplicate Db at 18-JUN-13


你可能感兴趣的:(oracle)