首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >PostgreSQL源码编译安装(一)

PostgreSQL源码编译安装(一)

原创
作者头像
Raymond运维
发布2025-09-11 17:07:54
发布2025-09-11 17:07:54
1100
代码可运行
举报
文章被收录于专栏:干货分享干货分享
运行总次数:0
代码可运行

2.3 源码编译安装PostgreSQL

2.3.1 下载并解压缩源码包

PostgreSQL源码包下载,去“https://www.postgresql.org/ftp/source”网站下载,根据需要的版本下载,比如这里下载:v17.6。

t6
t6

图6 下载PostgreSQL源码包

然后下载源码包“postgresql-17.6.tar.gz”。

t7
t7

图7 下载PostgreSQL源码包

代码语言:javascript
代码运行次数:0
运行
复制
# Rocky、Almalinux、CentOS、AnolisOS、OpenCloudOS、Kylin Server默认没有wget包,需要安装
yum install -y wget

# openEuler 22.03/24.03 LTS、AnolisOS 23、OpenCloudOS 9没有安装tar包,需要安装
yum install -y tar

cd /usr/local/src

# 下载解压缩
wget https://ftp.postgresql.org/pub/source/v17.6/postgresql-17.6.tar.gz 
tar xf postgresql-17.6.tar.gz

2.3.2 源码编译安装PostgreSQL

编译安装参数解释:

代码语言:javascript
代码运行次数:0
运行
复制
./configure # 准备PostgreSQL的编译环境
--prefix # 指定 PostgreSQL 安装目录
--with-openssl # 启用 OpenSSL 支持
--with-libxml # 启用 XML 支持
--with-systemd # 启用 Systemd 支持
2.3.2.1 Rocky 8/9/10、AlmaLinux 8/9/10、CentOS Stream 8/9/10、OpenCloudOS 8

进入PostgreSQL包解压的目录:

代码语言:javascript
代码运行次数:0
运行
复制
cd postgresql-17.6

安装make包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y make

执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
configure: error: no acceptable C compiler found in $PATH # 提示,在$PATH中找不到可接受的C编译器,需要安装gcc
See `config.log' for more details

安装gcc包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y gcc

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
checking for icu-uc icu-i18n... no
configure: error: ICU library not found # 提示,未找到 ICU 库
If you have ICU already installed, see config.log for details on the
failure.  It is possible the compiler isn't looking in the proper directory.
Use --without-icu to disable ICU support.

安装libicu-devel包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y libicu-devel

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
checking for bison... no
configure: error: bison not found # 提示,未找到bison

安装bison包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y bison

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
checking for flex... no
configure: error: flex not found # 提示,未找到flex

安装flex包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y flex

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
checking for perl... no
configure: error: Perl not found # 提示,未找到Perl

安装perl包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y perl

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
checking for library containing readline... no
configure: error: readline library not found  # 提示,未找到readline库
If you have readline already installed, see config.log for details on the
failure.  It is possible the compiler isn't looking in the proper directory.
Use --without-readline to disable readline support.

安装readline-devel包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y readline-devel

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
configure: error: zlib library not found # 提示,为找到zlib库
If you have zlib already installed, see config.log for details on the
failure.  It is possible the compiler isn't looking in the proper directory.
Use --without-zlib to disable zlib support.

安装zlib-devel包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y zlib-devel

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
checking for CRYPTO_new_ex_data in -lcrypto... no
configure: error: library 'crypto' is required for OpenSSL # 提示,需要库 'crypto' 来支持 OpenSSL

安装openssl-devel包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y openssl-devel

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
checking for xmlSaveToBuffer in -lxml2... no
configure: error: library 'xml2' (version >= 2.6.23) is required for XML support # 提示,需要库 'xml2'(版本 >= 2.6.23)以支持 XML

安装libxml2-devel包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y libxml2-devel

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
configure: error: header file <systemd/sd-daemon.h> is required for systemd support # 提示,需要头文件 <systemd/sd-daemon.h> 以支持 systemd

安装systemd-devel包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y systemd-devel

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd

执行make:

代码语言:javascript
代码运行次数:0
运行
复制
# 默认 make 不包括文档和其它模块,$(nproc)表示当产主机的CPU核心
make -j $(nproc) world
...
make[2]: Leaving directory '/usr/local/src/postgresql-17.6/src/test/isolation'
make -C test/perl all
make[2]: Entering directory '/usr/local/src/postgresql-17.6/src/test/perl'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/usr/local/src/postgresql-17.6/src/test/perl'
make[1]: Leaving directory '/usr/local/src/postgresql-17.6/src'

执行make install:

代码语言:javascript
代码运行次数:0
运行
复制
# 默认 make install 不包括安装文档
make install-world
...
make[3]: *** [Makefile:72: postgres-full.xml] Error 1
make[3]: Leaving directory '/usr/local/src/postgresql-17.6/doc/src/sgml'
make[2]: *** [Makefile:8: install] Error 2
make[2]: Leaving directory '/usr/local/src/postgresql-17.6/doc/src'
make[1]: *** [Makefile:16: install] Error 2
make[1]: Leaving directory '/usr/local/src/postgresql-17.6/doc'
make: *** [GNUmakefile:32: install-world-doc-recurse] Error 2

从“https://www.postgresql.org/docs/current/docguide-toolsets.html#DOCGUIDE-TOOLSETS-INST-FEDORA-ET-AL”网址看到安装文档需要安装的包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y docbook-dtds docbook-style-xsl libxslt

重新执行make install:

代码语言:javascript
代码运行次数:0
运行
复制
make install-world
。。。
/usr/bin/mkdir -p '/apps/pgsql/lib'
/usr/bin/mkdir -p '/apps/pgsql/share/extension'
/usr/bin/mkdir -p '/apps/pgsql/share/extension'
/usr/bin/install -c -m 755  pgxml.so '/apps/pgsql/lib/pgxml.so'
/usr/bin/install -c -m 644 ./xml2.control '/apps/pgsql/share/extension/'
/usr/bin/install -c -m 644 ./xml2--1.1.sql ./xml2--1.0--1.1.sql  '/apps/pgsql/share/extension/'
make[2]: Leaving directory '/usr/local/src/postgresql-17.6/contrib/xml2'
make[1]: Leaving directory '/usr/local/src/postgresql-17.6/contrib'

总结编译过程:

代码语言:javascript
代码运行次数:0
运行
复制
# 安装依赖包
yum install -y make gcc libicu-devel bison flex perl readline-devel zlib-devel openssl-devel libxml2-devel systemd-devel docbook-dtds docbook-style-xsl libxslt

# 进入PostgreSQL包解压的目录:
cd postgresql-17.6

# 执行configure
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd

# 执行make
make -j $(nproc) world

# 执行make install
make install-world
2.3.2.2 CentOS 7

进入PostgreSQL包解压的目录:

代码语言:javascript
代码运行次数:0
运行
复制
cd postgresql-17.6

执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
configure: error: no acceptable C compiler found in $PATH # 提示,在$PATH中找不到可接受的C编译器,需要安装gcc
See `config.log' for more details

安装gcc包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y gcc

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
checking for icu-uc icu-i18n... no
configure: error: ICU library not found # 提示,未找到 ICU 库
If you have ICU already installed, see config.log for details on the
failure.  It is possible the compiler isn't looking in the proper directory.
Use --without-icu to disable ICU support.

安装libicu-devel包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y libicu-devel

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
checking for bison... no
configure: error: bison not found # 提示,未找到bison

安装bison包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y bison

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
checking for flex... no
configure: error: flex not found # 提示,未找到flex

安装flex包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y flex

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
checking for perl... no
configure: error: Perl not found # 提示,未找到Perl

安装perl包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y perl

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
checking for library containing readline... no
configure: error: readline library not found  # 提示,未找到readline库
If you have readline already installed, see config.log for details on the
failure.  It is possible the compiler isn't looking in the proper directory.
Use --without-readline to disable readline support.

安装readline-devel包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y readline-devel

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
configure: error: zlib library not found # 提示,为找到zlib库
If you have zlib already installed, see config.log for details on the
failure.  It is possible the compiler isn't looking in the proper directory.
Use --without-zlib to disable zlib support.

安装zlib-devel包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y zlib-devel

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
checking for CRYPTO_new_ex_data in -lcrypto... no
configure: error: library 'crypto' is required for OpenSSL # 提示,需要库 'crypto' 来支持 OpenSSL

安装openssl-devel包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y openssl-devel

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
checking for xmlSaveToBuffer in -lxml2... no
configure: error: library 'xml2' (version >= 2.6.23) is required for XML support # 提示,需要库 'xml2'(版本 >= 2.6.23)以支持 XML

安装libxml2-devel包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y libxml2-devel

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
configure: error: header file <systemd/sd-daemon.h> is required for systemd support # 提示,需要头文件 <systemd/sd-daemon.h> 以支持 systemd

安装systemd-devel包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y systemd-devel

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd

执行make:

代码语言:javascript
代码运行次数:0
运行
复制
# 默认 make 不包括文档和其它模块,$(nproc)表示当产主机的CPU核心
make -j $(nproc) world
...
make[2]: Leaving directory '/usr/local/src/postgresql-17.6/src/test/isolation'
make -C test/perl all
make[2]: Entering directory '/usr/local/src/postgresql-17.6/src/test/perl'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/usr/local/src/postgresql-17.6/src/test/perl'
make[1]: Leaving directory '/usr/local/src/postgresql-17.6/src'

执行make install:

代码语言:javascript
代码运行次数:0
运行
复制
# 默认 make install 不包括安装文档
make install-world
...
make[3]: *** [Makefile:72: postgres-full.xml] Error 1
make[3]: Leaving directory '/usr/local/src/postgresql-17.6/doc/src/sgml'
make[2]: *** [Makefile:8: install] Error 2
make[2]: Leaving directory '/usr/local/src/postgresql-17.6/doc/src'
make[1]: *** [Makefile:16: install] Error 2
make[1]: Leaving directory '/usr/local/src/postgresql-17.6/doc'
make: *** [GNUmakefile:32: install-world-doc-recurse] Error 2

从“https://www.postgresql.org/docs/current/docguide-toolsets.html#DOCGUIDE-TOOLSETS-INST-FEDORA-ET-AL”网址看到安装文档需要安装的包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y docbook-dtds docbook-style-xsl libxslt

重新执行make install:

代码语言:javascript
代码运行次数:0
运行
复制
make install-world
。。。
/usr/bin/mkdir -p '/apps/pgsql/lib'
/usr/bin/mkdir -p '/apps/pgsql/share/extension'
/usr/bin/mkdir -p '/apps/pgsql/share/extension'
/usr/bin/install -c -m 755  pgxml.so '/apps/pgsql/lib/pgxml.so'
/usr/bin/install -c -m 644 ./xml2.control '/apps/pgsql/share/extension/'
/usr/bin/install -c -m 644 ./xml2--1.1.sql ./xml2--1.0--1.1.sql  '/apps/pgsql/share/extension/'
make[2]: Leaving directory '/usr/local/src/postgresql-17.6/contrib/xml2'
make[1]: Leaving directory '/usr/local/src/postgresql-17.6/contrib'

总结编译过程:

代码语言:javascript
代码运行次数:0
运行
复制
# 安装依赖包
yum install -y gcc libicu-devel bison flex perl readline-devel zlib-devel openssl-devel libxml2-devel systemd-devel docbook-dtds docbook-style-xsl libxslt

# 进入PostgreSQL包解压的目录:
cd postgresql-17.6

# 执行configure
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd

# 执行make
make -j $(nproc) world

# 执行make install
make install-world
2.3.2.3 openEuler 22.03/24.03 LTS

进入PostgreSQL包解压的目录:

代码语言:javascript
代码运行次数:0
运行
复制
cd postgresql-17.6

安装make包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y make

执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
configure: error: no acceptable C compiler found in $PATH # 提示,在$PATH中找不到可接受的C编译器,需要安装gcc
See `config.log' for more details

安装gcc包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y gcc

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
checking for icu-uc icu-i18n... no
configure: error: ICU library not found # 提示,未找到 ICU 库
If you have ICU already installed, see config.log for details on the
failure.  It is possible the compiler isn't looking in the proper directory.
Use --without-icu to disable ICU support.

安装libicu-devel包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y libicu-devel

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
checking for bison... no
configure: error: bison not found # 提示,未找到bison

安装bison包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y bison

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
checking for flex... no
configure: error: flex not found # 提示,未找到flex

安装flex包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y flex

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
checking for library containing readline... no
configure: error: readline library not found  # 提示,未找到readline库
If you have readline already installed, see config.log for details on the
failure.  It is possible the compiler isn't looking in the proper directory.
Use --without-readline to disable readline support.

安装readline-devel包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y readline-devel

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
configure: error: zlib library not found # 提示,为找到zlib库
If you have zlib already installed, see config.log for details on the
failure.  It is possible the compiler isn't looking in the proper directory.
Use --without-zlib to disable zlib support.

安装zlib-devel包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y zlib-devel

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
checking for CRYPTO_new_ex_data in -lcrypto... no
configure: error: library 'crypto' is required for OpenSSL # 提示,需要库 'crypto' 来支持 OpenSSL

安装openssl-devel包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y openssl-devel

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
checking for xmlSaveToBuffer in -lxml2... no
configure: error: library 'xml2' (version >= 2.6.23) is required for XML support # 提示,需要库 'xml2'(版本 >= 2.6.23)以支持 XML

安装libxml2-devel包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y libxml2-devel

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
configure: error: header file <systemd/sd-daemon.h> is required for systemd support # 提示,需要头文件 <systemd/sd-daemon.h> 以支持 systemd

安装systemd-devel包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y systemd-devel

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd

执行make:

代码语言:javascript
代码运行次数:0
运行
复制
# 默认 make 不包括文档和其它模块,$(nproc)表示当产主机的CPU核心
make -j $(nproc) world
...
make[2]: Leaving directory '/usr/local/src/postgresql-17.6/src/test/isolation'
make -C test/perl all
make[2]: Entering directory '/usr/local/src/postgresql-17.6/src/test/perl'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/usr/local/src/postgresql-17.6/src/test/perl'
make[1]: Leaving directory '/usr/local/src/postgresql-17.6/src'

执行make install:

代码语言:javascript
代码运行次数:0
运行
复制
# 默认 make install 不包括安装文档
make install-world
...
make[3]: *** [Makefile:72: postgres-full.xml] Error 1
make[3]: Leaving directory '/usr/local/src/postgresql-17.6/doc/src/sgml'
make[2]: *** [Makefile:8: install] Error 2
make[2]: Leaving directory '/usr/local/src/postgresql-17.6/doc/src'
make[1]: *** [Makefile:16: install] Error 2
make[1]: Leaving directory '/usr/local/src/postgresql-17.6/doc'
make: *** [GNUmakefile:32: install-world-doc-recurse] Error 2

从“https://www.postgresql.org/docs/current/docguide-toolsets.html#DOCGUIDE-TOOLSETS-INST-FEDORA-ET-AL”网址看到安装文档需要安装的包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y docbook-dtds docbook-style-xsl libxslt

重新执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
# 再次执行make之前先清理之前的操作
make clean

./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd

执行make:

代码语言:javascript
代码运行次数:0
运行
复制
make -j $(nproc) world

重新执行make install:

代码语言:javascript
代码运行次数:0
运行
复制
make install-world
。。。
make[2]: Leaving directory '/usr/local/src/postgresql-17.6/contrib/sslinfo'
make -C xml2 install
make[2]: Entering directory '/usr/local/src/postgresql-17.6/contrib/xml2'
/usr/bin/mkdir -p '/apps/pgsql/lib'
/usr/bin/mkdir -p '/apps/pgsql/share/extension'
/usr/bin/mkdir -p '/apps/pgsql/share/extension'
/usr/bin/install -c -m 755  pgxml.so '/apps/pgsql/lib/pgxml.so'
/usr/bin/install -c -m 644 ./xml2.control '/apps/pgsql/share/extension/'
/usr/bin/install -c -m 644 ./xml2--1.1.sql ./xml2--1.0--1.1.sql  '/apps/pgsql/share/extension/'
make[2]: Leaving directory '/usr/local/src/postgresql-17.6/contrib/xml2'
make[1]: Leaving directory '/usr/local/src/postgresql-17.6/contrib'

总结编译过程:

代码语言:javascript
代码运行次数:0
运行
复制
# 安装依赖包
yum install -y make gcc libicu-devel bison flex readline-devel zlib-devel openssl-devel libxml2-devel systemd-devel docbook-dtds docbook-style-xsl libxslt

# 进入PostgreSQL包解压的目录:
cd postgresql-17.6

# 执行configure
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd

# 执行make
make -j $(nproc) world

# 执行make install
make install-world
2.3.2.4 AnolisOS 23

进入PostgreSQL包解压的目录:

代码语言:javascript
代码运行次数:0
运行
复制
cd postgresql-17.6

执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
configure: error: no acceptable C compiler found in $PATH # 提示,在$PATH中找不到可接受的C编译器,需要安装gcc
See `config.log' for more details

安装gcc包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y gcc

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
checking for icu-uc icu-i18n... no
configure: error: ICU library not found # 提示,未找到 ICU 库
If you have ICU already installed, see config.log for details on the
failure.  It is possible the compiler isn't looking in the proper directory.
Use --without-icu to disable ICU support.

安装libicu-devel包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y libicu-devel

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
checking for bison... no
configure: error: bison not found # 提示,未找到bison

安装bison包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y bison

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
checking for flex... no
configure: error: flex not found # 提示,未找到flex

安装flex包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y flex

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
checking for library containing readline... no
configure: error: readline library not found  # 提示,未找到readline库
If you have readline already installed, see config.log for details on the
failure.  It is possible the compiler isn't looking in the proper directory.
Use --without-readline to disable readline support.

安装readline-devel包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y readline-devel

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
configure: error: zlib library not found # 提示,为找到zlib库
If you have zlib already installed, see config.log for details on the
failure.  It is possible the compiler isn't looking in the proper directory.
Use --without-zlib to disable zlib support.

安装zlib-devel包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y zlib-devel

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
checking for CRYPTO_new_ex_data in -lcrypto... no
configure: error: library 'crypto' is required for OpenSSL # 提示,需要库 'crypto' 来支持 OpenSSL

安装openssl-devel包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y openssl-devel

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
checking for xmlSaveToBuffer in -lxml2... no
configure: error: library 'xml2' (version >= 2.6.23) is required for XML support # 提示,需要库 'xml2'(版本 >= 2.6.23)以支持 XML

安装libxml2-devel包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y libxml2-devel

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
configure: error: header file <systemd/sd-daemon.h> is required for systemd support # 提示,需要头文件 <systemd/sd-daemon.h> 以支持 systemd

安装systemd-devel包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y systemd-devel

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd

执行make:

代码语言:javascript
代码运行次数:0
运行
复制
# 默认 make 不包括文档和其它模块,$(nproc)表示当产主机的CPU核心
make -j $(nproc) world
...
Can't locate FindBin.pm in @INC (you may need to install the FindBin module) (@INC contains: /usr/local/lib64/perl5/5.36 /usr/local/share/perl5/5.36 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5) at gen_node_support.pl line 24. # 提示,perl缺少FindBin.pm模块
BEGIN failed--compilation aborted at gen_node_support.pl line 24.
Can't locate FindBin.pm in @INC (you may need to install the FindBin module) (@INC contains: /usr/local/lib64/perl5/5.36 /usr/local/share/perl5/5.36 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5) at ../../../src/backend/catalog/genbki.pl line 20.
BEGIN failed--compilation aborted at ../../../src/backend/catalog/genbki.pl line 20.
make[2]: *** [Makefile:141: bki-stamp] Error 2
make[2]: Leaving directory '/usr/local/src/postgresql-17.6/src/include/catalog'
make[1]: *** [Makefile:121: submake-catalog-headers] Error 2
make[1]: *** Waiting for unfinished jobs....
make[2]: *** [Makefile:78: node-support-stamp] Error 2
make[2]: Leaving directory '/usr/local/src/postgresql-17.6/src/backend/nodes'
make[1]: *** [Makefile:125: submake-nodes-headers] Error 2
make[1]: Leaving directory '/usr/local/src/postgresql-17.6/src/backend'
make: *** [src/Makefile.global:384: submake-generated-headers] Error 2

安装perl-FindBin和perl-core包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y perl-FindBin perl-core

执行make:

代码语言:javascript
代码运行次数:0
运行
复制
make -j $(nproc) world

执行make install:

代码语言:javascript
代码运行次数:0
运行
复制
# 默认 make install 不包括安装文档
make install-world
...
make[3]: *** [Makefile:72: postgres-full.xml] Error 1
make[3]: Leaving directory '/usr/local/src/postgresql-17.6/doc/src/sgml'
make[2]: *** [Makefile:8: install] Error 2
make[2]: Leaving directory '/usr/local/src/postgresql-17.6/doc/src'
make[1]: *** [Makefile:16: install] Error 2
make[1]: Leaving directory '/usr/local/src/postgresql-17.6/doc'
make: *** [GNUmakefile:32: install-world-doc-recurse] Error 2

从“https://www.postgresql.org/docs/current/docguide-toolsets.html#DOCGUIDE-TOOLSETS-INST-FEDORA-ET-AL”网址看到安装文档需要安装的包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y docbook-dtds docbook-style-xsl libxslt

重新执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
# 再次执行make之前先清理之前的操作
make clean

./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd

执行make:

代码语言:javascript
代码运行次数:0
运行
复制
make -j $(nproc) world

重新执行make install:

代码语言:javascript
代码运行次数:0
运行
复制
make install-world
。。。
/usr/bin/mkdir -p '/apps/pgsql/lib'
/usr/bin/mkdir -p '/apps/pgsql/share/extension'
/usr/bin/mkdir -p '/apps/pgsql/share/extension'
/usr/bin/install -c -m 755  pgxml.so '/apps/pgsql/lib/pgxml.so'
/usr/bin/install -c -m 644 ./xml2.control '/apps/pgsql/share/extension/'
/usr/bin/install -c -m 644 ./xml2--1.1.sql ./xml2--1.0--1.1.sql  '/apps/pgsql/share/extension/'
make[2]: Leaving directory '/usr/local/src/postgresql-17.6/contrib/xml2'
make[1]: Leaving directory '/usr/local/src/postgresql-17.6/contrib'

总结编译过程:

代码语言:javascript
代码运行次数:0
运行
复制
# 安装依赖包
yum install -y gcc libicu-devel bison flex readline-devel zlib-devel openssl-devel libxml2-devel systemd-devel perl-FindBin perl-core docbook-dtds docbook-style-xsl libxslt

# 进入PostgreSQL包解压的目录:
cd postgresql-17.6

# 执行configure
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd

# 执行make
make -j $(nproc) world

# 执行make install
make install-world
2.3.2.5 AnolisOS 8

进入PostgreSQL包解压的目录:

代码语言:javascript
代码运行次数:0
运行
复制
cd postgresql-17.6

安装make包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y make

执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
configure: error: no acceptable C compiler found in $PATH # 提示,在$PATH中找不到可接受的C编译器,需要安装gcc
See `config.log' for more details

安装gcc包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y gcc

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
checking for icu-uc icu-i18n... no
configure: error: ICU library not found # 提示,未找到 ICU 库
If you have ICU already installed, see config.log for details on the
failure.  It is possible the compiler isn't looking in the proper directory.
Use --without-icu to disable ICU support.

安装libicu-devel包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y libicu-devel

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
checking for bison... no
configure: error: bison not found # 提示,未找到bison

安装bison包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y bison

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
checking for flex... no
configure: error: flex not found # 提示,未找到flex

安装flex包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y flex

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
checking for library containing readline... no
configure: error: readline library not found  # 提示,未找到readline库
If you have readline already installed, see config.log for details on the
failure.  It is possible the compiler isn't looking in the proper directory.
Use --without-readline to disable readline support.

安装readline-devel包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y readline-devel

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
configure: error: zlib library not found # 提示,为找到zlib库
If you have zlib already installed, see config.log for details on the
failure.  It is possible the compiler isn't looking in the proper directory.
Use --without-zlib to disable zlib support.

安装zlib-devel包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y zlib-devel

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
checking for CRYPTO_new_ex_data in -lcrypto... no
configure: error: library 'crypto' is required for OpenSSL # 提示,需要库 'crypto' 来支持 OpenSSL

安装openssl-devel包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y openssl-devel

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
checking for xmlSaveToBuffer in -lxml2... no
configure: error: library 'xml2' (version >= 2.6.23) is required for XML support # 提示,需要库 'xml2'(版本 >= 2.6.23)以支持 XML

安装libxml2-devel包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y libxml2-devel

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
configure: error: header file <systemd/sd-daemon.h> is required for systemd support # 提示,需要头文件 <systemd/sd-daemon.h> 以支持 systemd

安装systemd-devel包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y systemd-devel

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd

执行make:

代码语言:javascript
代码运行次数:0
运行
复制
# 默认 make 不包括文档和其它模块,$(nproc)表示当产主机的CPU核心
make -j $(nproc) world
...
make[2]: Leaving directory '/usr/local/src/postgresql-17.6/src/test/isolation'
make -C test/perl all
make[2]: Entering directory '/usr/local/src/postgresql-17.6/src/test/perl'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/usr/local/src/postgresql-17.6/src/test/perl'
make[1]: Leaving directory '/usr/local/src/postgresql-17.6/src'

执行make install:

代码语言:javascript
代码运行次数:0
运行
复制
# 默认 make install 不包括安装文档
make install-world
...
make[3]: *** [Makefile:72: postgres-full.xml] Error 1
make[3]: Leaving directory '/usr/local/src/postgresql-17.6/doc/src/sgml'
make[2]: *** [Makefile:8: install] Error 2
make[2]: Leaving directory '/usr/local/src/postgresql-17.6/doc/src'
make[1]: *** [Makefile:16: install] Error 2
make[1]: Leaving directory '/usr/local/src/postgresql-17.6/doc'
make: *** [GNUmakefile:32: install-world-doc-recurse] Error 2

从“https://www.postgresql.org/docs/current/docguide-toolsets.html#DOCGUIDE-TOOLSETS-INST-FEDORA-ET-AL”网址看到安装文档需要安装的包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y docbook-dtds docbook-style-xsl libxslt

重新执行make install:

代码语言:javascript
代码运行次数:0
运行
复制
make install-world
。。。
/usr/bin/mkdir -p '/apps/pgsql/lib'
/usr/bin/mkdir -p '/apps/pgsql/share/extension'
/usr/bin/mkdir -p '/apps/pgsql/share/extension'
/usr/bin/install -c -m 755  pgxml.so '/apps/pgsql/lib/pgxml.so'
/usr/bin/install -c -m 644 ./xml2.control '/apps/pgsql/share/extension/'
/usr/bin/install -c -m 644 ./xml2--1.1.sql ./xml2--1.0--1.1.sql  '/apps/pgsql/share/extension/'
make[2]: Leaving directory '/usr/local/src/postgresql-17.6/contrib/xml2'
make[1]: Leaving directory '/usr/local/src/postgresql-17.6/contrib'

总结编译过程:

代码语言:javascript
代码运行次数:0
运行
复制
# 安装依赖包
yum install -y make gcc libicu-devel bison flex readline-devel zlib-devel openssl-devel libxml2-devel systemd-devel docbook-dtds docbook-style-xsl libxslt

# 进入PostgreSQL包解压的目录:
cd postgresql-17.6

# 执行configure
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd

# 执行make
make -j $(nproc) world

# 执行make install
make install-world
2.3.2.6 OpenCloudOS 9、Kylin Server V10

进入PostgreSQL包解压的目录:

代码语言:javascript
代码运行次数:0
运行
复制
cd postgresql-17.6

安装make包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y make

执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
configure: error: no acceptable C compiler found in $PATH # 提示,在$PATH中找不到可接受的C编译器,需要安装gcc
See `config.log' for more details

安装gcc包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y gcc

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
checking for icu-uc icu-i18n... no
configure: error: ICU library not found # 提示,未找到 ICU 库
If you have ICU already installed, see config.log for details on the
failure.  It is possible the compiler isn't looking in the proper directory.
Use --without-icu to disable ICU support.

安装libicu-devel包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y libicu-devel

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
checking for bison... no
configure: error: bison not found # 提示,未找到bison

安装bison包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y bison

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
checking for flex... no
configure: error: flex not found # 提示,未找到flex

安装flex包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y flex

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
checking for perl... no
configure: error: Perl not found # 提示,未找到Perl

安装perl包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y perl

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
checking for library containing readline... no
configure: error: readline library not found  # 提示,未找到readline库
If you have readline already installed, see config.log for details on the
failure.  It is possible the compiler isn't looking in the proper directory.
Use --without-readline to disable readline support.

安装readline-devel包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y readline-devel

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
configure: error: zlib library not found # 提示,为找到zlib库
If you have zlib already installed, see config.log for details on the
failure.  It is possible the compiler isn't looking in the proper directory.
Use --without-zlib to disable zlib support.

安装zlib-devel包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y zlib-devel

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
checking for CRYPTO_new_ex_data in -lcrypto... no
configure: error: library 'crypto' is required for OpenSSL # 提示,需要库 'crypto' 来支持 OpenSSL

安装openssl-devel包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y openssl-devel

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
checking for xmlSaveToBuffer in -lxml2... no
configure: error: library 'xml2' (version >= 2.6.23) is required for XML support # 提示,需要库 'xml2'(版本 >= 2.6.23)以支持 XML

安装libxml2-devel包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y libxml2-devel

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
configure: error: header file <systemd/sd-daemon.h> is required for systemd support # 提示,需要头文件 <systemd/sd-daemon.h> 以支持 systemd

安装systemd-devel包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y systemd-devel

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd

执行make:

代码语言:javascript
代码运行次数:0
运行
复制
# 默认 make 不包括文档和其它模块,$(nproc)表示当产主机的CPU核心
make -j $(nproc) world
...
make[2]: Leaving directory '/usr/local/src/postgresql-17.6/src/test/isolation'
make -C test/perl all
make[2]: Entering directory '/usr/local/src/postgresql-17.6/src/test/perl'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/usr/local/src/postgresql-17.6/src/test/perl'
make[1]: Leaving directory '/usr/local/src/postgresql-17.6/src'

执行make install:

代码语言:javascript
代码运行次数:0
运行
复制
# 默认 make install 不包括安装文档
make install-world
...
make[3]: *** [Makefile:72: postgres-full.xml] Error 1
make[3]: Leaving directory '/usr/local/src/postgresql-17.6/doc/src/sgml'
make[2]: *** [Makefile:8: install] Error 2
make[2]: Leaving directory '/usr/local/src/postgresql-17.6/doc/src'
make[1]: *** [Makefile:16: install] Error 2
make[1]: Leaving directory '/usr/local/src/postgresql-17.6/doc'
make: *** [GNUmakefile:32: install-world-doc-recurse] Error 2

从“https://www.postgresql.org/docs/current/docguide-toolsets.html#DOCGUIDE-TOOLSETS-INST-FEDORA-ET-AL”网址看到安装文档需要安装的包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y docbook-dtds docbook-style-xsl libxslt

重新执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
# 再次执行make之前先清理之前的操作
make clean

./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd

执行make:

代码语言:javascript
代码运行次数:0
运行
复制
make -j $(nproc) world

重新执行make install:

代码语言:javascript
代码运行次数:0
运行
复制
make install-world
。。。
make[2]: Leaving directory '/usr/local/src/postgresql-17.6/contrib/sslinfo'
make -C xml2 install
make[2]: Entering directory '/usr/local/src/postgresql-17.6/contrib/xml2'
/usr/bin/mkdir -p '/apps/pgsql/lib'
/usr/bin/mkdir -p '/apps/pgsql/share/extension'
/usr/bin/mkdir -p '/apps/pgsql/share/extension'
/usr/bin/install -c -m 755  pgxml.so '/apps/pgsql/lib/pgxml.so'
/usr/bin/install -c -m 644 ./xml2.control '/apps/pgsql/share/extension/'
/usr/bin/install -c -m 644 ./xml2--1.1.sql ./xml2--1.0--1.1.sql  '/apps/pgsql/share/extension/'
make[2]: Leaving directory '/usr/local/src/postgresql-17.6/contrib/xml2'
make[1]: Leaving directory '/usr/local/src/postgresql-17.6/contrib'

总结编译过程:

代码语言:javascript
代码运行次数:0
运行
复制
# 安装依赖包
yum install -y make gcc libicu-devel bison flex perl readline-devel zlib-devel openssl-devel libxml2-devel systemd-devel docbook-dtds docbook-style-xsl libxslt

# 进入PostgreSQL包解压的目录:
cd postgresql-17.6

# 执行configure
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd

# 执行make
make -j $(nproc) world

# 执行make install
make install-world
2.3.2.7 UOS Server V20

进入PostgreSQL包解压的目录:

代码语言:javascript
代码运行次数:0
运行
复制
cd postgresql-17.6

执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
checking for icu-uc icu-i18n... no
configure: error: ICU library not found # 提示,未找到 ICU 库
If you have ICU already installed, see config.log for details on the
failure.  It is possible the compiler isn't looking in the proper directory.
Use --without-icu to disable ICU support.

安装libicu-devel包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y libicu-devel

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
checking for bison... no
configure: error: bison not found # 提示,未找到bison

安装bison包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y bison

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
checking for flex... no
configure: error: flex not found # 提示,未找到flex

安装flex包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y flex

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
checking for library containing readline... no
configure: error: readline library not found  # 提示,未找到readline库
If you have readline already installed, see config.log for details on the
failure.  It is possible the compiler isn't looking in the proper directory.
Use --without-readline to disable readline support.

安装readline-devel包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y readline-devel

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
configure: error: header file <systemd/sd-daemon.h> is required for systemd support # 提示,需要头文件 <systemd/sd-daemon.h> 以支持 systemd

安装systemd-devel包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y systemd-devel

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd

执行make:

代码语言:javascript
代码运行次数:0
运行
复制
# 默认 make 不包括文档和其它模块,$(nproc)表示当产主机的CPU核心
make -j $(nproc) world
...
make[2]: Leaving directory '/usr/local/src/postgresql-17.6/src/test/isolation'
make -C test/perl all
make[2]: Entering directory '/usr/local/src/postgresql-17.6/src/test/perl'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/usr/local/src/postgresql-17.6/src/test/perl'
make[1]: Leaving directory '/usr/local/src/postgresql-17.6/src'

执行make install:

代码语言:javascript
代码运行次数:0
运行
复制
# 默认 make install 不包括安装文档
make install-world
...
make[3]: *** [Makefile:72: postgres-full.xml] Error 1
make[3]: Leaving directory '/usr/local/src/postgresql-17.6/doc/src/sgml'
make[2]: *** [Makefile:8: install] Error 2
make[2]: Leaving directory '/usr/local/src/postgresql-17.6/doc/src'
make[1]: *** [Makefile:16: install] Error 2
make[1]: Leaving directory '/usr/local/src/postgresql-17.6/doc'
make: *** [GNUmakefile:32: install-world-doc-recurse] Error 2

从“https://www.postgresql.org/docs/current/docguide-toolsets.html#DOCGUIDE-TOOLSETS-INST-FEDORA-ET-AL”网址看到安装文档需要安装的包:

代码语言:javascript
代码运行次数:0
运行
复制
yum install -y docbook-dtds docbook-style-xsl libxslt

重新执行make install:

代码语言:javascript
代码运行次数:0
运行
复制
make install-world
。。。
/usr/bin/mkdir -p '/apps/pgsql/lib'
/usr/bin/mkdir -p '/apps/pgsql/share/extension'
/usr/bin/mkdir -p '/apps/pgsql/share/extension'
/usr/bin/install -c -m 755  pgxml.so '/apps/pgsql/lib/pgxml.so'
/usr/bin/install -c -m 644 ./xml2.control '/apps/pgsql/share/extension/'
/usr/bin/install -c -m 644 ./xml2--1.1.sql ./xml2--1.0--1.1.sql  '/apps/pgsql/share/extension/'
make[2]: Leaving directory '/usr/local/src/postgresql-17.6/contrib/xml2'
make[1]: Leaving directory '/usr/local/src/postgresql-17.6/contrib'

总结编译过程:

代码语言:javascript
代码运行次数:0
运行
复制
# 安装依赖包
yum install -y libicu-devel bison flex perl readline-devel systemd-devel docbook-dtds docbook-style-xsl libxslt

# 进入PostgreSQL包解压的目录:
cd postgresql-17.6

# 执行configure
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd

# 执行make
make -j $(nproc) world

# 执行make install
make install-world
2.3.2.8 openSUSE 15

进入PostgreSQL包解压的目录:

代码语言:javascript
代码运行次数:0
运行
复制
cd postgresql-17.6

安装make包:

代码语言:javascript
代码运行次数:0
运行
复制
zypper install -y make

执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
configure: error: no acceptable C compiler found in $PATH # 提示,在$PATH中找不到可接受的C编译器,需要安装gcc
See `config.log' for more details

安装gcc包:

代码语言:javascript
代码运行次数:0
运行
复制
zypper install -y gcc

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
checking for icu-uc icu-i18n... no
configure: error: ICU library not found # 提示,未找到 ICU 库
If you have ICU already installed, see config.log for details on the
failure.  It is possible the compiler isn't looking in the proper directory.
Use --without-icu to disable ICU support.

安装libicu-devel包:

代码语言:javascript
代码运行次数:0
运行
复制
zypper install -y libicu-devel

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
checking for bison... no
configure: error: bison not found # 提示,未找到bison

安装bison包:

代码语言:javascript
代码运行次数:0
运行
复制
zypper install -y bison

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
checking for flex... no
configure: error: flex not found # 提示,未找到flex

安装flex包:

代码语言:javascript
代码运行次数:0
运行
复制
zypper install -y flex

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
checking for library containing readline... no
configure: error: readline library not found  # 提示,未找到readline库
If you have readline already installed, see config.log for details on the
failure.  It is possible the compiler isn't looking in the proper directory.
Use --without-readline to disable readline support.

安装readline-devel包:

代码语言:javascript
代码运行次数:0
运行
复制
zypper install -y readline-devel

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
configure: error: zlib library not found # 提示,为找到zlib库
If you have zlib already installed, see config.log for details on the
failure.  It is possible the compiler isn't looking in the proper directory.
Use --without-zlib to disable zlib support.

安装zlib-devel包:

代码语言:javascript
代码运行次数:0
运行
复制
zypper install -y zlib-devel

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
checking for CRYPTO_new_ex_data in -lcrypto... no
configure: error: library 'crypto' is required for OpenSSL # 提示,需要库 'crypto' 来支持 OpenSSL

安装openssl-devel包:

代码语言:javascript
代码运行次数:0
运行
复制
zypper install -y openssl-devel

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
checking for xmlSaveToBuffer in -lxml2... no
configure: error: library 'xml2' (version >= 2.6.23) is required for XML support # 提示,需要库 'xml2'(版本 >= 2.6.23)以支持 XML

安装libxml2-devel包:

代码语言:javascript
代码运行次数:0
运行
复制
zypper install -y libxml2-devel

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
configure: error: header file <systemd/sd-daemon.h> is required for systemd support # 提示,需要头文件 <systemd/sd-daemon.h> 以支持 systemd

安装systemd-devel包:

代码语言:javascript
代码运行次数:0
运行
复制
zypper install -y systemd-devel

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd

执行make:

代码语言:javascript
代码运行次数:0
运行
复制
# 默认 make 不包括文档和其它模块,$(nproc)表示当产主机的CPU核心
make -j $(nproc) world
...
make[3]: *** [Makefile:72: postgres-full.xml] Error 1
make[3]: Leaving directory '/usr/local/src/postgresql-17.6/doc/src/sgml'
make[2]: *** [Makefile:8: all] Error 2
make[2]: Leaving directory '/usr/local/src/postgresql-17.6/doc/src'
make[1]: *** [Makefile:16: all] Error 2
make[1]: Leaving directory '/usr/local/src/postgresql-17.6/doc'
make: *** [GNUmakefile:16: world-doc-recurse] Error 2

从“https://www.postgresql.org/docs/current/docguide-toolsets.html#DOCGUIDE-TOOLSETS-INST-FEDORA-ET-AL”网址看到安装文档需要安装的包:

代码语言:javascript
代码运行次数:0
运行
复制
zypper install -y docbook-xsl-stylesheets

重新执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
# 再次执行make之前先清理之前的操作
make clean

./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd

重新执行make:

代码语言:javascript
代码运行次数:0
运行
复制
make -j $(nproc) world

执行make install:

代码语言:javascript
代码运行次数:0
运行
复制
# 默认 make install 不包括安装文档
make install-world
。。。
/usr/bin/mkdir -p '/apps/pgsql/lib'
/usr/bin/mkdir -p '/apps/pgsql/share/extension'
/usr/bin/mkdir -p '/apps/pgsql/share/extension'
/usr/bin/install -c -m 755  pgxml.so '/apps/pgsql/lib/pgxml.so'
/usr/bin/install -c -m 644 ./xml2.control '/apps/pgsql/share/extension/'
/usr/bin/install -c -m 644 ./xml2--1.1.sql ./xml2--1.0--1.1.sql  '/apps/pgsql/share/extension/'
make[2]: Leaving directory '/usr/local/src/postgresql-17.6/contrib/xml2'
make[1]: Leaving directory '/usr/local/src/postgresql-17.6/contrib'

总结编译过程:

代码语言:javascript
代码运行次数:0
运行
复制
# 安装依赖包
zypper install -y make gcc libicu-devel bison flex readline-devel zlib-devel openssl-devel libxml2-devel systemd-devel docbook-xsl-stylesheets

# 进入PostgreSQL包解压的目录:
cd postgresql-17.6

# 执行configure
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd

# 执行make
make -j $(nproc) world

# 执行make install
make install-world
2.3.2.9 Ubuntu Server 20.04/22.04/24.04 LTS、Debian 11/12/13

进入PostgreSQL包解压的目录:

代码语言:javascript
代码运行次数:0
运行
复制
cd postgresql-17.6

安装make包:

代码语言:javascript
代码运行次数:0
运行
复制
apt install -y make

执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
configure: error: no acceptable C compiler found in $PATH # 提示,在$PATH中找不到可接受的C编译器,需要安装gcc
See `config.log' for more details

安装gcc包:

代码语言:javascript
代码运行次数:0
运行
复制
apt install -y gcc

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
checking for pkg-config... no # 没有检测到pkg-config,要安装pkg-config,否则还会出现报错
checking whether to build with ICU support... yes
checking for icu-uc icu-i18n... no
configure: error: ICU library not found # 提示,未找到 ICU 库
If you have ICU already installed, see config.log for details on the
failure.  It is possible the compiler isn't looking in the proper directory.
Use --without-icu to disable ICU support.

安装pkg-config和libicu-dev包:

代码语言:javascript
代码运行次数:0
运行
复制
apt install -y pkg-config libicu-dev

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
checking for bison... no
configure: error: bison not found # 提示,未找到bison

安装bison包:

代码语言:javascript
代码运行次数:0
运行
复制
apt install -y bison

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
checking for flex... no
configure: error: flex not found # 提示,未找到flex

安装flex包:

代码语言:javascript
代码运行次数:0
运行
复制
apt install -y flex

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
checking for library containing readline... no
configure: error: readline library not found  # 提示,未找到readline库
If you have readline already installed, see config.log for details on the
failure.  It is possible the compiler isn't looking in the proper directory.
Use --without-readline to disable readline support.

安装libreadline-dev包:

代码语言:javascript
代码运行次数:0
运行
复制
apt install -y libreadline-dev

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
configure: error: zlib library not found # 提示,为找到zlib库
If you have zlib already installed, see config.log for details on the
failure.  It is possible the compiler isn't looking in the proper directory.
Use --without-zlib to disable zlib support.

安装zlib1g-dev包:

代码语言:javascript
代码运行次数:0
运行
复制
apt install -y zlib1g-dev

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
checking for CRYPTO_new_ex_data in -lcrypto... no
configure: error: library 'crypto' is required for OpenSSL # 提示,需要库 'crypto' 来支持 OpenSSL

安装libssl-dev包:

代码语言:javascript
代码运行次数:0
运行
复制
apt install -y libssl-dev

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
checking for xmlSaveToBuffer in -lxml2... no
configure: error: library 'xml2' (version >= 2.6.23) is required for XML support # 提示,需要库 'xml2'(版本 >= 2.6.23)以支持 XML

安装libxml2-dev包:

代码语言:javascript
代码运行次数:0
运行
复制
apt install -y libxml2-dev

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
configure: error: header file <systemd/sd-daemon.h> is required for systemd support # 提示,需要头文件 <systemd/sd-daemon.h> 以支持 systemd

安装libsystemd-dev包:

代码语言:javascript
代码运行次数:0
运行
复制
apt install -y libsystemd-dev

继续执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd

执行make:

代码语言:javascript
代码运行次数:0
运行
复制
# 默认 make 不包括文档和其它模块,$(nproc)表示当产主机的CPU核心
make -j $(nproc) world
...
make[2]: Leaving directory '/usr/local/src/postgresql-17.6/src/test/isolation'
make -C test/perl all
make[2]: Entering directory '/usr/local/src/postgresql-17.6/src/test/perl'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/usr/local/src/postgresql-17.6/src/test/perl'
make[1]: Leaving directory '/usr/local/src/postgresql-17.6/src'

执行make install:

代码语言:javascript
代码运行次数:0
运行
复制
# 默认 make install 不包括安装文档
make install-world
...
ERROR: `xmllint' is missing on your system.
***
make[3]: *** [Makefile:72: postgres-full.xml] Error 1
make[3]: Leaving directory '/usr/local/src/postgresql-17.6/doc/src/sgml'
make[2]: *** [Makefile:8: install] Error 2
make[2]: Leaving directory '/usr/local/src/postgresql-17.6/doc/src'
make[1]: *** [Makefile:16: install] Error 2
make[1]: Leaving directory '/usr/local/src/postgresql-17.6/doc'
make: *** [GNUmakefile:32: install-world-doc-recurse] Error 2

从“https://www.postgresql.org/docs/current/docguide-toolsets.html#DOCGUIDE-TOOLSETS-INST-FEDORA-ET-AL”网址看到安装文档需要安装的包:

代码语言:javascript
代码运行次数:0
运行
复制
apt install -y docbook-xml docbook-xsl libxml2-utils xsltproc fop

重新执行configure:

代码语言:javascript
代码运行次数:0
运行
复制
# 再次执行make之前先清理之前的操作
make clean

./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd

重新执行make:

代码语言:javascript
代码运行次数:0
运行
复制
make -j $(nproc) world

重新执行make install:

代码语言:javascript
代码运行次数:0
运行
复制
make install-world
。。。
/usr/bin/mkdir -p '/apps/pgsql/lib'
/usr/bin/mkdir -p '/apps/pgsql/share/extension'
/usr/bin/mkdir -p '/apps/pgsql/share/extension'
/usr/bin/install -c -m 755  pgxml.so '/apps/pgsql/lib/pgxml.so'
/usr/bin/install -c -m 644 ./xml2.control '/apps/pgsql/share/extension/'
/usr/bin/install -c -m 644 ./xml2--1.1.sql ./xml2--1.0--1.1.sql  '/apps/pgsql/share/extension/'
make[2]: Leaving directory '/usr/local/src/postgresql-17.6/contrib/xml2'
make[1]: Leaving directory '/usr/local/src/postgresql-17.6/contrib'

总结编译过程:

代码语言:javascript
代码运行次数:0
运行
复制
# 安装依赖包
apt update
apt install -y make gcc pkg-config libicu-dev bison flex libreadline-dev zlib1g-dev libssl-dev libxml2-dev libsystemd-dev docbook-xml docbook-xsl libxml2-utils xsltproc fop

# 进入PostgreSQL包解压的目录:
cd postgresql-17.6

# 执行configure
./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd

# 执行make
make -j $(nproc) world

# 执行make install
make install-world

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 2.3 源码编译安装PostgreSQL
    • 2.3.1 下载并解压缩源码包
    • 2.3.2 源码编译安装PostgreSQL
      • 2.3.2.1 Rocky 8/9/10、AlmaLinux 8/9/10、CentOS Stream 8/9/10、OpenCloudOS 8
      • 2.3.2.2 CentOS 7
      • 2.3.2.3 openEuler 22.03/24.03 LTS
      • 2.3.2.4 AnolisOS 23
      • 2.3.2.5 AnolisOS 8
      • 2.3.2.6 OpenCloudOS 9、Kylin Server V10
      • 2.3.2.7 UOS Server V20
      • 2.3.2.8 openSUSE 15
      • 2.3.2.9 Ubuntu Server 20.04/22.04/24.04 LTS、Debian 11/12/13
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档