美文网首页
postgresql小版本升级

postgresql小版本升级

作者: 这货不是王马勺 | 来源:发表于2024-08-12 16:54 被阅读0次

本例为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

检查版本已更新。

相关文章

网友评论

      本文标题:postgresql小版本升级

      本文链接:https://www.haomeiwen.com/subject/ulkdkjtx.html