Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions CN/modules/ROOT/pages/master/operation_guide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,28 @@ pg_upgrade https://www.postgresql.org/docs/current/pgupgrade.html[文档]概述

这种升级方法可以用内置的逻辑复制工具和外部的逻辑复制系统如pglogical,Slony,Londiste,和Bucardo。

==== 切换写入前同步序列状态

内置逻辑复制会复制表行,其中包括标识列已经生成的值。底层序列的计数更新保留在发布端。准备订阅端的模式时,使用与发布端一致的序列定义。

切换时,停止发布端的应用写入和序列调用,等待订阅端完成表同步并应用剩余变更。同步序列状态期间,保持订阅端应用写入关闭。在发布端读取每个应用序列的状态。

[source,sql]
----
SELECT last_value, is_called FROM public.invoice_id_seq;
----

例如,发布端返回 `last_value = 842` 和 `is_called = true` 时,在订阅端执行以下语句。

[source,sql]
----
SELECT pg_catalog.setval('public.invoice_id_seq'::regclass, 842, true);
----

同时复制 `last_value` 和 `is_called`。如果 `is_called` 为 `true` 且增量为 `1`,下一个值就是 `843`;如果为 `false`,下次调用直接返回传给 `setval` 的值。使用缓存时,记录的值可能领先于最近发放的 ID。选择安全的起点时,还要考虑显式写入表中的 ID。

同步后先禁用订阅,再将写入切换到新主库。对照已迁移的数据验证第一个自动生成的值。

== 使用 pg_upgrade 将 PostgreSQL 升级到 IvorySQL

`pg_upgrade` 支持将原生 PostgreSQL 集群升级到 IvorySQL。当源集群为原生 PostgreSQL ,而目标为 IvorySQL 集群时,必须使用 `-g`(`--using-ora-pg`)参数。
Expand Down
22 changes: 22 additions & 0 deletions EN/modules/ROOT/pages/master/operation_guide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,28 @@ We can also create a fallback server using logical replication of an updated ver

This upgrade method can be used with built-in logical replication tools and external logical replication systems such as pglogical, Slony, Londiste, and Bucardo.

==== Transfer sequence state before switching writers

Built-in logical replication copies table rows, including values generated by identity columns. Advances to the underlying sequences stay on the publisher. Create the sequences with matching definitions on the subscriber as part of schema preparation.

At cutover, stop application writes and sequence use on the publisher, and let the subscriber finish table synchronization and apply the remaining changes. Keep subscriber application writers stopped while copying sequence state. On the publisher, read each application sequence's state.

[source,sql]
----
SELECT last_value, is_called FROM public.invoice_id_seq;
----

For example, if the publisher shows `last_value = 842` and `is_called = true`, run the following on the subscriber.

[source,sql]
----
SELECT pg_catalog.setval('public.invoice_id_seq'::regclass, 842, true);
----

Copy `is_called` along with `last_value`. With `true`, a sequence with increment `1` returns `843` next. With `false`, the next call returns the value passed to `setval`. For cached sequences, the recorded value can be ahead of the most recently issued ID. Also account for IDs loaded explicitly into the table when choosing a safe starting point.

After synchronizing state, disable the subscription before routing writes to the new primary. Verify the first generated value against the migrated data.

== Use pg_upgrade to upgrade PostgreSQL to IvorySQL

`pg_upgrade` supports upgrading native PostgreSQL clusters to IvorySQL. When the source cluster is native PostgreSQL and the target is an IvorySQL cluster, the `-g`(`--using-ora-pg`)parameter must be used.
Expand Down
Loading