Skip to content

Commit d680da5

Browse files
committed
Add guide for Upgrading from PostgreSQL to IvorySQL
1 parent 7b57b2e commit d680da5

File tree

2 files changed

+217
-0
lines changed

2 files changed

+217
-0
lines changed

CN/modules/ROOT/pages/master/operation_guide.adoc

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

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

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

154262
== 管理IvorySQL版本
155263

EN/modules/ROOT/pages/master/operation_guide.adoc

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

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

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

145254
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 5.0 is based on PostgreSQL 18.0, 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)