ITPub博客

首页 > 数据库 > Oracle > 使用RMAN DUPLICATE创建Physical Standby

使用RMAN DUPLICATE创建Physical Standby

原创 Oracle 作者:流云风秀 时间:2015-01-29 14:54:10 0 删除 编辑
1、系统环境
    操作系统RHEL6  64位系统 ORACLE 11.2.0.3
   节点1:INSTANCE_NAME:DG
   节点2:INSTANCE_NAME:DGBAK
2、配置PRIMARY库
   2.1、开启数据库归档
   2.2、开启数据库强制日志
           SQL> alter database force logging;
   2.3、在主库上创建standby redo log
           SQL> alter database add standby logfile size 20m;
            SQL> alter database add standby logfile size 20m;
            SQL> alter database add standby logfile size 20m;
   2.4、修改数据库参数
           SQL> alter system set log_archive_config='DG_CONFIG=(DG,DGBAK)' scope=spfile;
           SQL> alter system set log_archive_dest_2='SERVICE=DGBAK valid_for=(online_logfiles,primary_role) db_unique_name=DGBAK' scope=spfile;
           SQL> alter system set log_archive_dest_state_2=enable;
           SQL> alter system set db_file_name_convert='DG','DGBAK' scope=spfile;
           SQL> alter system set log_file_name_convert='DG','DGBAK' scope=spfile;
           SQL> alter system set standby_file_management=auto;
  2.6、配置主库LISTENER.ORA和TNSNAMES.ORA  文件
          修改tnsname.ora文件
           DGBAK =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.22)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = DGBAK)
    )
  )


DG =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.21)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = DG)
    )
  )

          修改listener.ora文件
LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = dg01)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = DG)
      (ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)
      (PROGRAM = extproc)
      (GLOBAL_DBNAME = DG)
    )


    (SID_DESC =
      (SID_NAME = DGBAK)
      (ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)
      (GLOBAL_DBNAME = DGBAK)
    )
  )
ADR_BASE_LISTENER = /u01/app/oracle

3、配置STANDBY库
   3.1、创建备库参数文件initDGBAK.ora
          在此参数文件中只写入参数INSTANCE_NAME=DBBAK即可
  3.2、创建密码文件
           将主库上的密码文件拷贝到备库上。
  3.3、创建相应目录
          [oracle@dg02 ~]$ mkdir -p /u01/app/oracle/admin/DGBAK/adump
           [oracle@dg02 ~]$ mkdir -p /u01/app/oradata/DGBAK/
           [oracle@dg02 ~]$ mkdir -p /u01/app/fast_recovery_area/DGBAK

         注:如果不创建相应的目录,在进行Duplicate数据库时,会出现RMAN-04014: startup failed: ORA-09925: Unable to create audit trail file错误
  3.4、配置listener.ora文件和tnsname.ora文件
         standby 库的listener.ora、tnsname.ora文件与PRIMARY库的文件一致。

 
 3.5、创建脚本cr_standby_script
run {
  duplicate target database for standby from active database
  spfile
     parameter_value_convert 'DG','DGBAK'
     set db_unique_name='DGBAK'
     set control_files='/u01/oradata/DGBAK/control01.ctl'
     set db_file_name_convert='DG','DGBAK'
     set log_file_name_convert='DG','DGBAK'
     set log_archive_max_processes='5'
     set fal_client='DGBAK'
     set fal_server='DG'
     set standby_file_management='AUTO'
     set log_archive_config='dg_config=(DG,DGBAK)'
     set log_archive_dest_2='service=DG async valid_for=(ONLINE_LOGFILE,PRIMARY_ROLE) db_unique_name=DG';
}
  3.6、启动STANDBY库到nomount状态
          SQL> startup nomount pfile=/u01/app/oracle/product/11.2.0/db_1/dbs/initDGBAK.ora
         
 3.7、复制主库到备库
          [oracle@dg02 ~]$rman target sys/oracle@DG auxiliary sys/oracle@DGBAK
           RMAN>@cr_standby_script
 3.8、启动备库的apply进程
          SQL> alter database recover managed standby database using current logfile disconnect from session;

          

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/23988293/viewspace-1419501/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2011-04-05

  • 博文量
    9
  • 访问量
    22718