PostgreSQL源码编译安装(一)

举报
Raymond运维 发表于 2025/09/21 14:56:39 2025/09/21
【摘要】 PostgreSQL源码编译安装

2.3 源码编译安装PostgreSQL

2.3.1 下载并解压缩源码包

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

图6 下载PostgreSQL源码包

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

图7 下载PostgreSQL源码包

# 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

编译安装参数解释:

./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 7、CentOS Stream 8/9/10、OpenCloudOS 8

进入PostgreSQL包解压的目录:

cd postgresql-17.6

执行configure:

./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包:

yum install -y gcc

继续执行configure:

./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包:

yum install -y libicu-devel

继续执行configure:

./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
checking for bison... no
configure: error: bison not found # 提示,未找到bison

安装bison包:

yum install -y bison

继续执行configure:

./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
checking for flex... no
configure: error: flex not found # 提示,未找到flex

安装flex包:

yum install -y flex

继续执行configure:

./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
checking for perl... no
configure: error: Perl not found # 提示,未找到Perl

安装perl包:

yum install -y perl

继续执行configure:

./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包:

yum install -y readline-devel

继续执行configure:

./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包:

yum install -y zlib-devel

继续执行configure:

./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包:

yum install -y openssl-devel

继续执行configure:

./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包:

yum install -y libxml2-devel

继续执行configure:

./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包:

yum install -y systemd-devel

继续执行configure:

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

执行make:

# 默认 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:

# 默认 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”网址看到安装文档需要安装的包:

yum install -y docbook-dtds docbook-style-xsl libxslt

重新执行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'

总结编译过程:

# 安装依赖包
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.2 openEuler 22.03/24.03 LTS

进入PostgreSQL包解压的目录:

cd postgresql-17.6

执行configure:

./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包:

yum install -y gcc

继续执行configure:

./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包:

yum install -y libicu-devel

继续执行configure:

./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
checking for bison... no
configure: error: bison not found # 提示,未找到bison

安装bison包:

yum install -y bison

继续执行configure:

./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
checking for flex... no
configure: error: flex not found # 提示,未找到flex

安装flex包:

yum install -y flex

继续执行configure:

./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包:

yum install -y readline-devel

继续执行configure:

./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包:

yum install -y zlib-devel

继续执行configure:

./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包:

yum install -y openssl-devel

继续执行configure:

./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包:

yum install -y libxml2-devel

继续执行configure:

./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包:

yum install -y systemd-devel

继续执行configure:

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

执行make:

# 默认 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:

# 默认 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”网址看到安装文档需要安装的包:

yum install -y docbook-dtds docbook-style-xsl libxslt

重新执行make install:

make install-world
...
ERROR: `xsltproc' is missing on your system.
***
make[3]: *** [Makefile:130: html-stamp] 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

重新执行configure:

# 再次执行make之前先清理之前的操作
make clean

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

执行make:

make -j $(nproc) world

重新执行make install:

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'

总结编译过程:

# 安装依赖包
yum install -y 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.3 AnolisOS 23

进入PostgreSQL包解压的目录:

cd postgresql-17.6

执行configure:

./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包:

yum install -y gcc

继续执行configure:

./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包:

yum install -y libicu-devel

继续执行configure:

./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
checking for bison... no
configure: error: bison not found # 提示,未找到bison

安装bison包:

yum install -y bison

继续执行configure:

./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
checking for flex... no
configure: error: flex not found # 提示,未找到flex

安装flex包:

yum install -y flex

继续执行configure:

./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包:

yum install -y readline-devel

继续执行configure:

./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包:

yum install -y zlib-devel

继续执行configure:

./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包:

yum install -y openssl-devel

继续执行configure:

./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包:

yum install -y libxml2-devel

继续执行configure:

./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包:

yum install -y systemd-devel

继续执行configure:

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

执行make:

# 默认 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包:

yum install -y perl-FindBin perl-core

执行make:

make -j $(nproc) world

执行make install:

# 默认 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”网址看到安装文档需要安装的包:

yum install -y docbook-dtds docbook-style-xsl libxslt

重新执行configure:

# 再次执行make之前先清理之前的操作
make clean

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

执行make:

make -j $(nproc) world

重新执行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'

总结编译过程:

# 安装依赖包
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.4 AnolisOS 8

进入PostgreSQL包解压的目录:

cd postgresql-17.6

执行configure:

./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包:

yum install -y gcc

继续执行configure:

./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包:

yum install -y libicu-devel

继续执行configure:

./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
checking for bison... no
configure: error: bison not found # 提示,未找到bison

安装bison包:

yum install -y bison

继续执行configure:

./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
checking for flex... no
configure: error: flex not found # 提示,未找到flex

安装flex包:

yum install -y flex

继续执行configure:

./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包:

yum install -y readline-devel

继续执行configure:

./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包:

yum install -y zlib-devel

继续执行configure:

./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包:

yum install -y openssl-devel

继续执行configure:

./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包:

yum install -y libxml2-devel

继续执行configure:

./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包:

yum install -y systemd-devel

继续执行configure:

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

执行make:

yum install -y make

# 默认 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:

# 默认 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”网址看到安装文档需要安装的包:

yum install -y docbook-dtds docbook-style-xsl libxslt

重新执行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'

总结编译过程:

# 安装依赖包
yum install -y gcc libicu-devel bison flex readline-devel zlib-devel openssl-devel libxml2-devel systemd-devel make 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 OpenCloudOS 9、Kylin Server V10/V11

进入PostgreSQL包解压的目录:

cd postgresql-17.6

执行configure:

./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包:

yum install -y gcc

继续执行configure:

./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包:

yum install -y libicu-devel

继续执行configure:

./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
checking for bison... no
configure: error: bison not found # 提示,未找到bison

安装bison包:

yum install -y bison

继续执行configure:

./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
checking for flex... no
configure: error: flex not found # 提示,未找到flex

安装flex包:

yum install -y flex

继续执行configure:

./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
...
checking for perl... no
configure: error: Perl not found # 提示,未找到Perl

安装perl包:

yum install -y perl

继续执行configure:

./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包:

yum install -y readline-devel

继续执行configure:

./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包:

yum install -y zlib-devel

继续执行configure:

./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包:

yum install -y openssl-devel

继续执行configure:

./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包:

yum install -y libxml2-devel

继续执行configure:

./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包:

yum install -y systemd-devel

继续执行configure:

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

执行make:

# 默认 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:

# 默认 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”网址看到安装文档需要安装的包:

yum install -y docbook-dtds docbook-style-xsl libxslt

重新执行make install:

make install-world
...
ERROR: `xsltproc' is missing on your system.
***
make[3]: *** [Makefile:130: html-stamp] 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

重新执行configure:

# 再次执行make之前先清理之前的操作
make clean

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

执行make:

make -j $(nproc) world

重新执行make install:

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'

总结编译过程:

# 安装依赖包
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

【声明】本内容来自华为云开发者社区博主,不代表华为云及华为云开发者社区的观点和立场。转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息,否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。