postgresql 数据库小版本更新

postgresql 数据库小版本更新

记录一次pg小版本更新

前言

因为最近漏扫发现好多漏洞,需要升级pg数据库的版本用以解决漏洞问题,有些数据库不能升级大版本,只能升级小版本,网上全是讲的编译安装的,我在这里说说rpm安装如何升级。

一.下载最新的pg版本 pg11(11.18)

  1. 官网下载地址:
    sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm

官网直接下载

sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm

安装

sudo yum install -y postgresql11-server
  1. 自己下载安装包及依赖
    需要下载4个对应版本的rpm包。

下载地址:
https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-7-x86_64/
在这里插入图片描述
已下载好的文件地址:pg11.18的资源
https://download.csdn.net/download/yang_z_1/87432521

把下载包放到一个目录下,上传到所需的Linux服务器
在文件目录下执行

yum localinstall *.rpm -y
[root@hrmw-template pg11.18]# yum localinstall *.rpm -y
Loaded plugins: fastestmirror
Examining postgresql11-11.18-1PGDG.rhel7.x86_64.rpm: postgresql11-11.18-1PGDG.rhel7.x86_64
Marking postgresql11-11.18-1PGDG.rhel7.x86_64.rpm as an update to postgresql11-11.5-1PGDG.rhel7.x86_64
Examining postgresql11-contrib-11.18-1PGDG.rhel7.x86_64.rpm: postgresql11-contrib-11.18-1PGDG.rhel7.x86_64
Marking postgresql11-contrib-11.18-1PGDG.rhel7.x86_64.rpm as an update to postgresql11-contrib-11.5-1PGDG.rhel7.x86_64
Examining postgresql11-libs-11.18-1PGDG.rhel7.x86_64.rpm: postgresql11-libs-11.18-1PGDG.rhel7.x86_64
Marking postgresql11-libs-11.18-1PGDG.rhel7.x86_64.rpm as an update to postgresql11-libs-11.5-1PGDG.rhel7.x86_64
Examining postgresql11-server-11.18-1PGDG.rhel7.x86_64.rpm: postgresql11-server-11.18-1PGDG.rhel7.x86_64
Marking postgresql11-server-11.18-1PGDG.rhel7.x86_64.rpm as an update to postgresql11-server-11.5-1PGDG.rhel7.x86_64
Resolving Dependencies
--> Running transaction check
---> Package postgresql11.x86_64 0:11.5-1PGDG.rhel7 will be updated
---> Package postgresql11.x86_64 0:11.18-1PGDG.rhel7 will be an update
---> Package postgresql11-contrib.x86_64 0:11.5-1PGDG.rhel7 will be updated
---> Package postgresql11-contrib.x86_64 0:11.18-1PGDG.rhel7 will be an update
---> Package postgresql11-libs.x86_64 0:11.5-1PGDG.rhel7 will be updated
---> Package postgresql11-libs.x86_64 0:11.18-1PGDG.rhel7 will be an update
---> Package postgresql11-server.x86_64 0:11.5-1PGDG.rhel7 will be updated
---> Package postgresql11-server.x86_64 0:11.18-1PGDG.rhel7 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

===========================================================================================================
 Package               Arch    Version               Repository                                       Size
===========================================================================================================
Updating:
 postgresql11          x86_64  11.18-1PGDG.rhel7     /postgresql11-11.18-1PGDG.rhel7.x86_64          8.9 M
 postgresql11-contrib  x86_64  11.18-1PGDG.rhel7     /postgresql11-contrib-11.18-1PGDG.rhel7.x86_64  2.1 M
 postgresql11-libs     x86_64  11.18-1PGDG.rhel7     /postgresql11-libs-11.18-1PGDG.rhel7.x86_64     1.4 M
 postgresql11-server   x86_64  11.18-1PGDG.rhel7     /postgresql11-server-11.18-1PGDG.rhel7.x86_64    19 M

Transaction Summary
===========================================================================================================
Upgrade  4 Packages

Total size: 31 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : postgresql11-libs-11.18-1PGDG.rhel7.x86_64                                              1/8 
  Updating   : postgresql11-11.18-1PGDG.rhel7.x86_64                                                   2/8 
  Updating   : postgresql11-server-11.18-1PGDG.rhel7.x86_64                                            3/8 
  Updating   : postgresql11-contrib-11.18-1PGDG.rhel7.x86_64                                           4/8 
  Cleanup    : postgresql11-server-11.5-1PGDG.rhel7.x86_64                                             5/8 
  Cleanup    : postgresql11-contrib-11.5-1PGDG.rhel7.x86_64                                            6/8 
  Cleanup    : postgresql11-11.5-1PGDG.rhel7.x86_64                                                    7/8 
  Cleanup    : postgresql11-libs-11.5-1PGDG.rhel7.x86_64                                               8/8 
  Verifying  : postgresql11-libs-11.18-1PGDG.rhel7.x86_64                                              1/8 
  Verifying  : postgresql11-contrib-11.18-1PGDG.rhel7.x86_64                                           2/8 
  Verifying  : postgresql11-server-11.18-1PGDG.rhel7.x86_64                                            3/8 
  Verifying  : postgresql11-11.18-1PGDG.rhel7.x86_64                                                   4/8 
  Verifying  : postgresql11-server-11.5-1PGDG.rhel7.x86_64                                             5/8 
  Verifying  : postgresql11-contrib-11.5-1PGDG.rhel7.x86_64                                            6/8 
  Verifying  : postgresql11-11.5-1PGDG.rhel7.x86_64                                                    7/8 
  Verifying  : postgresql11-libs-11.5-1PGDG.rhel7.x86_64                                               8/8 

Updated:
  postgresql11.x86_64 0:11.18-1PGDG.rhel7            postgresql11-contrib.x86_64 0:11.18-1PGDG.rhel7      
  postgresql11-libs.x86_64 0:11.18-1PGDG.rhel7       postgresql11-server.x86_64 0:11.18-1PGDG.rhel7       

Complete!

二 pg11.5 升级 pg11.18过程

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

 select version();

在这里插入图片描述

2. 关闭pg11.5数据库

systemctl stop postgresql-11

3. 安装pg11.18

yum localinstall *.rpm -y

这步在上面已经做过了。

4.修改 配置文件

使用root用户修改 /usr/lib/systemd/system/postgresql-11.service 文件,将其中的PGDATA修改为新的数据目录

vim  /usr/lib/systemd/system/postgresql-11.service

把Environment=PGDATA=修改你pg11.5的安装目录;
修改前:
在这里插入图片描述
修改后:

在这里插入图片描述

5. 重新加载配置文件

systemctl daemon-reload

6. 启动数据库

systemctl start postgresql-11

7. 查看数据库版本

 select version();

在这里插入图片描述

在这里插入图片描述

后记

如果本文章有何错误,请您评论中指出,或联系我,我会改正,如果您觉得这篇文章有用,请帮忙一键三连,让更多的人看见,谢谢
作者 yang_z_1 csdn博客地址: https://blog.csdn.net/yang_z_1?type=blog

  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

yang_z_1

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值