diff --git a/CN/modules/ROOT/pages/master/operation_guide.adoc b/CN/modules/ROOT/pages/master/operation_guide.adoc index 242feb9e..ef81cc1d 100644 --- a/CN/modules/ROOT/pages/master/operation_guide.adoc +++ b/CN/modules/ROOT/pages/master/operation_guide.adoc @@ -28,7 +28,9 @@ IvorySQL版本号由主要版本和次要版本组成。例如,IvorySQL 3.2 === 通过pg_dumpall升级数据 -传统的跨版本升级方法利用pg_dump/pg_dumpall逻辑备份导出数据库,然后在新版本中通过pg_restore进行还原。导出旧版本数据库时推荐使用新版本的pg_dump/pg_dumpall工具,可以利用最新的并行导出和还原功能,同时可以减少数据库膨胀问题。 +`pg_dumpall` 默认输出纯 SQL 脚本,其中包含集群中的数据库及角色、表空间等全局对象。请在目标集群用 `psql` 执行该脚本。使用 `pg_dump -Fc` 等归档格式备份单个数据库时,用 `pg_restore` 读取归档。 + +导出旧版集群时,使用目标版本的 `pg_dumpall` 程序。 ​逻辑备份与还原非常简单但速度比较慢,停机时间取决于数据库的大小,因此适合中小型数据库的升级。 @@ -37,11 +39,9 @@ IvorySQL版本号由主要版本和次要版本组成。例如,IvorySQL 3.2 1. 执行逻辑备份之前停止应用程序,确保没有数据更新,因为备份开始后的更新不会被导出。如有必要,可以修改/usr/local/pgsql/data/pg_hba.conf文件禁止其他人访问数据库。然后备份数据库: ``` -pg_dumpall > outputfile +pg_dumpall --file=outputfile ``` -> 如果已经安装了新版本的IvorySQL,可以使用新版本的pg_dumpall命令备份旧版本数据库。 - 2.停止旧版本的后台服务: ``` @@ -72,16 +72,17 @@ mv /usr/local/pgsql /usr/local/pgsql.old /usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data ``` -8.最后利用新版本的psql命令还原数据: +*8.* 使用目标版本的 `psql` 执行 SQL 文件。`-X` 选项会跳过本地 psql 启动文件。 ``` -/usr/local/pgsql/bin/psql -d postgres -f outputfile +/usr/local/pgsql/bin/psql -X -d postgres -f outputfile ``` -为了减少停机时间,可以将新版本的IvorySQL安装到另一个目录,同时使用不同的端口启动服务。然后同时执行数据库的导出和导入: +需要同时运行新旧版本时,可将目标版本安装到其他目录,并使用独立端口启动。先保存源集群的转储,确认 `pg_dumpall` 成功后再在目标集群执行。 ``` -pg_dumpall -p 5432 | psql -d postgres -p 5433 +pg_dumpall -p 5432 --file=outputfile +psql -X -d postgres -p 5433 -f outputfile ``` ​执行以上操作时,新旧版本的后台服务同时运行,新版本使用5433端口,旧版本使用5432端口。 diff --git a/EN/modules/ROOT/pages/master/operation_guide.adoc b/EN/modules/ROOT/pages/master/operation_guide.adoc index 504f4607..0b187858 100644 --- a/EN/modules/ROOT/pages/master/operation_guide.adoc +++ b/EN/modules/ROOT/pages/master/operation_guide.adoc @@ -29,7 +29,9 @@ Releasing a minor version is not going to change the internal storage format, so === Upgrade data via pg_dumpall -The traditional cross-version upgrade method uses pg_dump/pg_dumpall to logically backup the database and then restore it in the new version via pg_restore. It is recommended to use the new version of pg_dump/pg_dumpall tool when exporting the old version of the database. You can take advantage of its latest parallel export and restore features, while reducing database bloat problems. +The default output of `pg_dumpall` is a plain SQL script containing the cluster's databases and global objects such as roles and tablespaces. Replay this script with `psql` on the target cluster. Use `pg_restore` for individual database archives created with a format such as `pg_dump -Fc`. + +Use the `pg_dumpall` executable from the target version when exporting an older cluster. Logical backup and restore is very simple but slow. Downtime depends on the size of the database, so it is suitable for small to medium sized database upgrades. @@ -38,11 +40,9 @@ Logical backup and restore is very simple but slow. Downtime depends on the siz 1.Stop the application before performing a logical backup and make sure that no data is updated, as updates after the backup has started will not be exported. If necessary, modify the /usr/local/pgsql/data/pg_hba.conf file to disable others from accessing the database. Then backup the database. ``` -pg_dumpall > outputfile +pg_dumpall --file=outputfile ``` -> If you have installed a new version of IvorySQL, you can use the new version of the pg_dumpall command to back up the old version of the database. - 2.Stop the backend services of older versions. pg_ctl stop @@ -65,13 +65,14 @@ Or stop the background service by other means. /usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data -8.Finally, using the new version of the psql command to restore the data. +*8.* Use the new version of `psql` to replay the SQL file. The `-X` option skips the local psql startup file. - /usr/local/pgsql/bin/psql -d postgres -f outputfile + /usr/local/pgsql/bin/psql -X -d postgres -f outputfile -To reduce downtime, you can install the new version of IvorySQL to another directory, while starting the service using a different port. Then perform both the export and import of the database. +To run both versions side by side, install the target version in another directory and start it on a separate port. Save the source dump and check that `pg_dumpall` succeeds before replaying it on the target. - pg_dumpall -p 5432 | psql -d postgres -p 5433 + pg_dumpall -p 5432 --file=outputfile + psql -X -d postgres -p 5433 -f outputfile When the above operation is executed, the old and new versions of the backend service run simultaneously, with the new version using port 5433 and the old version using port 5432.