监控复制和故障切换

本主题提供了有关如何监控账户复制进度、历史记录和成本的信息。

使用 Snowsight 监控复制

To monitor the replication progress and status for replication and failover groups in an organization, use the Replication page in Snowsight.

您可以查看刷新操作的状态和详细信息,其中包括:

  • 最近刷新操作的当前状态。
  • 副本滞后时间(自上次刷新操作以来的时间)。
  • 各组的副本滞后时间分布。
  • 下一次计划刷新操作的日期和时间。

Note

  • Snowsight lists the replication and failover groups for which your role has the MONITOR, OWNERSHIP, or REPLICATE privilege on.
  • 刷新操作详细信息仅对具有 ACCOUNTADMIN 角色或组的 OWNERSHIP 权限的用户可用。
  • 您必须登录源账户或目标账户才能查看刷新操作详细信息。如果没有,系统将提示您登录。

源账户和目标账户都必须使用相同的连接类型(公共互联网)。否则,登录目标账户将失败。

  • Currently, if your account uses private connectivity, you can’t use Snowsight to create or modify groups or connection objects. However, you can use Snowsight to monitor groups that were created using SQL.

要查看每个复制组或​​故障转移组的复制状态,请完成以下步骤:

  1. Sign in to Snowsight.
  2. In the navigation menu, select Admin » Accounts.
  3. Select Replication and then select Groups.

The Groups page displays refresh operation details for all the groups for which your role has a privilege to view. You can use the tiles to filter the view.

  • For example, if the Status tile indicates there are failed refresh operations, you can select the tile to investigate the group(s) with failures.

  • The lag time in the Longest Replication lag tile refers to the duration of time since the last refresh operation. This is the length of time that the secondary replication or failover group lags behind the primary group. The longest lag time is the length of time since the oldest secondary replication group was last refreshed.

    For example, if you have three failover groups, fg_1, fg_2, fg_3, with independent replication schedules of 10 minutes, 2 hours, and 12 hours respectively, the longest lag time could be as long as 12 hours. If fg_3, however, was recently refreshed in the target account, its lag time resets to 0 and a different failover group could have a longer lag time.

  • You can select an individual bar in the Group Lag Distribution tile to filter the results to an individual group.

您还可以使用搜索字段或下拉菜单来筛选组:

  • You can search by replication or failover group name using the Search icon (search) box.
  • Choose Type to filter the results by replication or failover group.
  • Choose Replicating to filter by primary (select To) or secondary groups (select From).
  • Choose the Account icon (accounts) menu to filter the results by account name.
  • Choose Status to filter results by refresh operation status:
    • Refresh Cancelled
    • Refresh Failed
    • Refresh In Progress
    • Refresh Successful

您可以查看有关复制组和故障转移组的以下详细信息:

ColumnDescription
NameName of the replication or failover group.
Is Replicating

指示组是否正在复制 目标账户或 源账户复制。

如果此列包含 可用的目标,则不存在辅助复制组或故障转移组。可用目标的数量表示主要组可以复制到的目标账户数量。

Status

显示最新刷新操作的状态。

You must be signed in to the source or target account in order to access replication details. If you are not signed in, select Sign in to view refresh operation status for the secondary group.

源账户和目标账户都必须使用相同的连接类型(公共互联网)。否则,登录目标账户将失败。

Replication Lag

自上次刷新操作以来的时间长度。这是辅助复制组“滞后”于主要复制组的时间长度。

Next RefreshThe date and time of the next scheduled refresh operation.

You can select a replication or failover group to view detailed information about each refresh operation. For more information, see the section on replication history in Snowsight.

监控刷新操作的进度

本节提供了有关如何使用 Snowsight 或 SQL 监控特定复制组或故障转移组的复制进度的信息。

使用 Snowsight 监控刷新操作的进度

You can view the status of a refresh operation in progress and the details of historical refresh operations using Snowsight.

  1. Sign in to Snowsight.
  2. In the navigation menu, select Admin » Accounts.
  3. Select Replication, select Groups.
  4. 选择复制组或故障转移组的名称。

Tip

If your account uses private connectivity, you can still use Snowsight to monitor groups. Although creating or modifying groups or connection objects through Snowsight isn’t currently available with private connectivity, Snowsight can monitor the groups that you create using SQL.

For more information about the detailed view, see the section on replication history in Snowsight.

使用 SQL 监控刷新操作的进度

To monitor the progress of a replication or failover group refresh, query the REPLICATION_GROUP_REFRESH_PROGRESS, REPLICATION_GROUP_REFRESH_PROGRESS_BY_JOB, REPLICATION_GROUP_REFRESH_PROGRESS_ALL table function (in the Snowflake Information Schema).

示例

View the progress of the most recent refresh operation for the failover group myfg:

SELECT phase_name, start_time, end_time, progress, details
  FROM TABLE(INFORMATION_SCHEMA.REPLICATION_GROUP_REFRESH_PROGRESS('myfg'));

查看复制历史记录

You can view replication history using Snowsight or using SQL.

Note

您可以查看具有 MONITOR、OWNERSHIP 或 REPLICATE 权限的复制组和故障转移组的复制历史记录。

使用 Snowsight 查看复制历史记录

您可以在组的详细信息页面中查看特定复制组或故障转移组每个刷新操作的复制历史记录和详细信息。

  1. Sign in to Snowsight.
  2. In the navigation menu, select Admin » Accounts.
  3. Select Replication, select Groups.
  4. 选择复制组或故障转移组的名称。

您可以查看有关该组的以下信息:

  • 组类型(复制组或故障转移组)。
  • 复制计划(例如,每 10 分钟一次)。
  • 每次刷新操作的持续时间。
  • 副本滞后时间(自上次刷新操作以来的时间长度)。
  • 下一次计划刷新操作的日期和时间。

Tip

If your account uses private connectivity, you can still use Snowsight to monitor groups. Although creating or modifying groups or connection objects through Snowsight isn’t currently available with private connectivity, Snowsight can monitor the groups that you create using SQL.

您可以按状态和时间段对页面上的数据进行筛选:

  • Choose Status to filter results by refresh operation status:

    • Refresh Cancelled
    • Refresh Failed
    • Refresh In Progress
    • Refresh Successful
  • Choose Duration to show refresh operation details for:

    • Last hour
    • Last 24 hours
    • Last 7 days
    • All

    Selecting All displays the last 14 days of refresh operations.

每次刷新操作的详细信息包括以下列:

ColumnDescription
Query IDQuery ID of the refresh operation.
StatusDisplays the status of the refresh operation. Valid values include Successful, Failed, In Progress.
EndedDate and time the refresh operation ended.
Duration

刷新操作完成所需的时间长度。

The duration period is broken down and color coded by replication phase. The width of each colored segment indicates the portion of the time spent in that phase.

The image below is for reference only. This graph is available when you select the refresh operation for additional details.

Color coded replication phase and duration.
TransferredThe number of bytes replicated.
ObjectsThe number of objects replicated.

选择一行以查看有关特定刷新操作的其他详细信息,包括:

  • 每个复制阶段的持续时间。
  • 错误消息(针对失败的刷新操作)。
  • 按类型和数量复制的数据库对象列表。
  • 复制的数据库数量和数据库名称。

使用 SQL 查看复制历史记录

要查看指定日期范围内特定复制组或故障转移组的复制历史记录,请查询以下内容之一:

示例

Query the Information Schema REPLICATION_GROUP_REFRESH_HISTORY table function to view the account replication history of failover group myfg in the last 7 days:

SELECT PHASE_NAME, START_TIME, END_TIME, TOTAL_BYTES, OBJECT_COUNT
  FROM TABLE(information_schema.replication_group_refresh_history('myfg'))
  WHERE START_TIME >= CURRENT_DATE() - INTERVAL '7 days';

查询 Account Usage REPLICATION_GROUP_REFRESH_HISTORY 视图,以查看当月账户复制历史记录:

SELECT REPLICATION_GROUP_NAME, PHASE_NAME, START_TIME, END_TIME, TOTAL_BYTES, OBJECT_COUNT
  FROM snowflake.account_usage.replication_group_refresh_history
  WHERE START_TIME >= DATE_TRUNC('month', CURRENT_DATE());

监控复制成本

要监控复制的 Credit 使用量,请查询以下内容之一:

示例

查询 REPLICATION_GROUP_USAGE_HISTORY 表函数,以查看最近 7 天用于账户复制的 Credit 使用情况:

SELECT start_time, end_time, replication_group_name, credits_used, bytes_transferred
  FROM TABLE(information_schema.replication_group_usage_history(date_range_start=>DATEADD('day', -7, CURRENT_DATE())));

查询 Account Usage REPLICATION_GROUP_USAGE_HISTORY 视图,以查看当月复制组或故障转移组用于账户复制的 Credit 使用情况历史记录:

SELECT start_time, 
  end_time, 
  replication_group_name, 
  credits_used, 
  bytes_transferred
FROM snowflake.account_usage.replication_group_usage_history
WHERE start_time >= DATE_TRUNC('month', CURRENT_DATE());

监控数据库的复制成本

对于包含在复制或故障转移组中的单个数据库的复制成本,可以通过检索数据库的复制字节数并将其与使用的 Credit 相关联来计算。

示例

查询 Account Usage 视图

以下示例计算最近 30 天某个复制组中数据库的复制成本。

  1. 查询 REPLICATION_GROUP_REFRESH_HISTORY Account Usage 视图,并计算每个数据库复制的字节数总和。

    For example, to calculate the sum of the number of bytes replicated for databases in the replication group myrg in the last 30 days:

    SELECT SUM(value:totalBytesToReplicate) as sum_database_bytes
      FROM snowflake.account_usage.replication_group_refresh_history rh,
     LATERAL FLATTEN(input => rh.total_bytes:databases)
      WHERE rh.replication_group_name = 'MYRG' AND
         rh.start_time >= CURRENT_DATE() - INTERVAL '30 days';

请注意数据库字节数总和的输出:

+--------------------+
| SUM_DATABASE_BYTES |
%--------------------%
|              22016 |
+--------------------+
  1. Query the REPLICATION_GROUP_USAGE_HISTORY Account Usage view and calculate the sum of the number of credits used and the sum of the bytes transferred for replication.

    For example, to calculate the sum of the number of credits used and the sum of the bytes transferred for replication of the replication group myrg in the last 30 days:

    SELECT SUM(credits_used) AS credits_used, SUM(bytes_transferred) AS bytes_transferred
      FROM snowflake.account_usage.replication_group_usage_history
      WHERE replication_group_name = 'MYRG' AND
         start_time >= CURRENT_DATE() - INTERVAL '30 days';

请注意 Credit 使用总数和传输字节数总和的输出:

+--------------+-------------------+
| CREDITS_USED | BYTES_TRANSFERRED |
|--------------+-------------------|
|  1.357923604 |             22013 |
+--------------+-------------------+
  1. Calculate the replication costs for databases using the values of the bytes transferred for databases, sum of the credits used, and the sum of all bytes transferred for replication from the previous two steps:

    (<database_bytes_transferred> / <bytes_transferred>) * <credits_used>

例如:

(22016 / 22013) * 1.357923604 = 1.35810866)

查询 Information Schema 表函数

如需了解最近 14 天的刷新操作,可查询关联的 Information Schema 表函数。

  1. Query the REPLICATION_GROUP_REFRESH_HISTORY table function to view the sum of the number of bytes copied for database replication for the replication group myrg:

    SELECT SUM(value:totalBytesToReplicate)
      FROM TABLE(information_schema.replication_group_refresh_history('myrg')) AS rh,
      LATERAL FLATTEN(input => total_bytes:databases)
      WHERE rh.phase_name = 'COMPLETED' AND
         rh.start_time >= CURRENT_DATE() - INTERVAL '14 days';
  2. Query the REPLICATION_GROUP_USAGE_HISTORY table function to view sum of the number of credits used and the sum of the bytes transferred for replication for the replication group myrg:

    SELECT SUM(credits_used), SUM(bytes_transferred)
      FROM TABLE(information_schema.replication_group_usage_history(
     date_range_start => DATEADD('day', -14, CURRENT_DATE()),
     replication_group_name => 'myrg'));