Skip to content

Commit c3a5a52

Browse files
committed
Add guide for Upgrading from PostgreSQL to IvorySQL
1 parent 823ac9e commit c3a5a52

File tree

2 files changed

+217
-0
lines changed

2 files changed

+217
-0
lines changed

CN/modules/ROOT/pages/4.4.adoc

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,114 @@ pg_upgrade https://www.postgresql.org/docs/current/pgupgrade.html[文档]概述
153153

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

156+
== 使用 pg_upgrade 将 PostgreSQL 升级到 IvorySQL
157+
158+
`pg_upgrade` 支持将原生 PostgreSQL 集群升级到 IvorySQL。当源集群为原生 PostgreSQL ,而目标为 IvorySQL 集群时,必须使用 `-g`(`--using-ora-pg`)参数。
159+
160+
从 PostgreSQL 升级到 IvorySQL 属于“跨产品”迁移,建议在生产环境操作前完成完整的测试验证,并制定详细的回滚方案。
161+
162+
=== 参数说明
163+
164+
[cols="1,3"]
165+
|===
166+
| 参数 | 说明
167+
168+
| `-g` / `--using-ora-pg`
169+
| 表示源集群为 PostgreSQL ,而目标为 IvorySQL 集群。启用此选项后,`pg_upgrade` 在连接两端集群时统一使用 PostgreSQL 标准端口,从而正确处理升级。
170+
|===
171+
172+
=== 升级步骤
173+
174+
==== 第一步:初始化新 IvorySQL 集群
175+
176+
[source,bash]
177+
----
178+
# 使用 IvorySQL 的 initdb 初始化新集群
179+
/opt/ivorysql/bin/initdb -D /data/ivorysql/data
180+
181+
# 停止新集群
182+
/opt/ivorysql/bin/pg_ctl -D /data/ivorysql/data stop
183+
----
184+
185+
==== 第二步:停止源 PostgreSQL 集群
186+
187+
[source,bash]
188+
----
189+
/usr/lib/postgresql/16/bin/pg_ctl -D /data/pg/data stop
190+
----
191+
192+
==== 第三步:运行升级检查(可选)
193+
194+
使用 `-c` 仅做兼容性检查,不修改任何数据:
195+
196+
[source,bash]
197+
----
198+
/opt/ivorysql/bin/pg_upgrade \
199+
-b /usr/lib/postgresql/16/bin \ # 源 PG 可执行文件目录
200+
-B /opt/ivorysql/bin \ # 目标 IvorySQL 可执行文件目录
201+
-d /data/pg/data \ # 源 PG 数据目录
202+
-D /data/ivorysql/data \ # 目标 IvorySQL 数据目录
203+
-g \ # 源为 PostgreSQL,目标为 IvorySQL
204+
-c # 仅检查,不升级
205+
----
206+
207+
==== 第四步:执行升级
208+
209+
[source,bash]
210+
----
211+
/opt/ivorysql/bin/pg_upgrade \
212+
-b /usr/lib/postgresql/16/bin \
213+
-B /opt/ivorysql/bin \
214+
-d /data/pg/data \
215+
-D /data/ivorysql/data \
216+
-g
217+
----
218+
219+
==== 第五步:启动 IvorySQL 并验证
220+
221+
[source,bash]
222+
----
223+
/opt/ivorysql/bin/pg_ctl -D /data/ivorysql/data start
224+
225+
# 验证数据库是否正常
226+
/opt/ivorysql/bin/psql -p 5433 -c "SELECT version();"
227+
----
228+
229+
==== 第六步:清理旧集群
230+
231+
升级完成后,`pg_upgrade` 会生成一个清理脚本:
232+
233+
[source,bash]
234+
----
235+
./delete_old_cluster.sh
236+
----
237+
238+
=== 常用参数速查
239+
240+
[cols="1,2,2"]
241+
|===
242+
| 参数 | 长选项 | 说明
243+
244+
| `-b` | `--old-bindir` | 源集群可执行文件目录
245+
| `-B` | `--new-bindir` | 目标集群可执行文件目录
246+
| `-d` | `--old-datadir` | 源集群数据目录
247+
| `-D` | `--new-datadir` | 目标集群数据目录
248+
| `-g` | `--using-ora-pg` | 源为 PostgreSQL 升级到 IvorySQL
249+
| `-p` | `--old-port` | 源集群端口
250+
| `-P` | `--new-port` | 目标集群 PG 端口
251+
| `-q` | `--old-oraport` | 源集群 Oracle 端口
252+
| `-Q` | `--new-oraport` | 目标集群 Oracle 端口
253+
| `-j` | `--jobs` | 并行进程数
254+
| `-k` | `--link` | 使用硬链接替代文件复制
255+
| `-c` | `--check` | 仅检查兼容性,不执行升级
256+
| `-v` | `--verbose` | 输出详细日志
257+
|===
258+
259+
=== 注意事项
260+
261+
* `-g` 参数仅在 **源为纯 PostgreSQL 集群**、目标为 **IvorySQL** 时使用。若源集群已是 IvorySQL,则无需此参数。
262+
* 升级期间源集群和目标集群均须处于停止状态。
263+
* 升级前务必对源集群做完整备份。
156264

157265
== 管理IvorySQL版本
158266

EN/modules/ROOT/pages/4.4.adoc

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,115 @@ We can also create a fallback server using logical replication of an updated ver
143143

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

146+
== Use pg_upgrade to upgrade PostgreSQL to IvorySQL
147+
148+
`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.
149+
150+
Upgrading from PostgreSQL to IvorySQL is considered a "cross-product" migration. It is recommended to complete comprehensive testing and validation before performing the operation in a production environment, and to develop a detailed rollback plan.
151+
152+
=== Parameter description
153+
154+
[cols="1,3"]
155+
|===
156+
| parameter | description
157+
158+
| `-g` / `--using-ora-pg`
159+
| Indicates that the source cluster is PostgreSQL and the target is an IvorySQL cluster. When this option is enabled, `pg_upgrade` uniformly uses the PostgreSQL standard port when connecting to both clusters, ensuring proper handling of the upgrade.
160+
|===
161+
162+
=== Upgrade steps
163+
164+
==== Step 1: Initialize the new IvorySQL cluster
165+
166+
[source,bash]
167+
----
168+
# Use IvorySQL's initdb to initialize the new cluster
169+
/opt/ivorysql/bin/initdb -D /data/ivorysql/data
170+
171+
# Stop the new cluster
172+
/opt/ivorysql/bin/pg_ctl -D /data/ivorysql/data stop
173+
----
174+
175+
==== Step 2: Stop the source PostgreSQL cluster
176+
177+
[source,bash]
178+
----
179+
/usr/lib/postgresql/16/bin/pg_ctl -D /data/pg/data stop
180+
----
181+
182+
==== Step 3: Run the upgrade check (optional)
183+
184+
Use `-c` to perform compatibility checks only without modifying any data:
185+
186+
[source,bash]
187+
----
188+
/opt/ivorysql/bin/pg_upgrade \
189+
-b /usr/lib/postgresql/16/bin \ # Source PG executable directory
190+
-B /opt/ivorysql/bin \ # Target IvorySQL executable directory
191+
-d /data/pg/data \ # Source PG data directory
192+
-D /data/ivorysql/data \ # Target IvorySQL data directory
193+
-g \ # Source is PostgreSQL, target is IvorySQL
194+
-c # Check only, do not upgrade
195+
----
196+
197+
==== Step 4: Perform the upgrade
198+
199+
[source,bash]
200+
----
201+
/opt/ivorysql/bin/pg_upgrade \
202+
-b /usr/lib/postgresql/16/bin \
203+
-B /opt/ivorysql/bin \
204+
-d /data/pg/data \
205+
-D /data/ivorysql/data \
206+
-g
207+
----
208+
209+
==== Step 5: Start IvorySQL and verify
210+
211+
[source,bash]
212+
----
213+
/opt/ivorysql/bin/pg_ctl -D /data/ivorysql/data start
214+
215+
# Verify if the database is functioning properly
216+
/opt/ivorysql/bin/psql -p 5433 -c "SELECT version();"
217+
----
218+
219+
==== Step 6: Clean up the old cluster
220+
221+
After the upgrade is completed,`pg_upgrade` will generate a cleanup script:
222+
223+
[source,bash]
224+
----
225+
./delete_old_cluster.sh
226+
----
227+
228+
=== Quick reference for common parameters
229+
230+
[cols="1,2,2"]
231+
|===
232+
| Parameters | Long options | Description
233+
234+
| `-b` | `--old-bindir` | Source cluster executable directory
235+
| `-B` | `--new-bindir` | Target cluster executable directory
236+
| `-d` | `--old-datadir` | Source cluster data directory
237+
| `-D` | `--new-datadir` | Target cluster data directory
238+
| `-g` | `--using-ora-pg` | Upgrade from PostgreSQL to IvorySQL
239+
| `-p` | `--old-port` | Source cluster port
240+
| `-P` | `--new-port` | Target cluster PG port
241+
| `-q` | `--old-oraport` | Source cluster Oracle port
242+
| `-Q` | `--new-oraport` | Target cluster Oracle port
243+
| `-j` | `--jobs` | Number of parallel processes
244+
| `-k` | `--link` | Use hard links instead of file copying
245+
| `-c` | `--check` | Check compatibility only, do not perform the upgrade
246+
| `-v` | `--verbose` | Output detailed logs
247+
|===
248+
249+
=== Precautions
250+
251+
* The `-g` parameter is only used when the **source is a pure PostgreSQL cluster**、and the target is **IvorySQL** . If the source cluster is already IvorySQL, this parameter is not needed.
252+
* Both the source and target clusters must be in a stopped state during the upgrade.
253+
* Be sure to perform a complete backup of the source cluster before upgrading.
254+
146255
== Managing IvorySQL Versions
147256

148257
IvorySQL is based on PostgreSQL and is updated at the same frequency as PostgreSQL, with one major release per year and one minor release per quarter. IvorySQL {ivorysql-version} is based on PostgreSQL {pg-version}, and all versions of IvorySQL are backward compatible.The relevant version features can be viewed by looking at https://www.ivorysql.org/en/releases-page/[Official Website]。

0 commit comments

Comments
 (0)