1.版本信息:
升级前 | 升级后 |
postgre14.6 | postgre14.11 |
2.升级步骤
2.1下载升级包
[root@localhost postgresql]# wget https://ftp.postgresql.org/pub/source/v14.11/postgresql-14.11.tar.bz2
2.2安装新版本postgresql
[root@localhost postgresql]# tar -xvf postgresql-14.11.tar.bz2
[root@localhost postgresql]# cd postgresql-14.11
#创建安装目录
[root@localhost postgresql-14.11]# mkdir -p /usr/local/pgsql14.11
#编译安装
[root@localhost postgresql-14.11]# ./configure --prefix=/usr/local/pgsql14.11 --with-perl --with-python --with-libxml --with-libxslt --with-openssl
[root@localhost postgresql-14.11]# make && make install
#查看是否安装到指定目录:/usr/local/pgsql14.11
[root@localhost pgsql14.11]# pwd
/usr/local/pgsql14.11
[root@localhost pgsql14.11]# ll
total 16
drwxr-xr-x 2 root root 4096 May 2 04:33 bin
drwxr-xr-x 6 root root 4096 May 2 04:33 include
drwxr-xr-x 4 root root 4096 May 2 04:33 lib
drwxr-xr-x 6 root root 4096 May 2 04:33 share
[root@localhost pgsql14.11]#
#编译插件
[root@localhost contrib]# pwd
/soft/postgresql/postgresql-14.11/contrib
[root@localhost contrib]# make && make install
3.生成软连接/替换旧版本安装目录
[root@localhost local]# cd /usr/local
[root@localhost local]# pwd
/usr/local
[root@localhost local]# ll
total 0
drwxr-xr-x. 2 root root 6 Apr 11 2018 bin
drwxr-xr-x. 2 root root 6 Apr 11 2018 etc
drwxr-xr-x. 2 root root 6 Apr 11 2018 games
drwxr-xr-x. 2 root root 6 Apr 11 2018 include
drwxr-xr-x. 2 root root 6 Apr 11 2018 lib
drwxr-xr-x. 2 root root 6 Apr 11 2018 lib64
drwxr-xr-x. 2 root root 6 Apr 11 2018 libexec
lrwxrwxrwx 1 root root 20 Apr 29 08:10 pgsql -> /usr/local/pgsql14.6
drwxr-xr-x 6 root root 56 May 2 04:33 pgsql14.11
drwxr-xr-x 6 root root 56 Apr 29 08:06 pgsql14.6
drwxr-xr-x. 2 root root 6 Apr 11 2018 sbin
drwxr-xr-x. 5 root root 49 Oct 5 2018 share
drwxr-xr-x. 2 root root 6 Apr 11 2018 src
[root@localhost local]# rm -rf pgsql
[root@localhost local]# ln -s /usr/local/pgsql14.11 /usr/local/pgsql
[root@localhost local]# ll
total 0
drwxr-xr-x. 2 root root 6 Apr 11 2018 bin
drwxr-xr-x. 2 root root 6 Apr 11 2018 etc
drwxr-xr-x. 2 root root 6 Apr 11 2018 games
drwxr-xr-x. 2 root root 6 Apr 11 2018 include
drwxr-xr-x. 2 root root 6 Apr 11 2018 lib
drwxr-xr-x. 2 root root 6 Apr 11 2018 lib64
drwxr-xr-x. 2 root root 6 Apr 11 2018 libexec
lrwxrwxrwx 1 root root 21 May 2 04:38 pgsql -> /usr/local/pgsql14.11
drwxr-xr-x 6 root root 56 May 2 04:33 pgsql14.11
drwxr-xr-x 6 root root 56 Apr 29 08:06 pgsql14.6
drwxr-xr-x. 2 root root 6 Apr 11 2018 sbin
drwxr-xr-x. 5 root root 49 Oct 5 2018 share
drwxr-xr-x. 2 root root 6 Apr 11 2018 src
[root@localhost local]#
4.重启pg数据库服务
重启前:
[root@localhost local]# psql postgres postgres
psql (14.11, server 14.6)
Type "help" for help.
postgres=# select version();
version
---------------------------------------------------------------------------------------------------------
PostgreSQL 14.6 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit
(1 row)
postgres=#
重启后:
[root@localhost local]# su - postgres
Last login: Tue Apr 30 06:02:50 UTC 2024 on pts/0
[postgres@localhost ~]$ pg_ctl stop
waiting for server to shut down.... done
server stopped
[postgres@localhost ~]$ pg_ctl start
server started
[postgres@localhost ~]$ psql
psql (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)
postgres=#