DG 日常管理命令汇总

发布时间:2020-08-09 10:52:11 作者:wwjfeng
来源:ITPUB博客 阅读:277

1.启动/停止MRP进程

  • log_archive_dest 为LGWR时需要创建standby redolog,为arch时无须设置standby redolog
  • --必须设置standby redolog,数据实时同步
  • alter database recover managed standby database using current controlfile disconnect;
  • --数据异步同步,当主库切换归档时进行数据同步
  • alter database recover managed standby database disconnect from session;
  • --关闭MRP进程
  • alter database recover managed standby database cancel;

  • 2.检查主备库状态

  • select OPEN_MODE,PROTECTION_MODE,ACTIVATION#,DATABASE_ROLE,SWITCHOVER#,SWITCHOVER_STATUS FROM V$DATABASE;
  • 确认主库状态为to standby或者为sessions active、保护模式应该maximum performance、角色为PRIMARY
  • 在备库查询时通常为not allowed 或者sessions active,角色为PHYSICAL STANDBY

  • 3.检查数据同步情况

  • -查看应用日志延迟时间:
  • select value from v$dataguard_stats where name='apply lag';
  • -查看接收日志延迟时间:
  • select value from v$dataguard_stats where name='transport lag';
  • -查看主库归档
  • Primary: SQL> select thread#, max(sequence#) "Last Primary Seq Generated"
  • from v$archived_log val, v$database vdb
  • where val.resetlogs_change# = vdb.resetlogs_change#
  • group by thread# order by 1;
  • -查看备库已接收归档
  • PhyStdby:SQL> select thread#, max(sequence#) "Last Standby Seq Received"
  • from v$archived_log val, v$database vdb
  • where val.resetlogs_change# = vdb.resetlogs_change#
  • group by thread# order by 1;
  • -查看备库已应用归档
  • PhyStdby:SQL>select thread#, max(sequence#) "Last Standby Seq Applied"
  • from v$archived_log val, v$database vdb
  • where val.resetlogs_change# = vdb.resetlogs_change#
  • and val.applied in ('YES','IN-MEMORY')
  • group by thread# order by 1;
  • -查看归档应用详细情况
  • select first_time,sequence#,applied from v$archived_log;
  • -查看主备库GAP
  • select * from v$archive_gap;

  • 4.查询ASM Diskgroup 使用率

  • SET LINES 300 PAGES 9999
  • COL name FOR a15
  • COL USED_PERCENT FOR a15
  • SELECT GROUP_NUMBER,
  • NAME,
  • TOTAL_MB / 1024 total_gb,
  • FREE_MB / 1024,
  • USABLE_FILE_MB / 1024,
  • ROUND ( (TOTAL_MB - USABLE_FILE_MB) * 100 / TOTAL_MB) || '%'
  • USED_PERCENT
  • FROM V$ASM_DISKGROUP
  • ORDER BY 1;

  • 5.检查进程

    1. 主库(确认ARCH进程正常)
    2. SQL> SELECT PROCESS, CLIENT_PROCESS, SEQUENCE#, STATUS FROM V$MANAGED_STANDBY;
    3. PROCESS CLIENT_PROCESS SEQUENCE# STATUS
    4. ------------------ ---------------- ---------- ------------------------
    5. ARCH ARCH 731 CLOSING
    6. DGRD N/A 0 ALLOCATED
    7. DGRD N/A 0 ALLOCATED
    8. ARCH ARCH 732 CLOSING
    9. ARCH ARCH 733 CLOSING
    10. ARCH ARCH 734 CLOSING
    11. LNS LNS 735 WRITING
    12. DGRD N/A 0 ALLOCATED
    13. DGRD N/A 0 ALLOCATED
    14. 备库(要确认存在MRP、ARCH、RFS进程)
    15. SQL> SELECT PROCESS, CLIENT_PROCESS, SEQUENCE#, STATUS FROM V$MANAGED_STANDBY;
    16. PROCESS CLIENT_PROCESS SEQUENCE# STATUS
    17. ------------------ ---------------- ---------- ------------------------
    18. ARCH ARCH 735 CLOSING
    19. DGRD N/A 0 ALLOCATED
    20. DGRD N/A 0 ALLOCATED
    21. ARCH ARCH 731 CLOSING
    22. ARCH ARCH 693 CLOSING
    23. ARCH ARCH 692 CLOSING
    24. RFS LGWR 736 IDLE
    25. RFS UNKNOWN 0 IDLE
    26. RFS UNKNOWN 0 IDLE
    27. RFS Archival 0 IDLE
    28. RFS LGWR 694 IDLE
    29. PROCESS CLIENT_PROCESS SEQUENCE# STATUS
    30. ------------------ ---------------- ---------- ------------------------
    31. MRP0 N/A 736 APPLYING_LOG
    32. RFS UNKNOWN 0 IDLE
    33. RFS Archival 0 IDLE


    6.查询,添加standby log

    点击(此处)折叠或打开

    1. select GROUP#, DBID db_id, THREAD#, SEQUENCE#, BYTES, USED, ARCHIVED, STATUS, FIRST_CHANGE#, NEXT_CHANGE#,LAST_CHANGE# from v$standby_log ;
    2. alter database add standby logfile thread 1 group 7 size xxx ,group 8 size xxx ,group 9 size xxx,group 10 size xxx ;







    推荐阅读:
    1. linux下oracle 11g dg环境搭建
    2. 【DG】利用闪回数据库(flashback)修复Failover后的DG环境

    免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

    dg 命令 日常

    上一篇:MYSQL merge union merge sort_union 的不同

    下一篇:bootstrap——free bootstrap admin dashboard templates

    相关阅读

    您好,登录后才能下订单哦!

    密码登录
    登录注册
    其他方式登录
    点击 登录注册 即表示同意《亿速云用户服务条款》