首页 > 其他分享 >pg升级(14-15)link方式

pg升级(14-15)link方式

时间:2024-05-17 14:40:34浏览次数:23  
标签:old 14 Checking 15 cluster link new ok data

环境:
OS:Centos 7
旧版本:pg14
新版本:pg15

1.查看当前的数据库版本

su - postgres
-bash-4.2$ psql -h localhost -U postgres -p5432
psql (15.6, server 14.11)
Type "help" for help.

postgres=# select version();
                                                 version                                                  
----------------------------------------------------------------------------------------------------------
 PostgreSQL 14.11 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit
(1 row)

 

2.查看安装的插件

postgres=# \dx
                                                                       List of installed extensions
             Name             | Version |   Schema   |                                                     Descriptio
n                                                     
------------------------------+---------+------------+---------------------------------------------------------------
------------------------------------------------------
 address_standardizer         | 3.3.3   | public     | Used to parse an address into constituent elements. Generally 
used to support geocoding address normalization step.
 address_standardizer_data_us | 3.3.3   | public     | Address Standardizer US dataset example
 dblink                       | 1.2     | public     | connect to other PostgreSQL databases from within a database
 fuzzystrmatch                | 1.1     | public     | determine similarities and distance between strings
 mysql_fdw                    | 1.2     | public     | Foreign data wrapper for querying a MySQL server
 plpgsql                      | 1.0     | pg_catalog | PL/pgSQL procedural language
 postgis                      | 3.3.3   | public     | PostGIS geometry and geography spatial types and functions
 postgis_raster               | 3.3.3   | public     | PostGIS raster types and functions
 postgis_sfcgal               | 3.3.3   | public     | PostGIS SFCGAL functions
 postgis_tiger_geocoder       | 3.3.3   | tiger      | PostGIS tiger geocoder and reverse geocoder
 postgis_topology             | 3.3.3   | topology   | PostGIS topology spatial types and functions
 postgres_fdw                 | 1.1     | public     | foreign-data wrapper for remote PostgreSQL servers
(12 rows)

 

这里安装了mysql_fdw和postgis插件,那么也要安装新版本pg15的插件

 

3.安装版本的数据库软件并进行初始化
安装软件步骤省略,下面是初始化数据库

su - postgres
/usr/pgsql-15/bin/initdb -D /opt/pg15/data

确保新版本的可以运行

 

4.安装插件
[root@localhost extension]#yum list mysql_fdw*
[root@dsc1 ~]#yum install mysql_fdw_15.x86_64

[root@localhost extension]#yum list postgis*
[root@localhost extension]#yum install postgis33_15.x86_64

 

5.停掉旧版本
systemctl stop postgresql-14

 

6.升级检查

su - postgres
-bash-4.2$ /usr/pgsql-15/bin/pg_upgrade --old-datadir /opt/pg14/data/ --new-datadir /opt/pg15/data --old-bindir /usr/pgsql-14/bin/ --new-bindir /usr/pgsql-15/bin/ --check --link
Performing Consistency Checks on Old Live Server
------------------------------------------------
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 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*

 

7.升级

su - postgres
/usr/pgsql-15/bin/pg_upgrade --old-datadir /opt/pg14/data/ --new-datadir /opt/pg15/data --old-bindir /usr/pgsql-14/bin/ --new-bindir /usr/pgsql-15/bin/ --link
There seems to be a postmaster servicing the old cluster.
Please shutdown that postmaster and try again.
Failure, exiting

提升需要停掉旧版本数据库
systemctl stop postgresql-14

 

-bash-4.2$ /usr/pgsql-15/bin/pg_upgrade --old-datadir /opt/pg14/data/ --new-datadir /opt/pg15/data --old-bindir /usr/pgsql-14/bin/ --new-bindir /usr/pgsql-15/bin/ --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
Creating dump of global objects                             ok
Creating dump of database schemas                           
                                                            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

If 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 cluster               
                                                            ok
Adding ".old" suffix to old global/pg_control               ok

If you want to start the old cluster, you will need to remove
the ".old" suffix from /opt/pg14/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 files                                 
                                                            ok
Setting next OID for new cluster                            ok
Sync data directory to disk                                 ok
Creating script to delete old cluster                       ok
Checking for extension updates                              ok

Upgrade Complete
----------------
Optimizer statistics are not transferred by pg_upgrade.
Once you start the new server, consider running:
    /usr/pgsql-15/bin/vacuumdb --all --analyze-in-stages

Running this script will delete the old cluster's data files:
    ./delete_old_cluster.sh

 

上面有提示

If you want to start the old cluster, you will need to remove
the ".old" suffix from /opt/pg14/data/global/pg_control.old.
Because "link" mode was used, the old cluster cannot be safely
started once the new cluster has been started.

 

若想重新启动旧版本的数据库,那么需要将
/opt/pg14/data/global/pg_control.old
改名为
/opt/pg14/data/global/pg_control

 

6.拷贝配置文件到新版本的数据库目录


su - postgres
cp /opt/pg14/data/pg_hba.conf /opt/pg15/data/
cp /opt/pg14/data/postgresql.conf /opt/pg15/data/

拷贝过去注意修改如下配置项postgresql.conf
log_directory = '/opt/pg15/log'
archive_command = 'DATE=`date +%Y%m%d`;DIR="/opt/pg15/archivelog/$DATE";(test -d $DIR || mkdir -p $DIR)&& cp %p $DIR/%f

 

7.启动新版数据库
systemctl start postgresql-15

 

标签:old,14,Checking,15,cluster,link,new,ok,data
From: https://www.cnblogs.com/hxlasky/p/18197762

相关文章

  • 当前版本:wimlib-1.14.4(发布于2024年2月24日)wimlib是一个开源、跨平台的库,用于创建、提
    当前版本:wimlib-1.14.4(发布于2024年2月24日)wimlibv1.14.4源代码(.tar.gz)wimlibv1.14.4Windows二进制文件(32位)wimlibv1.14.4Windows二进制文件(64位)wimlibv1.14.4WindowsARM64二进制文件(实验性)Beta版及旧版本发布wimlib是什么?wimlib是一个开源、跨平台的库,......
  • 【Flink 日常踩坑】Could not find ExecutorFactory in classpath
    Description一段简单的FlinkSQL程序,在IDE中运行没问题,但是maven打包后发布到终端启动却报错了。importorg.apache.flink.configuration.Configuration;importorg.apache.flink.streaming.api.environment.StreamExecutionEnvironment;importorg.apache.flink.table.......
  • 【Flink 日常踩坑】Could not find ExecutorFactory in classpath
    Description一段简单的FlinkSQL程序,在IDE中运行没问题,但是maven打包后发布到终端启动却报错了。importorg.apache.flink.configuration.Configuration;importorg.apache.flink.streaming.api.environment.StreamExecutionEnvironment;importorg.apache.flink.table.......
  • 关于“error: Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for
    安装库之前一定要注意python版本,今天鬼迷日眼的装一堆堆库,一个回车冒出来这个鬼问题。百度无果后灵光乍现,只安装报错时对应的库:condainstallnumpy==1.20.1结果在输出里找出这一段:Specifications:-numpy==1.20.1->python[version='>=3.7,<3.8.0a0|>=3.8,<3.9.0a0|>=......
  • openGauss lo_unlink
    lo_unlink功能描述从数据库中移除一个大对象。原型intlo_unlink(PGconn*conn,OidlobjId);参数表1lo_unlink参数关键字参数说明conn一个数据库连接lobjId要移除的大对象的OID返回值int:成功时返回1,失败时返回-1。示例请参见示例章节。详情查......
  • 群晖ds1517+解决第三方Marvell AQC107 10Gbe网卡驱动问题
    群晖ds1517+解决第三方MarvellAQC10710Gbe网卡驱动问题转载注明来源:本文链接来自osnosn的博客,写于2024-05-15.说明这是网友mohawk解决问题的经过,征得同意后,贴在这里。给大家参考。背景好友打算升级到全屋有线万兆2.5g网络,陆续装备了路由器、交换机等,但家里的群晖ds......
  • Flink同步kafka到iceberg(cos存储)
    一、flink到logger1、sourcecreatetablesource_table(idbigintcomment'唯一编号',order_numberbigintcomment'订单编号',update_timestamptimestamp_ltzmetadatafr......
  • Flink的State
      有状态的计算是流式计算框架的一个重要功能,很多复杂的计算场景都需要记录一下相关的状态。FlinkState一种为了满足算子计算时需要历史数据需求的,使用checkpoint机制进行容错,存储在statebackend的数据结构。1.State分类    FlinkState被分为keyedstate、operato......
  • openGauss dblink
    dblinkdblink是一个可以在openGauss数据库会话中连接到其它数据库的工具,同libpq支持的连接参数一致,也可以在通过在连接串中增加drivername(对应odbc.ini文件中的数据源名称)字段通过ODBC连接异构数据库。libpq连接串详见:链接参数ODBC的使用方法详见:ODBC常用的dblink函数参数......
  • MIUI 12.0.15
    /storage/emulated/0/MIUI/Gallery/cloud/.cache/.localthumbnailFile这个目录莫名其妙就很大95GB,感觉有bug Totaldiskusage:95.7GiBApparentsize:95.6GiBItems:18357 我大概明白了,它会将我拍摄的/DCIM/Camera目录下的压缩了的图,莫名其妙转换为未压缩的图,然后......