-
Notifications
You must be signed in to change notification settings - Fork 25
Add guide for Upgrading from PostgreSQL to IvorySQL #227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -153,6 +153,114 @@ pg_upgrade https://www.postgresql.org/docs/current/pgupgrade.html[文档]概述 | |
|
|
||
| 这种升级方法可以用内置的逻辑复制工具和外部的逻辑复制系统如pglogical,Slony,Londiste,和Bucardo。 | ||
|
|
||
| == 使用 pg_upgrade 将 PostgreSQL 升级到 IvorySQL | ||
|
|
||
| `pg_upgrade` 支持将原生 PostgreSQL 集群升级到 IvorySQL。当源集群为原生 PostgreSQL ,而目标为 IvorySQL 集群时,必须使用 `-g`(`--using-ora-pg`)参数。 | ||
|
|
||
| 从 PostgreSQL 升级到 IvorySQL 属于“跨产品”迁移,建议在生产环境操作前完成完整的测试验证,并制定详细的回滚方案。 | ||
|
|
||
| === 参数说明 | ||
|
|
||
| [cols="1,3"] | ||
| |=== | ||
| | 参数 | 说明 | ||
|
|
||
| | `-g` / `--using-ora-pg` | ||
| | 表示源集群为 PostgreSQL ,而目标为 IvorySQL 集群。启用此选项后,`pg_upgrade` 在连接两端集群时统一使用 PostgreSQL 标准端口,从而正确处理升级。 | ||
| |=== | ||
|
|
||
| === 升级步骤 | ||
|
|
||
| ==== 第一步:初始化新 IvorySQL 集群 | ||
|
|
||
| [source,bash] | ||
| ---- | ||
| # 使用 IvorySQL 的 initdb 初始化新集群 | ||
| /opt/ivorysql/bin/initdb -D /data/ivorysql/data | ||
|
|
||
| # 停止新集群 | ||
| /opt/ivorysql/bin/pg_ctl -D /data/ivorysql/data stop | ||
| ---- | ||
|
|
||
| ==== 第二步:停止源 PostgreSQL 集群 | ||
|
|
||
| [source,bash] | ||
| ---- | ||
| /usr/lib/postgresql/16/bin/pg_ctl -D /data/pg/data stop | ||
| ---- | ||
|
|
||
| ==== 第三步:运行升级检查(可选) | ||
|
|
||
| 使用 `-c` 仅做兼容性检查,不修改任何数据: | ||
|
|
||
| [source,bash] | ||
| ---- | ||
| /opt/ivorysql/bin/pg_upgrade \ | ||
| -b /usr/lib/postgresql/16/bin \ # 源 PG 可执行文件目录 | ||
| -B /opt/ivorysql/bin \ # 目标 IvorySQL 可执行文件目录 | ||
| -d /data/pg/data \ # 源 PG 数据目录 | ||
| -D /data/ivorysql/data \ # 目标 IvorySQL 数据目录 | ||
| -g \ # 源为 PostgreSQL,目标为 IvorySQL | ||
| -c # 仅检查,不升级 | ||
| ---- | ||
|
|
||
| ==== 第四步:执行升级 | ||
|
|
||
| [source,bash] | ||
| ---- | ||
| /opt/ivorysql/bin/pg_upgrade \ | ||
| -b /usr/lib/postgresql/16/bin \ | ||
| -B /opt/ivorysql/bin \ | ||
| -d /data/pg/data \ | ||
| -D /data/ivorysql/data \ | ||
| -g | ||
| ---- | ||
|
|
||
| ==== 第五步:启动 IvorySQL 并验证 | ||
|
|
||
| [source,bash] | ||
| ---- | ||
| /opt/ivorysql/bin/pg_ctl -D /data/ivorysql/data start | ||
|
|
||
| # 验证数据库是否正常 | ||
| /opt/ivorysql/bin/psql -p 5433 -c "SELECT version();" | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why use 5433 port? |
||
| ---- | ||
|
|
||
| ==== 第六步:清理旧集群 | ||
|
|
||
| 升级完成后,`pg_upgrade` 会生成一个清理脚本: | ||
|
|
||
| [source,bash] | ||
| ---- | ||
| ./delete_old_cluster.sh | ||
| ---- | ||
|
|
||
| === 常用参数速查 | ||
|
|
||
| [cols="1,2,2"] | ||
| |=== | ||
| | 参数 | 长选项 | 说明 | ||
|
|
||
| | `-b` | `--old-bindir` | 源集群可执行文件目录 | ||
| | `-B` | `--new-bindir` | 目标集群可执行文件目录 | ||
| | `-d` | `--old-datadir` | 源集群数据目录 | ||
| | `-D` | `--new-datadir` | 目标集群数据目录 | ||
| | `-g` | `--using-ora-pg` | 源为 PostgreSQL 升级到 IvorySQL | ||
| | `-p` | `--old-port` | 源集群端口 | ||
| | `-P` | `--new-port` | 目标集群 PG 端口 | ||
| | `-q` | `--old-oraport` | 源集群 Oracle 端口 | ||
| | `-Q` | `--new-oraport` | 目标集群 Oracle 端口 | ||
| | `-j` | `--jobs` | 并行进程数 | ||
| | `-k` | `--link` | 使用硬链接替代文件复制 | ||
| | `-c` | `--check` | 仅检查兼容性,不执行升级 | ||
| | `-v` | `--verbose` | 输出详细日志 | ||
| |=== | ||
|
|
||
| === 注意事项 | ||
|
|
||
| * `-g` 参数仅在 **源为纯 PostgreSQL 集群**、目标为 **IvorySQL** 时使用。若源集群已是 IvorySQL,则无需此参数。 | ||
| * 升级期间源集群和目标集群均须处于停止状态。 | ||
| * 升级前务必对源集群做完整备份。 | ||
|
|
||
| == 管理IvorySQL版本 | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to stop new cluster since it is just initialized.