Skip to content

Commit 249e979

Browse files
authored
Merge pull request #225 from jiaoshuntian/m_p2ivy
Add guide for Upgrading from PostgreSQL to IvorySQL
2 parents 631d140 + 8e3b088 commit 249e979

File tree

2 files changed

+211
-0
lines changed

2 files changed

+211
-0
lines changed

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

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,111 @@ 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+
==== 第二步:停止源 PostgreSQL 集群
180+
181+
[source,bash]
182+
----
183+
/usr/lib/postgresql/16/bin/pg_ctl -D /data/pg/data stop
184+
----
185+
186+
==== 第三步:运行升级检查(可选)
187+
188+
使用 `-c` 仅做兼容性检查,不修改任何数据:
189+
190+
[source,bash]
191+
----
192+
/opt/ivorysql/bin/pg_upgrade \
193+
-b /usr/lib/postgresql/16/bin \ # 源 PG 可执行文件目录
194+
-B /opt/ivorysql/bin \ # 目标 IvorySQL 可执行文件目录
195+
-d /data/pg/data \ # 源 PG 数据目录
196+
-D /data/ivorysql/data \ # 目标 IvorySQL 数据目录
197+
-g \ # 源为 PostgreSQL,目标为 IvorySQL
198+
-c # 仅检查,不升级
199+
----
200+
201+
==== 第四步:执行升级
202+
203+
[source,bash]
204+
----
205+
/opt/ivorysql/bin/pg_upgrade \
206+
-b /usr/lib/postgresql/16/bin \
207+
-B /opt/ivorysql/bin \
208+
-d /data/pg/data \
209+
-D /data/ivorysql/data \
210+
-g
211+
----
212+
213+
==== 第五步:启动 IvorySQL 并验证
214+
215+
[source,bash]
216+
----
217+
/opt/ivorysql/bin/pg_ctl -D /data/ivorysql/data start
218+
219+
# 验证数据库是否正常
220+
/opt/ivorysql/bin/psql -p 5432 -c "SELECT version();"
221+
----
222+
223+
==== 第六步:清理旧集群
224+
225+
升级完成后,`pg_upgrade` 会生成一个清理脚本:
226+
227+
[source,bash]
228+
----
229+
./delete_old_cluster.sh
230+
----
231+
232+
=== 常用参数速查
233+
234+
[cols="1,2,2"]
235+
|===
236+
| 参数 | 长选项 | 说明
237+
238+
| `-b` | `--old-bindir` | 源集群可执行文件目录
239+
| `-B` | `--new-bindir` | 目标集群可执行文件目录
240+
| `-d` | `--old-datadir` | 源集群数据目录
241+
| `-D` | `--new-datadir` | 目标集群数据目录
242+
| `-g` | `--using-ora-pg` | 源为 PostgreSQL 升级到 IvorySQL
243+
| `-p` | `--old-port` | 源集群端口
244+
| `-P` | `--new-port` | 目标集群 PG 端口
245+
| `-q` | `--old-oraport` | 源集群 Oracle 端口
246+
| `-Q` | `--new-oraport` | 目标集群 Oracle 端口
247+
| `-j` | `--jobs` | 并行进程数
248+
| `-k` | `--link` | 使用硬链接替代文件复制
249+
| `-c` | `--check` | 仅检查兼容性,不执行升级
250+
| `-v` | `--verbose` | 输出详细日志
251+
|===
252+
253+
=== 注意事项
254+
255+
* `-g` 参数仅在 **源为纯 PostgreSQL 集群**、目标为 **IvorySQL** 时使用。若源集群已是 IvorySQL,则无需此参数。
256+
* 升级期间源集群和目标集群均须处于停止状态。
257+
* 升级前务必对源集群做完整备份。
153258

154259
== 管理IvorySQL版本
155260

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

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

145251
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)