

# 了解 pgactive 架构
<a name="Appendix.PostgreSQL.CommonDBATasks.pgactive.schema"></a>

pgactive 架构管理 RDS for PostgreSQL 中的主动-主动复制。此架构包含用于存储复制配置和状态信息的表。

**注意**  
pgactive 架构正在演进中，可能会发生变更。不要直接修改这些表中的数据。

pgactive 架构中的键表包括：
+ `pgactive_nodes` – 存储有关主动-主动复制组中的节点的信息。
+ `pgactive_connections` – 存储每个节点的连接详细信息。

## pgactive\$1nodes
<a name="Appendix.PostgreSQL.CommonDBATasks.pgactive.schema.nodes"></a>

pgactive\$1nodes 存储有关参与主动-主动复制组的节点的信息。


| 列 | 类型 | 排序规则 | 是否可为 null | 默认值 | 
| --- | --- | --- | --- | --- | 
| node\$1sysid | 文本 | – | 不为 null | – | 
| node\$1timeline | oid | – | 不为 null | – | 
| node\$1dboid | oid | – | 不为 null | – | 
| node\$1status | char | – | 不为 null | – | 
| node\$1name | 文本 | – | 不为 null | – | 
| node\$1dsn | 文本 | – | 不为 null | – | 
| node\$1init\$1from\$1dsn | 文本 | – | 不为 null | – | 
| node\$1read\$1only | 布尔值 | – | – | false | 
| node\$1seq\$1id | smallint | – | 不为 null | – | 

**node\$1sysid**  
在 `pgactive_create_group` 或 `pgactive_join_group` 期间生成的节点的唯一 ID

**node\$1status**  
节点的准备情况：  
+ **b** – 开始设置
+ **i** – 正在初始化
+ **c** – 追赶
+ **o** – 创建出站插槽
+ **r** – 已就绪
+ **k** – 已终止
此列不指明节点已连接还是已断开连接。

**node\$1name**  
用户提供的唯一节点名称。

**node\$1dsn**  
连接字符串或用户映射名称。

**node\$1init\$1from\$1dsn**  
从中创建了此节点的 DSN。

## pgactive\$1connection
<a name="Appendix.PostgreSQL.CommonDBATasks.pgactive.schema.connection"></a>

pgactive\$1connections 存储每个节点的连接详细信息。


| 列 | 类型 | 排序规则 | 是否可为 null | 默认值 | 
| --- | --- | --- | --- | --- | 
| conn\$1sysid | 文本 | none | 不为 null | none | 
| conn\$1timeline | oid | none | 不为 null | none | 
| conn\$1dboid | oid | none | 不为 null | none | 
| conn\$1dsn | 文本 | none | 不为 null | none | 
| conn\$1apply\$1delay | 整数 | none | none | none | 
| conn\$1replication\$1sets | 文本 | none | none | none | 

conn\$1sysid  
此条目所指的节点的节点标识符。

conn\$1dsn  
与 pgactive.pgactive\$1nodes `node_dsn` 相同。

conn\$1apply\$1delay  
如果设置此参数，则将设定从远程节点应用每个事务前的等待时间（以毫秒为单位）。主要用于调试。如果为 null，则全局默认值将适用。

## 使用复制集
<a name="Appendix.PostgreSQL.CommonDBATasks.pgactive.replication"></a>

复制集决定要在复制操作中包含或排除的表。默认情况下，除非您使用以下函数另行指定，否则将复制所有表：
+ `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()` 函数。