OGG常用命令(六)–HEARTBEATTABLE

1、ADD HEARTBEATTABLE

使用ADD HEARTBEATTABLE创建使用自动心跳功能所需物品。该命令执行以下任务:
创建心跳种子表,心跳表和心跳历史记录表。
创建GG_LAG和 GG_LAG_HISTORY视图。
创建由调度程序作业调用的GG_UPDATE_HB_TAB和 GG_PURGE_HB_TAB过程。
创建调度程序作业,这些作业会定期更新心跳和种子表,并清除历史记录表。
填充种子表。
(PostgreSQL)创建作业表,作业过程以及心跳表或视图以获取滞后信息。如果TARGETONLY指定,则不创建作业表或过程。

默认的种子,心跳,历史表名 GG_HEARTBEAT_SEED,GG_HEARTBEAT和 GG_HEARTBEAT_HISTORY分别。GGSCHEMA在GLOBALS文件中提到 的表,过程和计划程序作业中创建。

在经典建筑中:
通过HEARTBEATTABLE hbschemaname.hbtablename在 GLOBALS文件中指定可以覆盖默认名称 。
表,过程和作业在模式中创建 hbschemaname。
种子和历史记录表是通过将_SEED和附加_HISTORY到表 创建的 hbtablename。

在微服务架构中,使用“使用Oracle GoldenGate微服务架构”指南的“如何创建部署”部分中提供的步骤12配置 架构。
对于Oracle,ADD HEARTBEATTABLE必须在要为其以CDB模式生成心跳的每个PDB中执行该操作。在多租户数据库上,心跳表在每个PDB内创建。使用该 DBLOGIN命令登录到需要创建心跳表的PDB。
对于DB2 LUW,必须DB2_ATS_ENABLE使用db2set DB2_ATS_ENABLE=yes命令设置属性。
对于Amazon Aurora MySQL,event_scheduler必须在参数组中启用全局变量 ,因为Amazon RDS不允许设置全局变量。重新启动数据库后,event_scheduler返回到禁用状态。为避免这种情况,您需要event_scheduler在 my.cnf/ini文件中启用。

语法:
ADD HEARTBEATTABLE
[, FREQUENCY number_in_seconds]
[, RETENTION_TIME number_in_days] |
[, PURGE_FREQUENCY number_in_days]
[, PARTITIONED]
[, TARGETONLY]

FREQUENCY number_in_seconds
指定心跳种子表和心跳表的更新频率。例如,心跳记录的生成频率。默认值为60秒。

RETENTION_TIME number_in_days
指定何时清除历史记录表中保留时间之前的心跳条目。默认值为30天。

PURGE_FREQUENCY number_in_days
指定运行清除调度程序从心跳历史记录中删除保留时间之前的表条目的频率。默认值为1天。

PARTITIONED
对Oracle有效。

在心跳历史记录表上启用分区。收到的心跳时间戳记列用于以一天为间隔对表进行分区。默认情况下,心跳历史记录表未分区。

TARGETONLY
对Oracle数据库,PostgreSQL和SQL Server有效。不能同时在心跳种子和心跳表上启用补充日志记录。它不会创建用于更新心跳表的调度程序作业。

举例1:

GGSCI (oracle11g as ogg@orcl) 12> ADD HEARTBEATTABLE

2020-12-01 16:00:27  INFO    OGG-14001  Successfully created heartbeat seed table ""ogg"."GG_HEARTBEAT_SEED"".

2020-12-01 16:00:28  INFO    OGG-14032  Successfully added supplemental logging for heartbeat seed table ""ogg"."GG_HEARTBEAT_SEED"".

2020-12-01 16:00:28  INFO    OGG-14000  Successfully created heartbeat table ""ogg"."GG_HEARTBEAT"".

2020-12-01 16:00:28  INFO    OGG-14033  Successfully added supplemental logging for heartbeat table ""ogg"."GG_HEARTBEAT"".

2020-12-01 16:00:28  INFO    OGG-14016  Successfully created heartbeat history table ""ogg"."GG_HEARTBEAT_HISTORY"".

2020-12-01 16:00:28  INFO    OGG-14086  Successfully disabled partitioning for heartbeat history table ogg.gg_heartbeat_history.

2020-12-01 16:00:28  INFO    OGG-14023  Successfully created heartbeat lag view ""ogg"."GG_LAG"".

2020-12-01 16:00:28  INFO    OGG-14024  Successfully created heartbeat lag history view ""ogg"."GG_LAG_HISTORY"".

2020-12-01 16:00:28  INFO    OGG-14003  Successfully populated heartbeat seed table with "ORCL".

2020-12-01 16:00:28  INFO    OGG-14004  Successfully created procedure ""ogg"."GG_UPDATE_HB_TAB"" to update the heartbeat tables.

2020-12-01 16:00:28  INFO    OGG-14017  Successfully created procedure ""ogg"."GG_PURGE_HB_TAB"" to purge the heartbeat history table.

2020-12-01 16:00:28  INFO    OGG-14005  Successfully created scheduler job ""ogg"."GG_UPDATE_HEARTBEATS"" to update the heartbeat tables.

2020-12-01 16:00:28  INFO    OGG-14018  Successfully created scheduler job ""ogg"."GG_PURGE_HEARTBEATS"" to purge the heartbeat history table.

举例2:

GGSCI (oracle11g as ogg@orcl) 15> ADD HEARTBEATTABLE, partitioned, TARGETONLY

2020-12-01 16:02:19  INFO    OGG-14001  Successfully created heartbeat seed table ""ogg"."GG_HEARTBEAT_SEED"".

2020-12-01 16:02:19  INFO    OGG-14087  Successfully disabled supplemental logging for heartbeat seed table "ogg.gg_heartbeat_seed".

2020-12-01 16:02:19  INFO    OGG-14000  Successfully created heartbeat table ""ogg"."GG_HEARTBEAT"".

2020-12-01 16:02:19  INFO    OGG-14088  Successfully disabled supplemental logging for heartbeat table "ogg.gg_heartbeat".

2020-12-01 16:02:19  INFO    OGG-14016  Successfully created heartbeat history table ""ogg"."GG_HEARTBEAT_HISTORY"".

2020-12-01 16:02:19  INFO    OGG-14085  Successfully enabled partitioning for heartbeat history table ogg.gg_heartbeat_history.

2020-12-01 16:02:19  INFO    OGG-14023  Successfully created heartbeat lag view ""ogg"."GG_LAG"".

2020-12-01 16:02:19  INFO    OGG-14024  Successfully created heartbeat lag history view ""ogg"."GG_LAG_HISTORY"".

2020-12-01 16:02:19  INFO    OGG-14003  Successfully populated heartbeat seed table with "ORCL".

2020-12-01 16:02:19  INFO    OGG-14017  Successfully created procedure ""ogg"."GG_PURGE_HB_TAB"" to purge the heartbeat history table.

2020-12-01 16:02:19  INFO    OGG-14018  Successfully created scheduler job ""ogg"."GG_PURGE_HEARTBEATS"" to purge the heartbeat history table.

2、ALTER HEARTBEATTABLE

使用ALTER HEARTBEATTABLE改变现有种子,心跳和历史表选项,您设置ADD HEARTBEATTABLE。
此命令需要一个DBLOGIN。在CDB数据库上,需要PDB登录。

语法:
ALTER HEARTBEATTABLE
[, FREQUENCY number_in_seconds]
[, RETENTION_TIME number_in_days] |
[, PURGE_FREQUENCY number_in_days]
[, TARGETONLY | NOTARGETONLY]

FREQUENCY
将频率更改为零(0)等效于暂停心跳。可以通过将频率更改为大于0的值来恢复心跳记录。

RETENTION_TIME
更改指定的心跳保留时间(以天为单位)。

PURGE_FREQUENCY
更改清除心跳表的重复间隔(以天为单位)。

TARGETONLY | NOTARGETONLY
对Oracle数据库,PostgreSQL和SQL Server有效。TARGETONLY通过禁用两个表的补充日志记录来修改现有的心跳种子和心跳表。它将删除现有调度程序作业以更新心跳表。
对Oracle数据库,PostgreSQL和SQL Server有效。 NOTARGETONLY通过在两个表上启用补充日志记录来修改现有的心跳种子和心跳表。它创建一个新的调度程序作业以更新心跳表。
(PostgreSQL)这些选项可用于删除作业和过程(TARGETONLY)或用于添加作业和过程(NOTARGETONLY)。

举例:

GGSCI (oracle11g as ogg@orcl) 19> ALTER HEARTBEATTABLE FREQUENCY 60

2020-12-01 16:04:49  INFO    OGG-14029  Frequency of scheduler job ""ogg"."GG_UPDATE_HEARTBEATS"" modified.

GGSCI (oracle11g as ogg@orcl) 20> 

GGSCI (oracle11g as ogg@orcl) 20> ALTER HEARTBEATTABLE RETENTION_TIME 30

2020-12-01 16:05:01  INFO    OGG-14031  Retention time of heartbeats modified.

GGSCI (oracle11g as ogg@orcl) 21> 

GGSCI (oracle11g as ogg@orcl) 21> ALTER HEARTBEATTABLE PURGE_FREQUENCY 1

2020-12-01 16:05:07  INFO    OGG-14030  Frequency of purge scheduler job ""ogg"."GG_PURGE_HEARTBEATS"" modified.

3、DELETE HEARTBEATTABLE

使用DELETE HEARTBEATTABLE删除表,程序,调度和意见。此命令需要一个DBLOGIN。在CDB数据库上,需要PDB登录。

语法:
DELETE HEARTBEATTABLE group_name

group_name
要清理的进程的名称。

!
(感叹号)删除所有与通配符关联的心跳表条目,而无提示。

举例:

GGSCI (oracle11g as ogg@orcl) 14> delete heartbeattable 

2020-12-01 16:02:16  INFO    OGG-14007  Heartbeat seed table ""ogg"."GG_HEARTBEAT_SEED"" dropped.

2020-12-01 16:02:16  INFO    OGG-14009  Heartbeat table ""ogg"."GG_HEARTBEAT"" dropped.

2020-12-01 16:02:16  INFO    OGG-14011  Heartbeat history table ""ogg"."GG_HEARTBEAT_HISTORY"" dropped.

2020-12-01 16:02:16  INFO    OGG-14026  Heartbeat lag view ""ogg"."GG_LAG"" dropped.

2020-12-01 16:02:16  INFO    OGG-14028  Heartbeat lag history view ""ogg"."GG_LAG_HISTORY"" dropped.

2020-12-01 16:02:16  INFO    OGG-14013  Procedure ""ogg"."GG_UPDATE_HB_TAB"" dropped.

2020-12-01 16:02:16  INFO    OGG-14020  Procedure ""ogg"."GG_PURGE_HB_TAB"" dropped.

2020-12-01 16:02:16  INFO    OGG-14015  Scheduler job ""ogg"."GG_UPDATE_HEARTBEATS"" dropped.

2020-12-01 16:02:16  INFO    OGG-14022  Scheduler job ""ogg"."GG_PURGE_HEARTBEATS"" dropped.

4、

使用INFO HEARTBEATTABLE约在数据库中配置的心跳表显示的信息。
此命令需要一个DBLOGIN。在CDB数据库上,需要PDB登录。

语法:
INFO HEARTBEATTABLE

举例:

GGSCI (oracle11g as ogg@orcl) 22> INFO HEARTBEATTABLE

HEARTBEAT table ogg.gg_heartbeat exists.

HEARTBEAT table ogg.gg_heartbeat_seed exists.

HEARTBEAT table ogg.gg_heartbeat_history exists.

HEARTBEAT table ogg.gg_heartbeat supplemental logging ENABLED.

HEARTBEAT table ogg.gg_heartbeat_seed supplemental logging ENABLED.

HEARTBEAT table ogg.gg_heartbeat_history partitioning DISABLED.

Frequency interval: 60 seconds.

Purge frequency interval: 1 days.

Retention time: 30 days.

5、UPGRADE HEARTBEATTABLE

对Oracle,PostgreSQL有效。
使用UPGRADE HEARTBEATTABLE改变心跳表和滞后用的Oracle GoldenGate版本创建的视图19C之前添加额外的列。这些额外的列用于跟踪提取重新启动位置。此命令在心跳设置中失败,在该心跳设置中表和视图已经具有多余的列。
此命令需要一个DBLOGIN。在CDB数据库上,需要PDB登录。
(PostgreSQL)使用此命令将LOGBSN列添加到心跳表。

语法:
UPGRADE HEARTBEATTABLE

Related Posts