首页 > 其他分享 >pg小版本升级 15.4

pg小版本升级 15.4

时间:2024-02-19 20:33:05浏览次数:32  
标签:postgresql postgres make 版本升级 pg 15.4 config

目录

一、 介绍

PG的小版本升级是十分简单的,小版本的升级是为了修复一些bug缺陷,或者安全性上的问题,对主版本PG上的功能是没有任何影响的。
这次的升级案例是 PG 从15.0升级达到 15.4的版本。 数据库架构是一主2从复制模式。

二、环境准备

节点类别 主机名 IP
主库 node1 192.168.3.3
备库1 node2 192.168.3.4
备库2 node3 192.168.3.5

三、安装包准备

3.1 下载安装包

下载PG15.4 的版本 https://www.postgresql.org/ftp/source/v15.4/

3.2 上传与解压软件包

[postgres@node3 soft]$  tar -xvf postgresql-15.4.tar.gz
[postgres@node3 soft]$ ll
total 57984
drwxrwxr-x 6 postgres postgres     4096 Nov  5  2022 postgresql-15.0
-rw-rw-r-- 1 postgres postgres 29385837 Nov  5  2022 postgresql-15.0.tar.gz
drwxrwxr-x 6 postgres postgres     4096 Aug  8 04:24 postgresql-15.4
-rw-rw-r-- 1 postgres postgres 29978353 Sep 19 14:48 postgresql-15.4.tar.gz

四、升级数据库

4.1 从库2上进行安装

4.1.1 当前版本是15.0, 关闭数据库

[postgres@node3 ~]$ psql
psql (15.0)
Type "help" for help.
postgres=# postgres=# select version();
                                                 version                                                 
---------------------------------------------------------------------------------------------------------
 PostgreSQL 15.0 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=# \q
[postgres@node3 ~]$ pg_ctl stop
waiting for server to shut down.... done
server stopped

4.1.2 执行 config, make, make install 等源码编译的命令

注:这里需要注意的是 config 需要和 上一次 PG 版本15.0 config的时候 保持参数一致

[postgres@node3 ~]$ pg_config |grep CONFIGURE
CONFIGURE =  '--prefix=/postgresql/pg15' '--without-readline'
[postgres@node3 ~]$ 
cd postgresql-15.4
./configure --prefix=/postgresql/pg15 --without-readline
make
make install

注:如果没有任何报错, 我们下来执行 make world ,make install-world

make world
make install-world 

4.1.3 至此软件升级完毕,查询一下升级后软件的版本

[postgres@node3 postgresql-15.4]$ pg_config | grep VERSION
VERSION = PostgreSQL 15.4
[postgres@node3 postgresql-15.4]$ 

4.1.4启动一下 standby2 的数据库

[postgres@node3 postgresql-15.4]$ pg_ctl start
waiting for server to start....2023-09-19 15:58:23.788 CST [31030] LOG:  pgaudit extension initialized
2023-09-19 15:58:23.914 CST [31030] LOG:  redirecting log output to logging collector process
2023-09-19 15:58:23.914 CST [31030] HINT:  Future log output will appear in directory "pg_log".
 done
server started

[postgres@node3 postgresql-15.4]$ psql
psql (15.4)
Type "help" for help.

postgres=# select version();
                                                 version                                                 
---------------------------------------------------------------------------------------------------------
 PostgreSQL 15.4 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=# 

4.2 从库1上进行安装

4.2.1 当前版本是15.0, 关闭数据库

[postgres@node2 ~]$ psql
psql (15.0)
Type "help" for help.
postgres=# postgres=# select version();
                                                 version                                                 
---------------------------------------------------------------------------------------------------------
 PostgreSQL 15.0 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=# \q
[postgres@node2 ~]$ pg_ctl stop
waiting for server to shut down.... done
server stopped

4.2.2 执行 config, make, make install 等源码编译的命令

注:这里需要注意的是 config 需要和 上一次 PG 版本15.0 config的时候 保持参数一致

[postgres@node2 ~]$ pg_config |grep CONFIGURE
CONFIGURE =  '--prefix=/postgresql/pg15' '--without-readline'
[postgres@node2 ~]$ 
cd postgresql-15.4
./configure --prefix=/postgresql/pg15 --without-readline
make
make install

注:如果没有任何报错, 我们下来执行 make world ,make install-world

make world
make install-world 

4.2.3 至此软件升级完毕,查询一下升级后软件的版本

[postgres@node2 postgresql-15.4]$ pg_config | grep VERSION
VERSION = PostgreSQL 15.4
[postgres@node2 postgresql-15.4]$ 

4.2.4启动一下 standby1 的数据库

[postgres@node2 postgresql-15.4]$ pg_ctl start
waiting for server to start....2023-09-19 15:58:23.788 CST [31030] LOG:  pgaudit extension initialized
2023-09-19 15:58:23.914 CST [31030] LOG:  redirecting log output to logging collector process
2023-09-19 15:58:23.914 CST [31030] HINT:  Future log output will appear in directory "pg_log".
 done
server started

[postgres@node2 postgresql-15.4]$ psql
psql (15.4)
Type "help" for help.

postgres=# select version();
                                                 version                                                 
---------------------------------------------------------------------------------------------------------
 PostgreSQL 15.4 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=# 

4.3 主库上进行安装

4.3.1 当前版本是15.0, 关闭数据库

[postgres@node1 ~]$ psql
psql (15.0)
Type "help" for help.
postgres=# postgres=# select version();
                                                 version                                                 
---------------------------------------------------------------------------------------------------------
 PostgreSQL 15.0 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=# \q
[postgres@node1 ~]$ pg_ctl stop
waiting for server to shut down.... done
server stopped

4.3.2 执行 config, make, make install 等源码编译的命令

注:这里需要注意的是 config 需要和 上一次 PG 版本15.0 config的时候 保持参数一致

[postgres@node1 ~]$ pg_config |grep CONFIGURE
CONFIGURE =  '--prefix=/postgresql/pg15' '--without-readline'
[postgres@node1 ~]$ 
cd postgresql-15.4
./configure --prefix=/postgresql/pg15 --without-readline
make
make install

注:如果没有任何报错, 我们下来执行 make world ,make install-world

make world
make install-world 

4.3.3 至此软件升级完毕,查询一下升级后软件的版本

[postgres@node1 postgresql-15.4]$ pg_config | grep VERSION
VERSION = PostgreSQL 15.4
[postgres@node1 postgresql-15.4]$ 

4.3.4启动一下 主库 的数据库

[postgres@node1 postgresql-15.4]$ pg_ctl start
waiting for server to start....2023-09-19 15:58:23.788 CST [31030] LOG:  pgaudit extension initialized
2023-09-19 15:58:23.914 CST [31030] LOG:  redirecting log output to logging collector process
2023-09-19 15:58:23.914 CST [31030] HINT:  Future log output will appear in directory "pg_log".
 done
server started

[postgres@node1 postgresql-15.4]$ psql
psql (15.4)
Type "help" for help.

postgres=# select version();
                                                 version                                                 
---------------------------------------------------------------------------------------------------------
 PostgreSQL 15.4 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=# 

五、检查一下插件

[postgres@node3 postgresql-15.4]$ psql
psql (15.4)
Type "help" for help.

postgres=# \sx
invalid command \sx
Try \? for help.
postgres=# \dx
                                                       List of installed extensions
        Name        | Version |   Schema   |                                          Description                                          
--------------------+---------+------------+-----------------------------------------------------------------------------------------------
 btree_gist         | 1.7     | public     | support for indexing common datatypes in GiST
 file_fdw           | 1.0     | public     | foreign-data wrapper for flat file access
 hypopg             | 1.4.0   | public     | Hypothetical indexes for PostgreSQL
 orafce             | 4.6     | public     | Functions and operators that emulate a subset of functions and packages from the Oracle RDBMS
 pageinspect        | 1.10    | public     | inspect the contents of database pages at a low level
 pg_permissions     | 1.1     | public     | view object permissions and compare them with the desired state
 pg_stat_statements | 1.10    | public     | track planning and execution statistics of all SQL statements executed
 pg_trgm            | 1.6     | public     | text similarity measurement and index searching based on trigrams
 pgaudit            | 1.7     | public     | provides auditing functionality
 plpgsql            | 1.0     | pg_catalog | PL/pgSQL procedural language
 postgres_fdw       | 1.1     | public     | foreign-data wrapper for remote PostgreSQL servers
 walminer           | 3.0     | public     | analyse wal to SQL
 zhparser           | 2.2     | public     | a parser for full-text search of Chinese
(13 rows)

六、主库查看 同步延迟

postgres=# select * from pg_stat_replication;
  pid  | usesysid | usename | application_name | client_addr | client_hostname | client_port |         backend_start         | backend_xmin |   state   |  sent_lsn  | write_lsn  | flush_lsn  | replay_lsn |  
  write_lag    |    flush_lag    |   replay_lag    | sync_priority | sync_state |          reply_time           
-------+----------+---------+------------------+-------------+-----------------+-------------+-------------------------------+--------------+-----------+------------+------------+------------+------------+--
---------------+-----------------+-----------------+---------------+------------+-------------------------------
 24487 |    16388 | repuser | walreceiver      | 192.168.3.4 |                 |       33615 | 2023-09-19 16:13:20.867203+08 |              | streaming | 2/F901E6B0 | 2/F901E6B0 | 2/F901E6B0 | 2/F901E6B0 | 0
0:00:00.000335 | 00:00:00.001863 | 00:00:00.002067 |             0 | async      | 2023-09-19 16:28:22.429572+08
 24724 |    16388 | repuser | walreceiver      | 192.168.3.5 |                 |       16433 | 2023-09-19 16:22:49.931795+08 |              | streaming | 2/F901E6B0 | 2/F901E6B0 | 2/F901E6B0 | 2/F901E6B0 | 0
0:00:00.000286 | 00:00:00.001131 | 00:00:00.001227 |             0 | async      | 2023-09-19 16:28:22.718429+08
(2 rows)

七、创建测试表

postgres=# create table t09 (id int,name text);
CREATE TABLE
postgres=# insert into t09 select repeat(md5(n::text),100) from generate_series(1,10) n;
ERROR:  column "id" is of type integer but expression is of type text
LINE 1: insert into t09 select repeat(md5(n::text),100) from generat...
                               ^
HINT:  You will need to rewrite or cast the expression.
postgres=#  insert into t09 select n,repeat(md5(n::text),100) from generate_series(1,10) n;
INSERT 0 10

备库:检查
postgres=# select count(*) from t09;
 count 
-------
    10
(1 row)

标签:postgresql,postgres,make,版本升级,pg,15.4,config
From: https://www.cnblogs.com/xinxin1222/p/18021905

相关文章

  • pg高可用方案repmgr带witness搭建
    一、总体架构操作系统版本:linuxredhat7.6pg版本:12.2repmgr版本5.2192.168.3.73主库:repmgr+master192.168.3.74从库1:repmgr+standby192.168.3.75从库2:repmgr+standby192.168.3.76witness:repmgr+witness所有的节点安装操作系统,创建用户目录,安装pg,安装......
  • 磐维2.0 之pg_stat_statements插件
    目录一、概念描述二、安装插件三、pg_stat_statements视图四、pg_stat_statements相关参数五、测试验证一、概念描述pg_stat_statements是pg的一个扩展插件,通常用于统计数据库的资源开销,分析TOPSQL,找出慢查询。二、安装插件testdb=#testdb=#createextensionpg_stat_sta......
  • password_encryption_type 和 pg_hba.conf 不匹配导致用户连不上
    问题概述xxx客户新上一套opengauss数据库,在测试中用户输入正确的密码,提示用户密码错误,导致用户被锁问题原因password_encryption_type和pg_hba.conf不匹配导致用户连不上模拟问题因没有opengauss的环境,测试环境选择Mogdb1、准备测试环境,修改password_encryption_type。......
  • rlwrap解决opengauss,pg,oracle上下左右及回退乱码
    安装下rlwrap,最新版本是0.43下载地址https://fossies.org/linux/privat/rlwrap-0.43.tar.gz/安装rlwraptar-zxvfrlwrap-0.43.tar.gz[root@openguesssoft]#lltotal298864-rw-------1ommdbgrp1234Apr810:30cluster_config_opendb.xmldrwx------.15rootroot......
  • ubuntu Fix The Google GPG Error on Ubuntu
    想装下node.js,结果ubuntu输入aptupdate环境炸了,原因是google的GPGkey更新了报错(base)woodx@Machine:~$sudoaptupdateGet:1file:/var/cudnn-local-repo-ubuntu1804-8.8.1.3InRelease[1,572B]Get:2file:/var/nv-tensorrt-local-repo-ubuntu1804-8.5.1-cuda-11.8InR......
  • 基于FPGA的图像RGB转CIE-Lab实现,包含testbench和MATLAB辅助验证程序
    1.算法运行效果图预览 将FPGA的结果导入到matlab,并和matlab的仿真结果进行对比:   2.算法运行软件版本vivado2019.2 matlab2022a 3.算法理论概述     RGB和CIE-Lab是两种常用的颜色空间,它们在不同的应用领域中各有优势。RGB颜色空间主要用于显示设备,而C......
  • Tomcat官网下载版本:如何选择tar.gz (pgp, sha512)和zip (pgp, sha512)?
    先上结论:选择tar.gz格式还是zip格式的文件下载,主要取决于操作系统和个人偏好:tar.gz(pgp,sha512):这是一种在Unix-like系统(如Linux和macOS)中常用的压缩格式。tar是一种将多个文件合并为单个文件(归档)的工具,而gz是gzip,用于压缩归档文件。pgp和sha512分别提供了文件......
  • FPGA设计经验之图像处理
    用FPGA做图像处理优势最关键的就是:FPGA能进行实时流水线运算,能达到最高的实时性。因此在一些对实时性要求非常高的应用领域,做图像处理基本就只能用FPGA。例如在一些分选设备中图像处理基本上用的都是FPGA,因为在其中相机从看到物料图像到给出执行指令之间的延时大概只有几毫秒,这就......
  • 软件无线电平台的FPGA设计与实现
    软件无线电的概念最早由美国MITRE公司的Joe.Mitola于1992年5月在美国国家远程会议上提出,其基本思想是以硬件平台作为无线电通信的基础,通过软件编程的方式在此硬件平台上实现可定制的无线电功能。软件无线电系统具有数字化、可编程性、模块化、可扩展性和开放性的特点,使其在包......
  • FPGA图像处理学习(人脸识别、追踪、转换)
    获取人脸图像——肤色提取(Ycbcr+阈值)——滤波处理(中值、腐蚀膨胀)——人脸框选——显示肤色提取:顾名思义,将肤色从外界环境中提取出。在肤色识别算法中,常用YCbCr颜色空间(亮度、蓝色、红色分量),因为肤色在YCbCr空间受亮度信息的影响较小,从而肤色类聚性好,由此,在Ycbcr空间基础上,我们......