一、centos7 postgresql-12的预安装版本的安装方法:
# Install the repository RPM:
sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
# Install PostgreSQL:
sudo yum install -y postgresql12-server
# Optionally initialize the database and enable automatic start:
sudo /usr/pgsql-12/bin/postgresql-12-setup initdb
sudo systemctl enable postgresql-12
sudo systemctl start postgresql-12
二、postgresql-12 源码安装方式:
1 下载
官网提供了源码和预安装的版本。 源码需要编译安装,解决依赖包等问题,而预安装的版本要简单很多。只需下载解压, 初始化数据库即可。
本例以源码安装为例:请至官网 下载源码。
本例中安装的是PG12. 在 https://www.postgresql.org/ftp/source/v12.0/ 中选择postgresql-12.0.tar.bz2
请根据需要先择自己需要的版本。
预安装版本,请至官网下载。
2 准备环境
此步骤以root用户执行。 将postgresql的安装包放到/opt 路径。
# 创建组和用户
groupadd postgre
useradd -g postgre -G postgre -d /home/postgresql postgre
passwd postgre
# 安装依赖包
yum install -y bzip2 readline-devel zlib-devel
# 将安装包放在/opt 路径中并解压
cd /opt/
bunzip2 postgresql-12.0.tar.bz2
tar -xvf ./postgresql-12.0.tar
3 编译安装
此步骤以postgre 用户操作:
cd /opt/postgresql-12.0
./configure --prefix=/home/postgresql/dbhome
make && make install
安装后,可执行文件,库文件等都会安装在/home/postgresql/dbhome 中。

最低0.47元/天 解锁文章
1万+

被折叠的 条评论
为什么被折叠?



