当前位置:  数据库>oracle

Oracle 11g DataGuard使用总结

    来源: 互联网  发布时间:2017-06-18

    本文导语: Oracle 11g的dataguard相比于10g来说,最优越的特性应该算就是active dataguard了,这一点改进在很大意义上促使用户需要把数据库从10g升级到11g,读写分离在这个时候得到了升华,而且在后台会根据需要进行数据的同步,相比于使用10g,...

Oracle 11g的dataguard相比于10g来说,最优越的特性应该算就是active dataguard了,这一点改进在很大意义上促使用户需要把数据库从10g升级到11g,读写分离在这个时候得到了升华,而且在后台会根据需要进行数据的同步,相比于使用10g,想读数据的时候把数据库启动到read only 阶段,但这个时候不接受日志同步数据,如果需要同步数据还需要把数据库再启动到mount阶段,感觉还是比较繁琐的。

11g的active dataurad功能很强大,同时搭建的时候使用rman 的duplicate选项在11g也得到了很大的改进,我们不需要专门去做一个备份,就可以直接在备库上通过duplicate把数据文件从主库传送到备库,同时做恢复,整个过程更加简洁。

当然了一般的系统是一主一备,关键的系统甚至要一主两备,如果系统多了,手工管理很容易搞糊涂,这个时候还是用加强版的dg broker来做吧,以前在10g的时候感觉还是手工管理,手工switchover,failover比较踏实,因为也在10g的过程中switchover,failover出现过一些问题,算是留下了一些阴影,到了11g的时候,工作中大量使用,就尝试着自己试了试,发现确实很好,而且搭建备库步骤比手工搭建要轻松的多。所以还是需要拥抱变化,勇敢接受新事物,一方面可以给自己疗伤,一方面恢复使用的信心,至少在灾难发生的时候回临危不乱。

我们来简单看一个例子,怎么结合dg broker来搭建dataguard,步骤相比手工要简化很多,而且可靠性要高很多,因为人为去做的检查点,在dg broker的检查中都会去做。

出了设置主库为归档模式,force logging之外。

我们所要做的就是配置网络监听。当然这个也不是难点,listener.ora tnsnames.ora主备是很相似的。

比如我们使用1523的端口在primary和standby之间互联

listener.ora  主库和备库的host部分不一样


LISTENER_1523 =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS_LIST =
        (ADDRESS = (PROTOCOL = TCP)(HOST = 10.xxxxx.45)(PORT = 1523))
      )
    )
  )

 SID_LIST_LISTENER_1523 =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = test11g)
      (ORACLE_HOME = /DATA/app/oracle/product/11.2.0.4)
      (SID_NAME = test11g)
  )
  ) 

 tnsnames.ora 主库备库一致
TEST11G =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 10.xxxxx.45)(PORT = 1523))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = test11g)
    )
  )

 STEST11G =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 10.xxxxxx.46)(PORT = 1523))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = test11g)
    )
 )

然后就是使用tnsping开始检查,检查防火墙,等等
 添加备库日志
 主库查看日志情况,可以使用下面的方法检查一下。
SQL> select member,group#,status from v$logfile
 MEMBER                                                GROUP# STATUS
 -------------------------------------------------- ---------- -------
 /DATA/app/oracle/oradata/test11g/redo03.log                3
 /DATA/app/oracle/oradata/test11g/redo02.log                2
 /DATA/app/oracle/oradata/test11g/redo01.log                1
 SQL> select group#,status,bytes,blocksize,status from v$log;
    GROUP# STATUS                BYTES  BLOCKSIZE STATUS
 ---------- ---------------- ---------- ---------- ----------------
          1 INACTIVE          52428800        512 INACTIVE
          2 CURRENT            52428800        512 CURRENT
          3 INACTIVE          52428800        512 INACTIVE
添加备库日志的语句类似:
ALTER DATABASE ADD STANDBY LOGFILE GROUP 4 '/DATA/app/oracle/oradata/test11g/redo04.log' SIZE 524288000;
修改下面的数据库参数,
alter system set standby_file_management=auto scope=both;
 alter system set dg_broker_start=TRUE scope=both;
alter system set local_listener=TEST11G scope=both;

检查dmon的情况
SQL> !ps -ef|grep dmon_test11g
 oracle    8129    1  0 11:25 ?        00:00:00 ora_dmon_test11g
 oracle    8138  8108  0 11:25 pts/0    00:00:00 /bin/bash -c ps -ef|grep dmon_test11g
 oracle    8140  8138  0 11:25 pts/0    00:00:00 grep dmon_test11g

查看dg broker的日志,开始的时候没有配置文件,会重新创建。
DMON: cannot open configuration file "/DATA/app/oracle/product/11.2.0.4/dbs/dr2test11g.dat"
  ORA-27037: unable to obtain file status
  Linux-x86_64 Error: 2: No such file or directory
  Additional information: 3
 DMON: cannot open configuration file "/DATA/app/oracle/product/11.2.0.4/dbs/dr2test11g.dat"
  ORA-27037: unable to obtain file status
  Linux-x86_64 Error: 2: No such file or directory
  Additional information: 3
Configuration does not exist, Data Guard broker ready

数据库alert日志:
Mon Jul 27 11:25:15 2015
DMON started with pid=26, OS id=8129
 Starting Data Guard Broker (DMON)
 Mon Jul 27 11:25:23 2015

接着拷贝密码文件,参数文件(spfile)到备库

 在备库生成pfile,然后修改下面的参数
        修改db_unique_name为stest11g
        修改local_listener为stest11g
        配置 db_file_name_convert
              log_file_name_convert
    db_file_name_convert='/DATA/app/oracle/oradata/test11g','/DATA/app/oracle/oradata/test11g','/DATA/app/oracle/fast_recovery_area/test11g','/DATA/app/oracle/fast_recovery_area/test11g'              log_file_name_convert='/DATA/app/oracle/oradata/test11g','/DATA/app/oracle/oradata/test11g','/DATA/app/oracle/fast_recovery_area/test11g','/DATA/app/oracle/fast_recovery_area/test11g'
检查db_recovery_file_dest 和其它的文件路径是否有效(adump,oradata)
              fal_server
              fal_client
生成spfile
这个时候被库的工作就基本完成了,剩下的就是使用rman来恢复,dg broker来配置了。

 数据复制恢复
 启动备库到nomount阶段
SQL> create spfile from pfile;
 File created.
 SQL> startup nomount
 SQL> !ps -ef|grep dmon_test11g
 oracle  17773    1  0 11:44 ?        00:00:00 ora_dmon_test11g
 oracle  17779 17733  0 11:44 pts/0    00:00:00 /bin/bash -c ps -ef|grep dmon_test11g
 oracle  17781 17779  0 11:44 pts/0    00:00:00 grep dmon_test11g

检查参数是否生效
 备库通过rman复制数据文件
$  rman target sys/xxxx@test11g auxiliary sys/xxxxx@stest11g nocatalog
 Recovery Manager: Release 11.2.0.4.0 - Production on Mon Jul 27 11:46:23 2015
 Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
 connected to target database: TEST11G (DBID=1038061657)
 using target database control file instead of recovery catalog
 connected to auxiliary database: TEST11G (not mounted)
 RMAN> duplicate target database for standby from active database nofilenamecheck;

配置完成,数据复制工作就告一段落。
 开始配置dg broker

主库执行:
$ dgmgrl /
 DGMGRL for Linux: Version 11.2.0.4.0 - 64bit Production
 Copyright (c) 2000, 2009, Oracle. All rights reserved.
 Welcome to DGMGRL, type "help" for information.
 Connected.
 DGMGRL> create configuration dg_test11g as
 > primary database is test11g
 > connect identifier is test11g;
 Configuration "dg_test11g" created with primary database "test11g"
 DGMGRL> add database stest11g as
 > connect identifier is stest11g
 > maintained as physical;
 Database "stest11g" added
这个时候配置还没有生效
DGMGRL> show configuration;
 Configuration - dg_test11g
  Protection Mode: MaxPerformance
  Databases:
    test11g  - Primary database
    stest11g - Physical standby database
 Fast-Start Failover: DISABLED
 Configuration Status:
DISABLED
启用配置
DGMGRL> enable  configuration;
然后再次查看,如果配置没有问题,就会生效。
DGMGRL> show configuration;
 Configuration - dg_test11g
  Protection Mode: MaxPerformance
  Databases:
    test11g  - Primary database
    stest11g - Physical standby database
 Fast-Start Failover: DISABLED
 Configuration Status:
SUCCESS
接着进行再次验证
DGMGRL> enable database test11g;
 Enabled.
 DGMGRL> enable database stest11g;
 Enabled.
 DGMGRL>
 DGMGRL> show configuration;
 Configuration - dg_test11g
  Protection Mode: MaxPerformance
  Databases:
    test11g  - Primary database
    stest11g - Physical standby database
 Fast-Start Failover: DISABLED
 Configuration Status:
SUCCESS

 dataguard的搭建就完成了,可以在主库切换日志查看是否在备库数据库日志中会应用日志
Media Recovery Waiting for thread 1 sequence 12 (in transit)
Recovery of Online Redo Log: Thread 1 Group 4 Seq 12 Reading mem 0
  Mem# 0: /DATA/app/oracle/oradata/test11g/redo04.log

 11g备库使用active dataguard特性。
SQL> alter database open;
 Database altered.

 SQL>  recover managed standby database using current logfile disconnect from session;
 Media recovery complete.

 switchover的问题答疑
 如果出现下面的错误,很可能当前操作系统用户下安装了多个数据库实例,取消默认的ORACLE_SID即可。
 或者直接使用dgmgrl sys/oracle@test11g 这种方式连接
DGMGRL> switchover to 'stest11g';
 Performing switchover NOW, please wait...
 Operation requires a connection to instance "test11g" on database "stest11g"
 Connecting to instance "test11g"...
 ORA-01017: invalid username/password; logon denied
 Warning: You are no longer connected to ORACLE.
        connect to instance "test11g" of database "stest11g"

切换正常,但是需要手工启动备库,切换其实是正常的,需要手工启动一下主库
 主要原因就是在listener.ora中需要配置一个xxxx_DGMGRL的global_name

 DGMGRL> switchover to stest11g
 Performing switchover NOW, please wait...
 Operation requires a connection to instance "test11g" on database "stest11g"
 Connecting to instance "test11g"...
 Connected.
 New primary database "stest11g" is opening...
 Operation requires startup of instance "test11g" on database "test11g"
 Starting instance "test11g"...
 Unable to connect to database
 ORA-12514: TNS:listener does not currently know of service requested in connect descriptor
 Failed.
 Warning: You are no longer connected to ORACLE.
 Please complete the following steps to finish switchover:
        start up instance "test11g" of database "test11g"

如果配置完全正确,正常切换的日志就会如下:
DGMGRL> switchover to stest11g;
 Performing switchover NOW, please wait...
 Operation requires a connection to instance "test11g" on database "stest11g"
 Connecting to instance "test11g"...
 Connected.
 New primary database "stest11g" is opening...
 Operation requires startup of instance "test11g" on database "test11g"
 Starting instance "test11g"...
 ORACLE instance started.
 Database mounted.
 Database opened.
 Switchover succeeded, new primary is "stest11g"
 DGMGRL>

最后还是希望大家能够合理使用dataguard,一切顺利。

在CentOS 6.4下安装Oracle 11gR2(x64)

Oracle 11gR2 在VMWare虚拟机中安装步骤

Debian 下 安装 Oracle 11g XE R2

Oracle Data Guard 重要配置参数

基于同一主机配置 Oracle 11g Data Guard

探索Oracle之11g DataGuard

Oracle Data Guard (RAC+DG) 归档删除策略及脚本

Oracle Data Guard 的角色转换

Oracle Data Guard的日志FAL gap问题

Oracle 11g Data Guard Error 16143 Heartbeat failed to connect to standby 处理方法


    
 
 

您可能感兴趣的文章:

  • ORACLE DATAGUARD中手工处理日志v$archive_GAP的方法
  • Oracle Dataguard备库失败与主库响应测试
  • Linux下Oracle10_Dataguard配置与应用
  • Oracle 11g Dataguard参数详解
  • Oracle认证:学好Oracle的六条总结
  • oracle服务启动与停止经验总结
  • Linux下Oracle常见安装错误总结及参考案例
  • Oracle中三种表连接算法的总结
  • Oracle、DB2、PostgreSQL之Sequence大总结
  • Oracle索引(B*tree与Bitmap)的学习总结
  • [Oracle] dbms_metadata.get_ddl 的使用方法总结
  • Oracle数据库中的字符处理技巧总结
  • Oracle数据字典的学习总结
  • Oracle 数据库优化实战心得总结
  • 深入ORACLE迁移到MYSQL的总结分析
  • oracle数据库sql的优化总结
  • Oracle 游标使用总结
  • oracle 日期时间函数使用总结
  • Oracle 存储过程总结(一、基本应用)
  • Oracle 存储过程总结 二、字符串处理相关函数
  • ORACLE 常用函数总结(80个)第1/2页
  •  
    本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
    本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。












  • 相关文章推荐
  • linux下安装oracle后使用命令行启动的方法 linux启动oracle
  • Oracle9i 9.0.1的JDBC Drivers 可以给Oracle 8.0.5使用马?
  • Suse linux使用oracle问题
  • 请问:在使用oracle数据库作开发时,是使用pro*c作开发好些,还是使用库函数如oci等好一些啊?或者它们有什么区别或者优缺点啊?
  • jbuilder中使用oracle的问题
  • 求redhat linux 9.0下可以使用的oracle 10g或9i,还有redhat linux 9.0下可以使用的eclipse下载地址
  • Oracle事务!使用游标提交过程
  • NOSQL iis7站长之家
  • AIX 64位系统上如何使用32位OCI oracle driver
  • Oracle中SQL语句连接字符串的符号使用介绍
  • 使用X manager连接oracle数据库的步骤
  • C++使用OCCI连Oracle10g的错误
  • 使用工具 plsqldev将Excel导入Oracle数据库
  • Linux下Oracle的sqlplus使用光标上下左右方法
  • Oracle 数据 使用游标
  • oracle使用sql脚本生成csv文件案例学习
  • ORACLE 修改表结构 之ALTER CONSTAINTS的使用
  • Linux中Oracle使用相关知识集锦
  • Oracle密码文件的使用和维护第1/3页
  • Oracle 触发器的使用小结
  • Oracle 12c发布简单介绍及官方下载地址
  • 在linux下安装oracle,如何设置让oracle自动启动!也就是让oracle那个服务自动启动,不是手动的
  • oracle 11g最新版官方下载地址
  • 请问su oracle 和su - oracle有什么不同?
  • Oracle 数据库(oracle Database)Select 多表关联查询方式
  • 虚拟机装Oracle R12与Oracle10g
  • Oracle数据库(Oracle Database)体系结构及基本组成介绍
  • Oracle 数据库开发工具 Oracle SQL Developer
  • 如何设置让Oracle SQL Developer显示的时间包含时分秒
  • Oracle EBS R12 支持 Oracle Database 11g
  • Oracle 10g和Oracle 11g网格技术介绍


  • 站内导航:


    特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

    ©2012-2021,,E-mail:www_#163.com(请将#改为@)

    浙ICP备11055608号-3