Skip to content
Database

手动复制常见问题

Common questions and considerations when setting up manual replication.

应该使用哪个连接字符串? #

🌐 Which connection string should be used?

对于逻辑复制,请使用直接连接字符串。通过连接池(如 Supavisor)的连接将无法工作。

🌐 Use the direct connection string for logical replication. Connections through a pooler, such as Supavisor, will not work.

正在使用的工具不支持IPv6 #

🌐 The tool in use does not support IPv6

你可以为你的项目启用 IPv4 插件。

🌐 You can enable the IPv4 add-on for your project.

可以在仪表板中配置复制吗? #

🌐 Can replication be configured in the Dashboard?

你可以在仪表板中查看发布并更改它们的已发布操作和表选择。对于其余的设置,使用SQL 编辑器、CLI 或你的消费者设置流程。外部消费者需要单独连接和操作;仪表板不管理手动复制管道。

🌐 You can inspect publications and change their published operations and table selection in the Dashboard. Use the SQL Editor, a CLI, or your consumer's setup flow for the remaining setup. Connect and operate the external consumer separately; the Dashboard doesn't manage a manual replication pipeline.

如何配置数据库以实现复制? #

🌐 How to configure database settings for replication?

使用 Supabase CLI,你可以配置数据库设置来优化它们以满足你的复制需求。这些值会根据你的数据库大小和活动情况有所不同。

🌐 Using the Supabase CLI, you can configure database settings to optimize them for your replication needs. These values can vary depending on your database size and activity.

有哪些重要的配置选项? #

🌐 What are some important configuration options?

一些比较重要的选项需要注意的是:

🌐 Some of the more important options to be aware of are:

  • max_wal_size:自动检查点之间写入 WAL 的软限制。在某些情况下,Postgres 可能会超过这个限制。
  • max_slot_wal_keep_size:在检查点时间,每个槽保留的 WAL 有上限。-1 让复制槽保留无限的 WAL。有限的上限可能会导致滞后的槽丢失所需的 WAL。
  • wal_keep_size:为备用服务器保留的最小旧 WAL 数量。它不会替代每个槽的限制。
  • max_wal_senders:备用服务器、逻辑复制消费者和流式备份的最大并发 WAL 发送进程数。

根据消费者预期的最大滞后或停机时间以及数据库的 WAL 生成速率来确定 WAL 的保留大小。更高的值可以降低消费者需要进行新初始同步的风险,但可能会占用更多的数据库存储空间。监控每个 slot 的保留 WAL 和 wal_status,不要把配置的限制当作保证。

🌐 Size WAL retention for the consumer's maximum expected lag or downtime and the database's WAL generation rate. Higher values reduce the risk that a consumer needs a new initial sync, but can use more database storage. Monitor each slot's retained WAL and wal_status instead of treating a configured limit as a guarantee.

XMIN 是什么,应该使用吗? #

🌐 What is XMIN and should it be used?

Xmin 是一种不同于逻辑复制的复制方式,只有在你的数据库无法使用逻辑复制时才应该使用,比如在旧版本的 Postgres 上。

🌐 Xmin is a different form of replication from logical replication and should only be used if logical replication is not available for your database, such as with older versions of Postgres.

Xmin 通过检查 xmin 系统列 来执行复制,并判断该行是否已经同步。

🌐 Xmin performs replication by checking the xmin system column and determining if that row has already been synchronized.

它不能捕捉数据的删除,不推荐使用,尤其是对于较大的数据库。

🌐 It does not capture deletion of data and is not recommended, particularly for larger databases.