暂无图片
暂无图片
1
暂无图片
暂无图片
暂无图片

Postgresql16小版本升级

原创 龙舌兰地落🌏 2024-08-13
222

本例为16.1升级至16.4
先下载对应Source code介质:

https://www.postgresql.org/download/

上传至服务器后解压:

tar -zxvf postgresql-14.6.tar.gz

升级前先做一个全备份(最好是pg_dump逻辑备份),之后检查版本等其他信息

su - postgres
psql
\q

然后停服务:

pg_ctl stop

查看postgresql用户环境变量:

[postgres@localhost ~]$ 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=/pgsql/postgresql

export PGDATA=/pgsql/postgresql/data

PATH=$PATH:$HOME/bin:$PGHOME/bin

补充安装一些依赖:

sudo yum install libicu-devel  readline-devel  perl-ExtUtils-Embed  python3 python3-dev  libxml2 libxml2-devel   libxslt libxslt-devel   -y

root用户下编译安装:

mkdir /usr/local/pgsql16.4
cd postgresql-16.4
./configure --prefix=/usr/local/pgsql16.4 --with-perl --with-python --with-libxml --with-libxslt --with-openssl
make && make install

更改属组:

chown -R postgres:postgres  /usr/local/pgsql16.4

拷贝原data目录到新版本数据库数据目录下:

su - postgresql
cd $PGHOME
cp -rf data  /usr/local/pgsql16.4/

改环境变量:

vim ~/.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=/usr/local/pgsql16.4/

export PGDATA=$PGHOME/data

PATH=$PATH:$HOME/bin:$PGHOME/bin

生效:

source ~/.bash_profile

然后即可启动数据库并查看版本:

./pg_ctl start
./psql

检查版本已更新。

「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

文章被以下合辑收录

评论