这里具体介绍PostGreSQL基于源码进行编译安装的过程,操作系统为RedHat8,PostGreSQL版本为最新的15.4的版本,官方下载地址:https://www.postgresql.org/ftp/source/v15.4/

编译安装总体过程参考其官网文档,以避免网络种可能存在的以讹传讹的情况,15.4官方安装手册参考:https://www.postgresql.org/docs/15/install-requirements.html
安装前准备
1、确保make版本不低于3.81
[root@localhost ~]# make --version
GNU Make 4.2.1
Built for x86_64-redhat-linux-gnu
Copyright (C) 1988-2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
[root@localhost ~]#
其他依赖包主要是软件的一些高级功能依赖,具体可以看官网的说明,默认安装以下依赖包就行了。
[root@localhost ~]# yum install -y bzip2 gzip zlib perl python3 openldap bison flex readline-devel zlib-devel gcc libxml2 libxml2-devel lz4 lz4-devel systemtap-sdt-devel perl-ExtUtils-Embed perl-ExtUtils-MakeMaker openssl openssl-devel pam pam-devel libxslt libxslt-devel systemd-devel tcl tcl-devel
2、下载源码安装包并解压
[root@localhost setup]# ls
postgresql-15.4.tar.gz
[root@localhost setup]#
[root@localhost setup]# pwd
/soft/postgresql/setup
[root@localhost setup]# tar -xzvf postgresql-15.4.tar.gz
[root@localhost setup]# ls
postgresql-15.4 postgresql-15.4.tar.gz
3、创建用户组合用户
[root@localhost ~]# groupadd postgres
[root@localhost ~]# useradd -d /home/postgres -m postgres -g postgres
[root@localhost ~]# passwd postgres
Changing password for user postgres.
New password: postgres
BAD PASSWORD: The password contains the user name in some form
Retype new password: postgres
passwd: all authentication tokens updated successfully.
编译安装
1、编译
[root@localhost postgresql-15.4]# mkdir -p /soft/postgresql/pgsql
[root@localhost postgresql-15.4]# ./configure --prefix=/soft/postgresql/pgsql --with-libxml --with-lz4 --enable-debug --with-perl --with-tcl --with-gssapi --with-pam --with-openssl --with-pam --without-ldap --with-libxml --with-libxslt --enable-dtrace --enable-depend --enable-cassert --with-systemd
[root@localhost postgresql-15.4]# gmake world && gmake install-world
2、安装
[root@localhost postgresql-15.4]# make -j4
[root@localhost postgresql-15.4]# make install

到此PostgreSQL数据库软件就安装完了,对于数据库实例的初始化等我们后面再来具体介绍。
原创文章,作者:lzb,如若转载,请注明出处:https://www.wlkjzx.com/2023/08/15/postgresql%e6%ba%90%e7%a0%81%e7%bc%96%e8%af%91%e5%ae%89%e8%a3%85-redhat8/