找回密码
 立即注册
首页 业界区 安全 Oracle DG Broker做切换Switchover

Oracle DG Broker做切换Switchover

辗振 6 天前
使用Oracle DG Broker做Switchover是非常简单的一件事情,但是流程必须规范,事前做足检查工作.避免没有检查到位,做Switchover时出现异常.
切换前检查
  1. DGMGRL>show configuration;
  2. DGMGRL>show database <primary_db_name>;
  3. DGMGRL>show database <standby_db_name>;
  4. DGMGRL>show database verbose <primary_db_name>;
  5. DGMGRL>show database verbose <standby_db_name>;
  6. DGMGRL>show database <db_name> logxptstatus;
  7. DGMGRL>show database <db_name> 'inconsistentlogxptprops';
复制代码
注意: 用具体的主库名和备库名替换上面的和或
主要检查下面这些内容:

  • DG中所有数据库都处于正常状态.无任何错误或警告信息。
  • 主数据库上已配置备用重做日志文件。
  • 主数据库与备用数据库的状态分别为日志传输开启(TRANSPORT-ON)和日志应用开启(APPLY-ON)。
  1. DGMGRL>  validate database gsp;        
  2.   Database Role:    Primary database
  3.   Ready for Switchover:  Yes
  4.   Flashback Database Status:
  5.     gsp:  Off
  6.   Managed by Clusterware:
  7.     gsp:  NO            
  8.     Validating static connect identifier for the primary database gsp...
  9.     The static connect identifier allows for a connection to database "gsp".
  10. DGMGRL> validate database gspro
  11.   Database Role:     Physical standby database
  12.   Primary Database:  gsp
  13.   Ready for Switchover:  Yes
  14.   Ready for Failover:    Yes (Primary Running)
  15.   Flashback Database Status:
  16.     gsp  :  Off
  17.     gspro:  Off
  18.   Managed by Clusterware:
  19.     gsp  :  NO            
  20.     gspro:  NO            
  21.     Validating static connect identifier for the primary database gsp...
  22.     The static connect identifier allows for a connection to database "gsp".
  23.   Current Log File Groups Configuration:
  24.     Thread #  Online Redo Log Groups  Standby Redo Log Groups Status      
  25.               (gsp)                   (gspro)                              
  26.     1         7                       3                       Insufficient SRLs
  27.   Future Log File Groups Configuration:
  28.     Thread #  Online Redo Log Groups  Standby Redo Log Groups Status      
  29.               (gspro)                 (gsp)                                
  30.     1         7                       3                       Insufficient SRLs
  31. DGMGRL>
复制代码
主库信息:
Ready for Switchover:  Yes  表示可以准备切换(Switchover)
备库信息:
Ready for Switchover:  Yes    表示切换操作已准备就绪
如果需要进一步诊断或troubleshoot,可以使用下面命令查看更多详细信息
  1. validate database verbose gsp;
  2. validate database verbose gspro;
复制代码
例子:
  1. DGMGRL> validate database verbose gsp;
  2.   Database Role:    Primary database
  3.   Ready for Switchover:  Yes
  4.   Flashback Database Status:
  5.     gsp:  On
  6.   Capacity Information:
  7.     Database  Instances        Threads        
  8.     gsp       1                1              
  9.   Managed by Clusterware:
  10.     gsp:  NO            
  11.     Validating static connect identifier for the primary database gsp...
  12.     The static connect identifier allows for a connection to database "gsp".
  13.   Temporary Tablespace File Information:
  14.     gsp TEMP Files:  3
  15.   Data file Online Move in Progress:
  16.     gsp:  No
  17.   Transport-Related Information:
  18.     Transport On:  Yes
  19.   Log Files Cleared:
  20.     gsp Standby Redo Log Files:  Cleared
  21. DGMGRL> validate database verbose gspro;
  22.   Database Role:     Physical standby database
  23.   Primary Database:  gsp
  24.   Ready for Switchover:  Yes
  25.   Ready for Failover:    Yes (Primary Running)
  26.   Flashback Database Status:
  27.     gsp  :  On
  28.     gspro:  Off
  29.   Capacity Information:
  30.     Database  Instances        Threads        
  31.     gsp       1                1              
  32.     gspro     1                1              
  33.   Managed by Clusterware:
  34.     gsp  :  NO            
  35.     gspro:  NO            
  36.     Validating static connect identifier for the primary database gsp...
  37.     The static connect identifier allows for a connection to database "gsp".
  38.   Temporary Tablespace File Information:
  39.     gsp TEMP Files:    3
  40.     gspro TEMP Files:  3
  41.   Data file Online Move in Progress:
  42.     gsp:    No
  43.     gspro:  No
  44.   Standby Apply-Related Information:
  45.     Apply State:      Running
  46.     Apply Lag:        0 seconds (computed 1 second ago)
  47.     Apply Delay:      0 minutes
  48.   Transport-Related Information:
  49.     Transport On:  Yes
  50.     Gap Status:    No Gap
  51.     Transport Lag:  0 seconds (computed 1 second ago)
  52.     Transport Status:  Success
  53.   Log Files Cleared:
  54.     gsp Standby Redo Log Files:    Cleared
  55.     gspro Online Redo Log Files:   Cleared
  56.     gspro Standby Redo Log Files:  Available
  57.   Current Log File Groups Configuration:
  58.     Thread #  Online Redo Log Groups  Standby Redo Log Groups Status      
  59.               (gsp)                   (gspro)                              
  60.     1         3                       4                       Sufficient SRLs
  61.   Future Log File Groups Configuration:
  62.     Thread #  Online Redo Log Groups  Standby Redo Log Groups Status      
  63.               (gspro)                 (gsp)                                
  64.     1         3                       4                       Sufficient SRLs
  65.   Current Configuration Log File Sizes:
  66.     Thread #   Smallest Online Redo      Smallest Standby Redo   
  67.                Log File Size             Log File Size            
  68.                (gsp)                     (gspro)                  
  69.     1          200 MBytes                200 MBytes               
  70.   Future Configuration Log File Sizes:
  71.     Thread #   Smallest Online Redo      Smallest Standby Redo   
  72.                Log File Size             Log File Size            
  73.                (gspro)                   (gsp)                    
  74.     1          200 MBytes                200 MBytes               
  75.   Apply-Related Property Settings:
  76.     Property                        gsp Value                gspro Value
  77.     DelayMins                       0                        0
  78.     ApplyParallel                   AUTO                     AUTO
  79.     ApplyInstances                  0                        0
  80.   Transport-Related Property Settings:
  81.     Property                        gsp Value                gspro Value
  82.     LogShipping                     ON                       ON
  83.     LogXptMode                      ASYNC                    ASYNC
  84.     Dependency                      <empty>                  <empty>
  85.     DelayMins                       0                        0
  86.     Binding                         optional                 OPTIONAL
  87.     MaxFailure                      0                        0
  88.     ReopenSecs                      300                      300
  89.     NetTimeout                      30                       30
  90.     RedoCompression                 DISABLE                  DISABLE
  91. DGMGRL>
复制代码
切换步骤

主库切换(Switchover)
switchover to
  1. DGMGRL> switchover to gspro
  2. Performing switchover NOW, please wait...
  3. Operation requires a connection to database "gspro"
  4. Connecting ...
  5. Connected to "gspro"
  6. Connected as SYSDBA.
  7. New primary database "gspro" is opening...
  8. Operation requires start up of instance "gsp" on database "gsp"
  9. Starting instance "gsp"...
  10. Connected to an idle instance.
  11. ORACLE instance started.
  12. Connected to "gsp"
  13. Database mounted.
  14. Database opened.
  15. Switchover succeeded, new primary is "gspro"
  16. DGMGRL>
复制代码
注意: 在切换过程,最好用下面命令实时观察主库&备库的错误日志与dg broker的日志输出信息.
主库:
  1. $ tail -60f drcgsp.log
  2. $ tail -60f alert_gsp.log
复制代码
备库:
  1. $ tail -60f alert_gsp.log
  2. $ tail -60f drcgsp.log
复制代码
注意事项:
如果切换的目标是物理standby,那么Brocker 在切换过程中会关闭主库。
如果切换环境是MAX_PROTECTION模式并且主库只有一个备库,Brocker在切换过程中将同时关闭主备库;如果主库有多个备库,那么Brocker仅关闭新主库。
检查验证
  1. DGMGRL> show configuration;
  2. Configuration - dg_gsp
  3.   Protection Mode: MaxPerformance
  4.   Members:
  5.   gspro - Primary database
  6.     gsp   - Physical standby database
  7. Fast-Start Failover:  Disabled
  8. Configuration Status:
  9. SUCCESS   (status updated 67 seconds ago)
  10. DGMGRL>
复制代码
疑问问题


  • DG Broker做switchover会改变DG的保护模式吗?
DG Broker will not downgrade the PROTECTION mode during the process of Switchover.
Configure suitable REDO transport mode on current standby that becomes Primary after switchover.
Configure SRL (Standby Redo Logs) and local archiving destination  on current Primary.
Broker switchover command verifies the availability of SRL on current Primary Database and suitable Redo transport method on current Standby.
DG Broker在主备切换(Switchover)过程中不会降级数据库的保护模式。
在当前备库(切换后的主库)上配置合适的重做日志传输模式(redo transport mode)
在当前主库上配置备库重做日志(SRL, Standby Redo Logs)与本地归档目标位置
Broker 主备切换命令会校验当前主库上备用重做日志(SRL)的可用性,以及当前备库上适配的重做日志传输方式。

  • 配置了DG Broker后,还能使用SQL手工切换吗? 手工切换会破坏DG Broker吗?
测试验证如下:
  1. SQL> ALTER DATABASE SWITCHOVER TO gspro VERIFY;
  2. ALTER DATABASE SWITCHOVER TO gspro VERIFY
  3. *
  4. ERROR at line 1:
  5. ORA-16475: succeeded with warnings, check alert log for more details
复制代码
检查告警日志如下所示:
  1. SWITCHOVER VERIFY: Send VERIFY request to switchover target GSPRO
  2. SWITCHOVER VERIFY WARNING: switchover target has no standby database defined in LOG_ARCHIVE_DEST_n parameter. If the switchover target is converted to a primary database, the new primary database will not be protected.
  3. ORA-16475 signalled during: ALTER DATABASE SWITCHOVER TO gspro VERIFY...
复制代码
检查备库的log_archive_dest_2,发现备库上参数log_archive_dest_1/log_archive_dest_2都为空
  1. SQL> show parameter log_archive_dest_2
  2. NAME                                 TYPE        VALUE
  3. ------------------------------------ ----------- ------------------------------
  4. log_archive_dest_2                   string
  5. log_archive_dest_20                  string
  6. log_archive_dest_21                  string
  7. log_archive_dest_22                  string
  8. log_archive_dest_23                  string
  9. log_archive_dest_24                  string
  10. log_archive_dest_25                  string
  11. log_archive_dest_26                  string
  12. log_archive_dest_27                  string
  13. log_archive_dest_28                  string
  14. log_archive_dest_29                  string
  15. SQL>
复制代码
此时需要修改相关参数才能满足DG切换条件,但是可能会破坏DG Broker的数据. 所以结论是不建议手工做切换,这样会破坏DB Broker的元数据.
  1. alter system set log_archive_dest_1='location=/db19clog/gspro_arc_ valid_for=(all_logfiles,all_roles) db_unique_name=gspro' scope=both;
  2. alter system set log_archive_dest_2='service=gsp, SYNC AFFIRM delay=0 optional compression=disable max_failure=0 reopen=300 db_unique_name=gsp net_timeout=30 valid_for=(online_logfile,primary_role)' scope=both;
  3. SQL> alter system set log_archive_dest_1='location=/db19clog/gspro_arc_ valid_for=(all_logfiles,all_roles) db_unique_name=gspro' scope=both;
  4. System altered.
  5. SQL> alter system set log_archive_dest_2='service=gsp, SYNC AFFIRM delay=0 optional compression=disable max_failure=0 reopen=300 db_unique_name=gsp net_timeout=30 valid_for=(online_logfile,primary_role)' scope=both;
  6. System altered.
  7. SQL>
复制代码

  • DG Broker切换可以在任意数据库保护模式下?
可以.
参考资料


  • 12c Dataguard Switchover Best Practices using DGMGRL(Dataguard Broker Command Prompt)
  • https://docs.oracle.com/en/database/oracle/oracle-database/19/dgbkr/using-data-guard-broker-to-manage-switchovers-failovers.html#GUID-89BF9FC5-1E3F-4C0B-90CB-AF4B39B5245E
扫描上面二维码关注我如果你真心觉得文章写得不错,而且对你有所帮助,那就不妨帮忙“推荐"一下,您的“推荐”和”打赏“将是我最大的写作动力!本文版权归作者所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接.
来源:程序园用户自行投稿发布,如果侵权,请联系站长删除
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!

相关推荐

您需要登录后才可以回帖 登录 | 立即注册