欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

Oracle数据库 DGbroker三种保护模式的切换

程序员文章站 2022-06-21 21:13:09
1.三种保护模式   – maximum protection 在maximum protection下, 可以保证从库和主库数据完全一样,做到zero dat...

1.三种保护模式

  – maximum protection

在maximum protection下, 可以保证从库和主库数据完全一样,做到zero data loss.事务同时在主从两边提交完成,才算事务完成。如果从库宕机或者网络出现问题,主从库不能通讯,主库也立即宕机。在这种方式下,具有最高的保护等级。但是这种模式对主库性能影响很大,要求高速的网络连接。

  – maximum availability

在maximum availability模式下,如果和从库的连接正常,运行方式等同maximum protection模式,事务也是主从库同时提交。如果从库和主库失去联系,则主库自动切换到maximum performance模式下运行,保证主库具有最大的可用性。

  – maximum performance

 在maximum performance,主库把归档的 archived log通过arch进程传递给从库,在这种方式下,主库运行性能最高,但是不能保证数据不丢失,且丢失的数据受redo log的大小影响。在redo log过大的情况下,可能一天都没有归档一个日志,可以通过手工切换日志的方式来减小数据的丢失。

2.模式切换(maximum performance切换至maximum availability)

  a.查看保护的模式

     dgbroker查看:

dgmgrl> show configuration verbose;
configuration - dgc
 protection mode: maxperformance
 databases:
 atest1 - primary database
 atest2 - physical standby database
 properties:
 faststartfailoverthreshold  = '30'
 operationtimeout    = '30'
 faststartfailoverlaglimit  = '30'
 communicationtimeout   = '180'
 observerreconnect    = '0'
 faststartfailoverautoreinstate = 'true'
 faststartfailoverpmyshutdown = 'true'
 bystandersfollowrolechange  = 'all'
 observeroverride    = 'false'
 externaldestination1   = ''
 externaldestination2   = ''
 primarylostwriteaction   = 'continue'
fast-start failover: disabled
configuration status:
success 

     sqlplus查看:

sql> select database_role,protection_mode,protection_level from v$database;
database_role  protection_mode  protection_level
---------------- -------------------- --------------------
primary  maximum performance maximum performance 

  b.查看备库的日志传输模式(参数logxptmode(sync:同步传输/async:异步传输))

dgmgrl> show database verbose 'atest2';
database - atest2
 role:   physical standby
 intended state: apply-on
 transport lag: 0 seconds (computed 1 second ago)
 apply lag:  0 seconds (computed 1 second ago)
 apply rate:  97.00 kbyte/s
 real time query: on
 instance(s):
 atest
 properties:
 dgconnectidentifier    = 'atest2'
 observerconnectidentifier  = ''
 logxptmode      = 'sync'
 delaymins      = '0'
 binding       = 'optional'
 maxfailure      = '0'
 maxconnections     = '1'
 reopensecs      = '300'
 nettimeout      = '30'
 redocompression     = 'disable'
 logshipping      = 'on'
 preferredapplyinstance   = ''
 applyinstancetimeout   = '0'
 applyparallel     = 'auto'
 standbyfilemanagement   = 'auto'
 archivelagtarget    = '0'
 logarchivemaxprocesses   = '4'
 logarchiveminsucceeddest  = '1'
 dbfilenameconvert    = ''
 logfilenameconvert    = ''
 faststartfailovertarget   = ''
 inconsistentproperties   = '(monitor)'
 inconsistentlogxptprops   = '(monitor)'
 sendqentries     = '(monitor)'
 logxptstatus     = '(monitor)'
 recvqentries     = '(monitor)'
 applylagthreshold    = '0'
 transportlagthreshold   = '0'
 transportdisconnectedthreshold = '30'
 sidname       = 'atest'
 staticconnectidentifier   = '(description=(address=(protocol=tcp)(host=vijay02.database.com)(port=1521))(connect_data=(service_name=atest2_dgmgrl)(instance_name=atest)(server=dedicated)))'
 standbyarchivelocation   = '/u01/app/oracle/oradata/atest/archivelog'
 alternatelocation    = ''
 logarchivetrace     = '0'
 logarchiveformat    = '%t_%s_%r.dbf'
 topwaitevents     = '(monitor)'
database status:
success 

  c.如果logxptmode的值为async,就要将其修改为sync

dgmgrl> edit database atest1 set property logxptmode=sync;
property "logxptmode" updated 

  d.修改完之后再次确认logxptmode的值,如步骤b

  e.切换模式(如果切换失败,则再次去确认备库logxptmode的值)

dgmgrl> edit configuration set protection mode as maxavailability;
succeeded.

  f. 确认数据库的的保护模式,如步骤a

  g.需要注意的是,步骤c中修改的sync是备库的值,切记!

 3.个人小结:

  a.三种模式在可以在dgbroker中*切换(使用步骤2的方式)(在测试库中),正常情况下,数据库能迅速反应过来(查看保护模式的时候)。

  b.使用maximum performance的时候,参数(备库)logxptmode设置为async就好/

  c.使用maximum protection或者maximum availability的时候,参数(备库)logxptmode要设置为sync。

  d.(经测试)使用maximum protection时,当备库出现异常(如网络问题,数据库宕机),主库会挂起(告警日志会报如下错误),当备库恢复正常之后,主库也会恢复。

lgwr: error 1034 attaching to rfs for reconnect

  e.使用maximum protection时,在当备库出现异常的情况下,当主库挂起时,(主库)可以强制切换到 maximum performance,但当重新切回maximum protection(在备库恢复时),主库需重启。

dgmgrl> edit configuration set protection mode as maxprotection;
operation requires shutdown of instance "atest" on database "atest1"
shutting down instance "atest"...
unable to connect to database
ora-12545: connect failed because target host or object does not exist
failed.
warning: you are no longer connected to oracle.
please complete the following steps to finish the operation:
 shut down instance "atest" of database "atest1"
 start up instance "atest" of database "atest1"

以上内容是小编给大家分享的oracle数据库 dgbroker三种保护模式的切换的相关内容,希望大家喜欢,同时也感谢大家一直以来对网站的支持与厚爱。