当前位置: 首页 > news >正文

PostgreSQL使用pg_upgrade 从13升级到14

pg_upgrade 工具可以支持 PostgreSQL 跨版本的就地升级,不需要执行导出和导入操作。pg_upgrade 可以支持 PostgreSQL 8.4.X 到最新版本的升级,包括快照版本和测试版本。

pg_upgrade 提供了升级前的兼容性检查(-c 或者 —check 选项)功能,可以发现插件、数据类型不兼容等问题。如果指定了—link 选项,新版本服务可以直接使用原有的数据库文件而不需要执行复制,通常可以在几分钟内完成升级操作。

本次文档主要记录的是版本13.5到14.1的升级演示
 

01 PG 13环境检查

1、环境变量检查

[postgres@lyp ~]$ cat .bash_profile
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/.local/bin:$HOME/bin

export PATH

export PGHOME=/opt/pgsql13.5
export PGDATA=/home/postgres/pgdata
export PGUSER=postgres
export PGPORT=5433
export PATH=$HOME/bin:$PGHOME/bin:$PATH
export LD_LIBRARY_PATH=$PGHOME/lib:$LD_LIBRARY_PATH
[postgres@lyp ~]$

2、数据库版本检查

[postgres@lyp ~]$ psql
psql (13.5)
Type "help" for help.

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

postgres=#

3、模拟数据

postgres=# \d
               List of relations
 Schema |       Name        | Type  |  Owner   
--------+-------------------+-------+----------
 public | emp               | table | postgres
(1 rows)

postgres=# select count(*) from emp;
  count  
---------
 1100000
(1 row)

postgres=#

02 PG 14环境安装

1、解压安装包

[root@lyp ~]# tar -zxvf postgresql-14.1.tar.gz
[root@lyp ~]# ll postgresql-14.1
total 756
-rw-r--r--.  1 1107 1107    490 Nov  9 05:58 aclocal.m4
drwxrwxrwx.  2 1107 1107   4096 Nov  9 06:10 config
-rwxr-xr-x.  1 1107 1107 580807 Nov  9 05:58 configure
-rw-r--r--.  1 1107 1107  83288 Nov  9 05:58 configure.ac
drwxrwxrwx. 58 1107 1107   4096 Nov  9 06:10 contrib
-rw-r--r--.  1 1107 1107   1192 Nov  9 05:58 COPYRIGHT
drwxrwxrwx.  3 1107 1107     87 Nov  9 06:10 doc
-rw-r--r--.  1 1107 1107   4259 Nov  9 05:58 GNUmakefile.in
-rw-r--r--.  1 1107 1107    277 Nov  9 05:58 HISTORY
-rw-r--r--.  1 1107 1107  63953 Nov  9 06:11 INSTALL
-rw-r--r--.  1 1107 1107   1665 Nov  9 05:58 Makefile
-rw-r--r--.  1 1107 1107   1213 Nov  9 05:58 README
drwxrwxrwx. 16 1107 1107   4096 Nov  9 06:11 src
[root@lyp ~]#
[root@lyp ~]# mv postgresql-14.1 /opt/pgsql14.1
[root@lyp ~]#

2、编译安装

[root@lyp ~]# cd /opt/pgsql14.1/
[root@lyp pgsql14.1]# ./configure --prefix=/opt/pgsql14.1
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
......
config.status: linking src/include/port/linux.h to src/include/pg_config_os.h
config.status: linking src/makefiles/Makefile.linux to src/Makefile.port
[root@lyp pgsql14.1]#
[root@lyp pgsql14.1]# gmake world
gmake -C ./src/backend generated-headers
gmake[1]: Entering directory `/opt/pgsql14.1/src/backend'
......
gmake[2]: Leaving directory &

相关文章:

  • SocketTool、串口调试助手、MQTT中间件基础
  • 大白话html 第三章学习表格和表单
  • Python 爬虫与网络安全有什么关系
  • RabbitMQ操作实战
  • 迁移学习策略全景解析:从理论到产业落地的技术跃迁
  • 打造更 AI 的操作系统 《龙蜥+超级探访》第三期走进浪潮信息
  • 对rust中的from和into的理解
  • RA-Eco-RA2L1-48PIN-V1.0开发板RTC时钟
  • redis restore 命令的用法
  • 【深度学习】强化学习(RL)-A3C(Asynchronous Advantage Actor-Critic)
  • 快速使用通义千问大模型API + VUE
  • 【时序预测】深度时序预测算法的对比与核心创新点分析
  • ArcGIS Pro中打造精美高程渲染图的全面指南
  • 数据开发面试:DQL,DDL,DTL
  • 【Kubernetes】对资源进行PATCH
  • 【Mysql】:数据库表的三部曲(数据操作 + 类型解析 + 约束规则)
  • sqlmap:自动SQL注入和数据库接管工具
  • JSX基础 —— 识别JS表达式
  • 【鸿蒙Next】系统通知权限申请
  • apk反编译工具
  • 微信公众号做公司网站/东莞今日新闻大事
  • 温州网站 公司/网站推广优化排名教程
  • 怎么自己设计装修效果图/网站快速优化排名软件
  • 网站做页游推广/最好的seo外包
  • 做自媒体与做网站/微信指数官网
  • 网站不同颜色/响应式网站 乐云seo品牌