了解 pgactive 架构
pgactive 架构管理 RDS for PostgreSQL 中的主动-主动复制。此架构包含用于存储复制配置和状态信息的表。
注意
pgactive 架构正在演进中,可能会发生变更。不要直接修改这些表中的数据。
pgactive 架构中的键表包括:
-
pgactive_nodes– 存储有关主动-主动复制组中的节点的信息。 -
pgactive_connections– 存储每个节点的连接详细信息。
pgactive_nodes
pgactive_nodes 存储有关参与主动-主动复制组的节点的信息。
列 |
类型 |
排序规则 |
是否可为 null |
默认 |
|---|---|---|---|---|
| node_sysid | 文本 | – | 不为 null | – |
| node_timeline | oid | – | 不为 null | – |
| node_dboid | oid | – | 不为 null | – |
| node_status | char | – | 不为 null | – |
| node_name | 文本 | – | 不为 null | – |
| node_dsn | 文本 | – | 不为 null | – |
| node_init_from_dsn | 文本 | – | 不为 null | – |
| node_read_only | 布尔值 | – | – | false |
| node_seq_id | smallint | – | 不为 null | – |
- node_sysid
-
在
pgactive_create_group或pgactive_join_group期间生成的节点的唯一 ID - node_status
-
节点的准备情况:
-
b – 开始设置
-
i – 正在初始化
-
c – 追赶
-
o – 创建出站插槽
-
r – 已就绪
-
k – 已终止
注意
此列不指明节点已连接还是已断开连接。
-
- node_name
-
用户提供的唯一节点名称。
- node_dsn
-
连接字符串或用户映射名称。
- node_init_from_dsn
-
从中创建了此节点的 DSN。
pgactive_connection
pgactive_connections 存储每个节点的连接详细信息。
| 列 | 类型 | 排序规则 | 是否可为 null | 默认 |
|---|---|---|---|---|
| conn_sysid | 文本 | none | 不为 null | none |
| conn_timeline | oid | none | 不为 null | none |
| conn_dboid | oid | none | 不为 null | none |
| conn_dsn | 文本 | none | 不为 null | none |
| conn_apply_delay | 整数 | none | none | none |
| conn_replication_sets | 文本 | none | none | none |
- conn_sysid
-
此条目所指的节点的节点标识符。
- conn_dsn
-
与 pgactive.pgactive_nodes
node_dsn相同。 - conn_apply_delay
-
如果设置此参数,则将设定从远程节点应用每个事务前的等待时间(以毫秒为单位)。主要用于调试。如果为 null,则全局默认值将适用。
使用复制集
复制集决定要在复制操作中包含或排除的表。默认情况下,除非您使用以下函数另行指定,否则将复制所有表:
-
pgactive_exclude_table_replication_set()– 从复制中排除指定的表 -
pgactive_include_table_replication_set()– 在复制中包含指定的表
注意
在配置复制集之前,请注意以下几点:
-
仅在运行
pgactive_create_group()后且在运行pgactive_join_group()之前,才能配置表包含或排除。 -
使用
pgactive_exclude_table_replication_set()后,您将无法使用pgactive_include_table_replication_set()。 -
使用
pgactive_include_table_replication_set()后,您将无法使用pgactive_exclude_table_replication_set()。
系统会根据您的初始配置通过不同的方式处理新创建的表:
-
如果排除表:在
pgactive_join_group()之后创建的任何新表都将自动包含在复制中。 -
如果包含表:在
pgactive_join_group()之后创建的任何新表都将自动从复制中排除。
要查看特定表的复制集配置,请使用 pgactive.pgactive_get_table_replication_sets() 函数。