pg13升级到pg14 inplace测试

编程入门 行业动态 更新时间:2024-10-18 14:14:05

pg13<a href=https://www.elefans.com/category/jswz/34/1770719.html style=升级到pg14 inplace测试"/>

pg13升级到pg14 inplace测试

准备工作

  1. 操作系统用户pg13
  2. pg13的数据目录/pg13/data
  3. pg14的数据目录/pg14-8k/data2
  4. 保证pg13和pg14的数据库中的插件一致
  5. pg13的初始化和pg14的初始化都要用操作系统用户pg13进行初始化

升级前检查

注:新老的集群端口号不能一致,否则升级失败
[pg13@sdw2 ~]$ /pg14-8k/bin/pg_upgrade  --old-datadir=/pg13/data --new-datadir=/pg14-8k/data2 --old-bindir=/pg13/bin --new-bindir=/pg14-8k/bin   --old-port=5432  --new-port=35432  --socketdir=/pg14-8k/data2  --check
Performing Consistency Checks
-----------------------------
Checking cluster versions                                   ok
Checking database user is the install user                  ok
Checking database connection settings                       ok
Checking for prepared transactions                          ok
Checking for system-defined composite types in user tables  ok
Checking for reg* data types in user tables                 ok
Checking for contrib/isn with bigint-passing mismatch       ok
Checking for user-defined encoding conversions              ok
Checking for user-defined postfix operators                 ok
Checking for presence of required libraries                 ok
Checking database user is the install user                  ok
Checking for prepared transactions                          ok
Checking for new cluster tablespace directories             ok*Clusters are compatible*

升级

--link 新版本采用硬链接的方式将数据复制到指定的文件目录
[pg13@sdw2 ~]$ /pg14-8k/bin/pg_upgrade  --old-datadir=/pg13/data --new-datadir=/pg14-8k/data2 --old-bindir=/pg13/bin --new-bindir=/pg14-8k/bin   --old-port=5432  --new-port=35432  --socketdir=/pg14-8k/data2  --link
Performing Consistency Checks
-----------------------------
Checking cluster versions                                   ok
Checking database user is the install user                  ok
Checking database connection settings                       ok
Checking for prepared transactions                          ok
Checking for system-defined composite types in user tables  ok
Checking for reg* data types in user tables                 ok
Checking for contrib/isn with bigint-passing mismatch       ok
Checking for user-defined encoding conversions              ok
Checking for user-defined postfix operators                 ok
Creating dump of global objects                             ok
Creating dump of database schemasok
Checking for presence of required libraries                 ok
Checking database user is the install user                  ok
Checking for prepared transactions                          ok
Checking for new cluster tablespace directories             okIf pg_upgrade fails after this point, you must re-initdb the
new cluster before continuing.Performing Upgrade
------------------
Analyzing all rows in the new cluster                       ok
Freezing all rows in the new cluster                        ok
Deleting files from new pg_xact                             ok
Copying old pg_xact to new server                           ok
Setting oldest XID for new cluster                          ok
Setting next transaction ID and epoch for new cluster       ok
Deleting files from new pg_multixact/offsets                ok
Copying old pg_multixact/offsets to new server              ok
Deleting files from new pg_multixact/members                ok
Copying old pg_multixact/members to new server              ok
Setting next multixact ID and offset for new cluster        ok
Resetting WAL archives                                      ok
Setting frozenxid and minmxid counters in new cluster       ok
Restoring global objects in the new cluster                 ok
Restoring database schemas in the new clusterok
Adding ".old" suffix to old global/pg_control               okIf you want to start the old cluster, you will need to remove
the ".old" suffix from /pg13/data/global/pg_control.old.
Because "link" mode was used, the old cluster cannot be safely
started once the new cluster has been started.Linking user relation filesok
Setting next OID for new cluster                            ok
Sync data directory to disk                                 ok
Creating script to delete old cluster                       ok
Checking for extension updates                              notice**注意点1:升级extensions**
Your installation contains extensions that should be updated
with the ALTER EXTENSION command.  The fileupdate_extensions.sql
when executed by psql by the database superuser will update
these extensions.Upgrade Complete
----------------
**注意点2:分析统计信息**
Optimizer statistics are not transferred by pg_upgrade.
Once you start the new server, consider running:/pg14-8k/bin/vacuumdb --all --analyze-in-stagesRunning this script will delete the old cluster's data files:./delete_old_cluster.sh

升级完成后,会在pg13 home目录下生成几个文件(后续用):

[root@sdw2 pg13]# pwd
/home/pg13
[root@sdw2 pg13]# ll -lhtr
.........
-rw-r-----  1 pg13 pg13  270 2月  10 09:33 loadable_libraries.txt(加载插件信息)
-rwx------  1 pg13 pg13   31 2月  10 10:04 delete_old_cluster.sh(删除老版本的数据)
-rw-------  1 pg13 pg13  135 2月  10 10:04 update_extensions.sql(升级插件)[root@sdw2 pg13]# more loadable_libraries.txt 
could not load library "pglogical": ERROR:  could not access file "pglogical": No such file or directory
In database: postgres
could not load library "$libdir/pglogical": ERROR:  could not access file "$libdir/pglogical": No such file or directory
In database: postgres

收集统计信息

由于运行pg_upgrade并不会把统计信息带过来,所以需要分析一下全库

-j为并行
[pg13@sdw2 ~]$ /pg14-8k/bin/vacuumdb --all --analyze-in-stages -p 35432 -h /pg14-8k/data2 -j 6
vacuumdb: processing database "dbt": Generating minimal optimizer statistics (1 target)
vacuumdb: processing database "dbt1": Generating minimal optimizer statistics (1 target)
vacuumdb: processing database "dbt2": Generating minimal optimizer statistics (1 target)
vacuumdb: processing database "postgres": Generating minimal optimizer statistics (1 target)
vacuumdb: processing database "template1": Generating minimal optimizer statistics (1 target)
vacuumdb: processing database "dbt": Generating medium optimizer statistics (10 targets)
vacuumdb: processing database "dbt1": Generating medium optimizer statistics (10 targets)
vacuumdb: processing database "dbt2": Generating medium optimizer statistics (10 targets)
vacuumdb: processing database "postgres": Generating medium optimizer statistics (10 targets)
vacuumdb: processing database "template1": Generating medium optimizer statistics (10 targets)
vacuumdb: processing database "dbt": Generating default (full) optimizer statistics
vacuumdb: processing database "dbt1": Generating default (full) optimizer statistics
vacuumdb: processing database "dbt2": Generating default (full) optimizer statistics
vacuumdb: processing database "postgres": Generating default (full) optimizer statistics
vacuumdb: processing database "template1": Generating default (full) optimizer statistics

升级插件

1 登陆数据库

[pg13@sdw2 ~]$ /pg14-8k/bin/psql -p 35432 -h /pg14-8k/data2 -d postgres
psql (14.1)
Type "help" for help.postgres=# \dtList of relationsSchema |    Name     | Type  | Owner 
--------+-------------+-------+-------public | ct          | table | pg13public | t1          | table | pg13public | t2          | table | pg13public | t3          | table | pg13public | t4          | table | pg13public | t_demo      | table | pg13public | t_goods     | table | pg13public | t_hash      | table | pg13public | t_insert1   | table | pg13public | t_order     | table | pg13public | t_parallel1 | table | pg13public | t_parallel2 | table | pg13public | t_pj        | table | pg13public | t_product   | table | pg13public | t_pub       | table | pg13public | t_pub2      | table | pg13public | t_pub3      | table | pg13public | t_pub4      | table | pg13public | t_pub5      | table | pg13public | t_pub6      | table | pg13public | t_pub7      | table | pg13public | t_pub8      | table | pg13public | t_pub9      | table | pg13public | t_table     | table | pg13public | t_table1    | table | pg13public | t_trunate   | table | pg13public | t_wishlist  | table | pg13public | tab1        | table | pg13public | tab2        | table | pg13public | tab3        | table | pg13public | test_big2   | table | pg13
(31 rows)

2 查看插件情况

postgres=# \dxList of installed extensionsName        | Version |   Schema   |                              Description                               
--------------------+---------+------------+------------------------------------------------------------------------bloom              | 1.0     | public     | bloom access method - signature file based indexpageinspect        | 1.8     | public     | inspect the contents of database pages at a low levelpg_stat_statements | 1.8     | public     | track planning and execution statistics of all SQL statements executedpg_trgm            | 1.5     | public     | text similarity measurement and index searching based on trigramspgstattuple        | 1.5     | public     | show tuple-level statisticsplpgsql            | 1.0     | pg_catalog | PL/pgSQL procedural language
(6 rows)

3 升级插件

postgres=# \i update_extensions.sql
You are now connected to database "postgres" as user "pg13".
ALTER EXTENSION
ALTER EXTENSION
ALTER EXTENSION
postgres=# \dxList of installed extensionsName        | Version |   Schema   |                              Description                               
--------------------+---------+------------+------------------------------------------------------------------------bloom              | 1.0     | public     | bloom access method - signature file based indexpageinspect        | 1.9     | public     | inspect the contents of database pages at a low levelpg_stat_statements | 1.9     | public     | track planning and execution statistics of all SQL statements executedpg_trgm            | 1.6     | public     | text similarity measurement and index searching based on trigramspgstattuple        | 1.5     | public     | show tuple-level statisticsplpgsql            | 1.0     | pg_catalog | PL/pgSQL procedural language
(6 rows)注意:pageinspect已经从1.8升级到了1.9pg_stat_statements从1.8升级到1.9

删除老版本

[pg13@sdw2 ~]$ sh /home/pg13/delete_old_cluster.sh

更多推荐

pg13升级到pg14 inplace测试

本文发布于:2023-11-15 18:09:30,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1603933.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:升级到   测试   inplace

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!