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

PostgreSQL源码编译安装(一)

原创
作者头像
Raymond运维
修改2025-09-24 17:37:11
修改2025-09-24 17:37:11
5210
举报
文章被收录于专栏:干货分享干货分享

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
复制
1# Rocky、Almalinux、CentOS、AnolisOS、OpenCloudOS、Kylin Server默认没有wget包,需要安装
2yum install-ywget
3
4# openEuler 22.03/24.03 LTS、AnolisOS 23、OpenCloudOS 9没有安装tar包,需要安装
5yum install-ytar
6
7cd /usr/local/src
8
9# 下载解压缩
10wget https://ftp.postgresql.org/pub/source/v17.6/postgresql-17.6.tar.gz
11tar xf postgresql-17.6.tar.gz

2.3.2 源码编译安装PostgreSQL

编译安装参数解释:

代码语言:javascript
复制
1./configure # 准备PostgreSQL的编译环境
2--prefix# 指定 PostgreSQL 安装目录
3--with-openssl # 启用 OpenSSL 支持
4--with-libxml # 启用 XML 支持
5--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包解压的目录:

代码语言:javascript
复制
1cd postgresql-17.6

执行configure:

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

安装gcc包:

代码语言:javascript
复制
1yum install-y gcc

继续执行configure:

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

安装libicu-devel包:

代码语言:javascript
复制
1yum install-y libicu-devel

继续执行configure:

代码语言:javascript
复制
1./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
2...
3checking for bison... no
4configure: error: bison not found # 提示,未找到bison

安装bison包:

代码语言:javascript
复制
1yum install-y bison

继续执行configure:

代码语言:javascript
复制
1./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
2...
3checking for flex... no
4configure: error: flex not found # 提示,未找到flex

安装flex包:

代码语言:javascript
复制
1yum install-y flex

继续执行configure:

代码语言:javascript
复制
1./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
2...
3checking for perl... no
4configure: error: Perl not found # 提示,未找到Perl

安装perl包:

代码语言:javascript
复制
1yum install-y perl

继续执行configure:

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

安装readline-devel包:

代码语言:javascript
复制
1yum install-y readline-devel

继续执行configure:

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

安装zlib-devel包:

代码语言:javascript
复制
1yum install-y zlib-devel

继续执行configure:

代码语言:javascript
复制
1./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
2...
3checking forCRYPTO_new_ex_datain -lcrypto... no
4configure: error: library 'crypto' is required for OpenSSL # 提示,需要库 'crypto' 来支持 OpenSSL

安装openssl-devel包:

代码语言:javascript
复制
1yum install-y openssl-devel

继续执行configure:

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

安装libxml2-devel包:

代码语言:javascript
复制
1yum install-y libxml2-devel

继续执行configure:

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

安装systemd-devel包:

代码语言:javascript
复制
1yum install-y systemd-devel

继续执行configure:

代码语言:javascript
复制
1./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd

执行make:

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

执行make install:

代码语言:javascript
复制
1# 默认 make install 不包括安装文档
2make install-world
3...
4make[3]: *** [Makefile:72: postgres-full.xml] Error 1
5make[3]: Leaving directory '/usr/local/src/postgresql-17.6/doc/src/sgml'
6make[2]: *** [Makefile:8: install] Error 2
7make[2]: Leaving directory '/usr/local/src/postgresql-17.6/doc/src'
8make[1]: *** [Makefile:16: install] Error 2
9make[1]: Leaving directory '/usr/local/src/postgresql-17.6/doc'
10make: *** [GNUmakefile:32: install-world-doc-recurse] Error 2
代码语言:javascript
复制
# 从“https://www.postgresql.org/docs/current/docguide-toolsets.html#DOCGUIDE-TOOLSETS-INST-FEDORA-ET-AL”网址看到安装文档需要安装的包:
1yum install-y docbook-dtds docbook-style-xsl libxslt

重新执行make install:

代码语言:javascript
复制
1make install-world
2。。。
3/usr/bin/mkdir -p'/apps/pgsql/lib'
4/usr/bin/mkdir -p'/apps/pgsql/share/extension'
5/usr/bin/mkdir -p'/apps/pgsql/share/extension'
6/usr/bin/install -c-m755  pgxml.so '/apps/pgsql/lib/pgxml.so'
7/usr/bin/install -c-m644 ./xml2.control '/apps/pgsql/share/extension/'
8/usr/bin/install -c-m644 ./xml2--1.1.sql ./xml2--1.0--1.1.sql  '/apps/pgsql/share/extension/'
9make[2]: Leaving directory '/usr/local/src/postgresql-17.6/contrib/xml2'
10make[1]: Leaving directory '/usr/local/src/postgresql-17.6/contrib'

总结编译过程:

代码语言:javascript
复制
1# 安装依赖包
2yum install-y gcc libicu-devel bison flex perl readline-devel zlib-devel openssl-devel libxml2-devel systemd-devel docbook-dtds docbook-style-xsl libxslt
3
4# 进入PostgreSQL包解压的目录:
5cd postgresql-17.6
6
7# 执行configure
8./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
9
10# 执行make
11make-j$(nproc) world
12
13# 执行make install
14make install-world
2.3.2.2 openEuler 22.03/24.03 LTS

进入PostgreSQL包解压的目录:

代码语言:javascript
复制
1cd postgresql-17.6

执行configure:

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

安装gcc包:

代码语言:javascript
复制
1yum install-y gcc

继续执行configure:

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

安装libicu-devel包:

代码语言:javascript
复制
1yum install-y libicu-devel

继续执行configure:

代码语言:javascript
复制
1./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
2...
3checking for bison... no
4configure: error: bison not found # 提示,未找到bison

安装bison包:

代码语言:javascript
复制
1yum install-y bison

继续执行configure:

代码语言:javascript
复制
1./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
2...
3checking for flex... no
4configure: error: flex not found # 提示,未找到flex

安装flex包:

代码语言:javascript
复制
1yum install-y flex

继续执行configure:

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

安装readline-devel包:

代码语言:javascript
复制
1yum install-y readline-devel

继续执行configure:

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

安装zlib-devel包:

代码语言:javascript
复制
1yum install-y zlib-devel

继续执行configure:

代码语言:javascript
复制
1./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
2...
3checking forCRYPTO_new_ex_datain -lcrypto... no
4configure: error: library 'crypto' is required for OpenSSL # 提示,需要库 'crypto' 来支持 OpenSSL

安装openssl-devel包:

代码语言:javascript
复制
1yum install-y openssl-devel

继续执行configure:

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

安装libxml2-devel包:

代码语言:javascript
复制
1yum install-y libxml2-devel

继续执行configure:

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

安装systemd-devel包:

代码语言:javascript
复制
1yum install-y systemd-devel

继续执行configure:

代码语言:javascript
复制
1./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd

执行make:

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

执行make install:

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

代码语言:javascript
复制
# 从“https://www.postgresql.org/docs/current/docguide-toolsets.html#DOCGUIDE-TOOLSETS-INST-FEDORA-ET-AL”网址看到安装文档需要安装的包:
1yum install-y docbook-dtds docbook-style-xsl libxslt

重新执行make install:

代码语言:javascript
复制
1make install-world
2...
3ERROR: `xsltproc' is missing on your system.
4***
5make[3]: *** [Makefile:130: html-stamp] Error 1
6make[3]: Leaving directory '/usr/local/src/postgresql-17.6/doc/src/sgml'
7make[2]: *** [Makefile:8: install] Error 2
8make[2]: Leaving directory '/usr/local/src/postgresql-17.6/doc/src'
9make[1]: *** [Makefile:16: install] Error 2
10make[1]: Leaving directory '/usr/local/src/postgresql-17.6/doc'
11make: *** [GNUmakefile:32: install-world-doc-recurse] Error 2

重新执行configure:

代码语言:javascript
复制
1# 再次执行make之前先清理之前的操作
2make clean
3
4./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd

执行make:

代码语言:javascript
复制
1make-j$(nproc) world

重新执行make install:

代码语言:javascript
复制
1make install-world
2。。。
3make[2]: Leaving directory '/usr/local/src/postgresql-17.6/contrib/sslinfo'
4make-C xml2 install
5make[2]: Entering directory '/usr/local/src/postgresql-17.6/contrib/xml2'
6/usr/bin/mkdir -p'/apps/pgsql/lib'
7/usr/bin/mkdir -p'/apps/pgsql/share/extension'
8/usr/bin/mkdir -p'/apps/pgsql/share/extension'
9/usr/bin/install -c-m755  pgxml.so '/apps/pgsql/lib/pgxml.so'
10/usr/bin/install -c-m644 ./xml2.control '/apps/pgsql/share/extension/'
11/usr/bin/install -c-m644 ./xml2--1.1.sql ./xml2--1.0--1.1.sql  '/apps/pgsql/share/extension/'
12make[2]: Leaving directory '/usr/local/src/postgresql-17.6/contrib/xml2'
13make[1]: Leaving directory '/usr/local/src/postgresql-17.6/contrib'

总结编译过程:

代码语言:javascript
复制
1# 安装依赖包
2yum install-y gcc libicu-devel bison flex readline-devel zlib-devel openssl-devel libxml2-devel systemd-devel docbook-dtds docbook-style-xsl libxslt
3
4# 进入PostgreSQL包解压的目录:
5cd postgresql-17.6
6
7# 执行configure
8./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
9
10# 执行make
11make-j$(nproc) world
12
13# 执行make install
14make install-world
2.3.2.3 AnolisOS 23

进入PostgreSQL包解压的目录:

代码语言:javascript
复制
1cd postgresql-17.6

执行configure:

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

安装gcc包:

代码语言:javascript
复制
1yum install-y gcc

继续执行configure:

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

安装libicu-devel包:

代码语言:javascript
复制
1yum install-y libicu-devel

继续执行configure:

代码语言:javascript
复制
1./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
2...
3checking for bison... no
4configure: error: bison not found # 提示,未找到bison

安装bison包:

代码语言:javascript
复制
1yum install-y bison

继续执行configure:

代码语言:javascript
复制
1./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
2...
3checking for flex... no
4configure: error: flex not found # 提示,未找到flex

安装flex包:

代码语言:javascript
复制
1yum install-y flex

继续执行configure:

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

安装readline-devel包:

代码语言:javascript
复制
1yum install-y readline-devel

继续执行configure:

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

安装zlib-devel包:

代码语言:javascript
复制
1yum install-y zlib-devel

继续执行configure:

代码语言:javascript
复制
1./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
2...
3checking forCRYPTO_new_ex_datain -lcrypto... no
4configure: error: library 'crypto' is required for OpenSSL # 提示,需要库 'crypto' 来支持 OpenSSL

安装openssl-devel包:

代码语言:javascript
复制
1yum install-y openssl-devel

继续执行configure:

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

安装libxml2-devel包:

代码语言:javascript
复制
1yum install-y libxml2-devel

继续执行configure:

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

安装systemd-devel包:

代码语言:javascript
复制
1yum install-y systemd-devel

继续执行configure:

代码语言:javascript
复制
1./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd

执行make:

代码语言:javascript
复制
1# 默认 make 不包括文档和其它模块,$(nproc)表示当产主机的CPU核心
2make-j$(nproc) world
3...
4Can'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模块
5BEGIN failed--compilation aborted at gen_node_support.pl line 24.
6Can'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.
7BEGIN failed--compilation aborted at ../../../src/backend/catalog/genbki.pl line 20.
8make[2]: *** [Makefile:141: bki-stamp] Error 2
9make[2]: Leaving directory '/usr/local/src/postgresql-17.6/src/include/catalog'
10make[1]: *** [Makefile:121: submake-catalog-headers] Error 2
11make[1]: *** Waiting for unfinished jobs....
12make[2]: *** [Makefile:78: node-support-stamp] Error 2
13make[2]: Leaving directory '/usr/local/src/postgresql-17.6/src/backend/nodes'
14make[1]: *** [Makefile:125: submake-nodes-headers] Error 2
15make[1]: Leaving directory '/usr/local/src/postgresql-17.6/src/backend'
16make: *** [src/Makefile.global:384: submake-generated-headers] Error 2

安装perl-FindBin和perl-core包:

代码语言:javascript
复制
1yum install-y perl-FindBin perl-core

执行make:

代码语言:javascript
复制
1make-j$(nproc) world

执行make install:

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

代码语言:javascript
复制
# 从“https://www.postgresql.org/docs/current/docguide-toolsets.html#DOCGUIDE-TOOLSETS-INST-FEDORA-ET-AL”网址看到安装文档需要安装的包:
1yum install-y docbook-dtds docbook-style-xsl libxslt

重新执行configure:

代码语言:javascript
复制
1# 再次执行make之前先清理之前的操作
2make clean
3
4./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd

执行make:

代码语言:javascript
复制
1make-j$(nproc) world

重新执行make install:

代码语言:javascript
复制
1make install-world
2。。。
3/usr/bin/mkdir -p'/apps/pgsql/lib'
4/usr/bin/mkdir -p'/apps/pgsql/share/extension'
5/usr/bin/mkdir -p'/apps/pgsql/share/extension'
6/usr/bin/install -c-m755  pgxml.so '/apps/pgsql/lib/pgxml.so'
7/usr/bin/install -c-m644 ./xml2.control '/apps/pgsql/share/extension/'
8/usr/bin/install -c-m644 ./xml2--1.1.sql ./xml2--1.0--1.1.sql  '/apps/pgsql/share/extension/'
9make[2]: Leaving directory '/usr/local/src/postgresql-17.6/contrib/xml2'
10make[1]: Leaving directory '/usr/local/src/postgresql-17.6/contrib'

总结编译过程:

代码语言:javascript
复制
1# 安装依赖包
2yum 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
3
4# 进入PostgreSQL包解压的目录:
5cd postgresql-17.6
6
7# 执行configure
8./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
9
10# 执行make
11make-j$(nproc) world
12
13# 执行make install
14make install-world
2.3.2.4 AnolisOS 8

进入PostgreSQL包解压的目录:

代码语言:javascript
复制
1cd postgresql-17.6

执行configure:

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

安装gcc包:

代码语言:javascript
复制
1yum install-y gcc

继续执行configure:

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

安装libicu-devel包:

代码语言:javascript
复制
1yum install-y libicu-devel

继续执行configure:

代码语言:javascript
复制
1./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
2...
3checking for bison... no
4configure: error: bison not found # 提示,未找到bison

安装bison包:

代码语言:javascript
复制
1yum install-y bison

继续执行configure:

代码语言:javascript
复制
1./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
2...
3checking for flex... no
4configure: error: flex not found # 提示,未找到flex

安装flex包:

代码语言:javascript
复制
1yum install-y flex

继续执行configure:

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

安装readline-devel包:

代码语言:javascript
复制
1yum install-y readline-devel

继续执行configure:

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

安装zlib-devel包:

代码语言:javascript
复制
1yum install-y zlib-devel

继续执行configure:

代码语言:javascript
复制
1./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
2...
3checking forCRYPTO_new_ex_datain -lcrypto... no
4configure: error: library 'crypto' is required for OpenSSL # 提示,需要库 'crypto' 来支持 OpenSSL

安装openssl-devel包:

代码语言:javascript
复制
1yum install-y openssl-devel

继续执行configure:

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

安装libxml2-devel包:

代码语言:javascript
复制
1yum install-y libxml2-devel

继续执行configure:

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

安装systemd-devel包:

代码语言:javascript
复制
1yum install-y systemd-devel

继续执行configure:

代码语言:javascript
复制
1./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd

执行make:

代码语言:javascript
复制
1yum install-ymake
2
3# 默认 make 不包括文档和其它模块,$(nproc)表示当产主机的CPU核心
4make-j$(nproc) world
5...
6make[2]: Leaving directory '/usr/local/src/postgresql-17.6/src/test/isolation'
7make-C test/perl all
8make[2]: Entering directory '/usr/local/src/postgresql-17.6/src/test/perl'
9make[2]: Nothing to be donefor'all'.
10make[2]: Leaving directory '/usr/local/src/postgresql-17.6/src/test/perl'
11make[1]: Leaving directory '/usr/local/src/postgresql-17.6/src'

执行make install:

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

代码语言:javascript
复制
# 从“https://www.postgresql.org/docs/current/docguide-toolsets.html#DOCGUIDE-TOOLSETS-INST-FEDORA-ET-AL”网址看到安装文档需要安装的包:
1yum install-y docbook-dtds docbook-style-xsl libxslt

重新执行make install:

代码语言:javascript
复制
1make install-world
2。。。
3/usr/bin/mkdir -p'/apps/pgsql/lib'
4/usr/bin/mkdir -p'/apps/pgsql/share/extension'
5/usr/bin/mkdir -p'/apps/pgsql/share/extension'
6/usr/bin/install -c-m755  pgxml.so '/apps/pgsql/lib/pgxml.so'
7/usr/bin/install -c-m644 ./xml2.control '/apps/pgsql/share/extension/'
8/usr/bin/install -c-m644 ./xml2--1.1.sql ./xml2--1.0--1.1.sql  '/apps/pgsql/share/extension/'
9make[2]: Leaving directory '/usr/local/src/postgresql-17.6/contrib/xml2'
10make[1]: Leaving directory '/usr/local/src/postgresql-17.6/contrib'

总结编译过程:

代码语言:javascript
复制
1# 安装依赖包
2yum install-y gcc libicu-devel bison flex readline-devel zlib-devel openssl-devel libxml2-devel systemd-devel make docbook-dtds docbook-style-xsl libxslt
3
4# 进入PostgreSQL包解压的目录:
5cd postgresql-17.6
6
7# 执行configure
8./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
9
10# 执行make
11make-j$(nproc) world
12
13# 执行make install
14make install-world
2.3.2.5 OpenCloudOS 9、Kylin Server V10/V11

进入PostgreSQL包解压的目录:

代码语言:javascript
复制
1cd postgresql-17.6

执行configure:

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

安装gcc包:

代码语言:javascript
复制
1yum install-y gcc

继续执行configure:

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

安装libicu-devel包:

代码语言:javascript
复制
1yum install-y libicu-devel

继续执行configure:

代码语言:javascript
复制
1./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
2...
3checking for bison... no
4configure: error: bison not found # 提示,未找到bison

安装bison包:

代码语言:javascript
复制
1yum install-y bison

继续执行configure:

代码语言:javascript
复制
1./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
2...
3checking for flex... no
4configure: error: flex not found # 提示,未找到flex

安装flex包:

代码语言:javascript
复制
1yum install-y flex

继续执行configure:

代码语言:javascript
复制
1./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
2...
3checking for perl... no
4configure: error: Perl not found # 提示,未找到Perl

安装perl包:

代码语言:javascript
复制
1yum install-y perl

继续执行configure:

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

安装readline-devel包:

代码语言:javascript
复制
1yum install-y readline-devel

继续执行configure:

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

安装zlib-devel包:

代码语言:javascript
复制
1yum install-y zlib-devel

继续执行configure:

代码语言:javascript
复制
1./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
2...
3checking forCRYPTO_new_ex_datain -lcrypto... no
4configure: error: library 'crypto' is required for OpenSSL # 提示,需要库 'crypto' 来支持 OpenSSL

安装openssl-devel包:

代码语言:javascript
复制
1yum install-y openssl-devel

继续执行configure:

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

安装libxml2-devel包:

代码语言:javascript
复制
1yum install-y libxml2-devel

继续执行configure:

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

安装systemd-devel包:

代码语言:javascript
复制
1yum install-y systemd-devel

继续执行configure:

代码语言:javascript
复制
1./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd

执行make:

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

执行make install:

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

代码语言:javascript
复制
# 从“https://www.postgresql.org/docs/current/docguide-toolsets.html#DOCGUIDE-TOOLSETS-INST-FEDORA-ET-AL”网址看到安装文档需要安装的包:
1yum install-y docbook-dtds docbook-style-xsl libxslt

重新执行make install:

代码语言:javascript
复制
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:

代码语言:javascript
复制
1# 再次执行make之前先清理之前的操作
2make clean
3
4./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd

执行make:

代码语言:javascript
复制
1make-j$(nproc) world

重新执行make install:

代码语言:javascript
复制
1make install-world
2。。。
3make[2]: Leaving directory '/usr/local/src/postgresql-17.6/contrib/sslinfo'
4make-C xml2 install
5make[2]: Entering directory '/usr/local/src/postgresql-17.6/contrib/xml2'
6/usr/bin/mkdir -p'/apps/pgsql/lib'
7/usr/bin/mkdir -p'/apps/pgsql/share/extension'
8/usr/bin/mkdir -p'/apps/pgsql/share/extension'
9/usr/bin/install -c-m755  pgxml.so '/apps/pgsql/lib/pgxml.so'
10/usr/bin/install -c-m644 ./xml2.control '/apps/pgsql/share/extension/'
11/usr/bin/install -c-m644 ./xml2--1.1.sql ./xml2--1.0--1.1.sql  '/apps/pgsql/share/extension/'
12make[2]: Leaving directory '/usr/local/src/postgresql-17.6/contrib/xml2'
13make[1]: Leaving directory '/usr/local/src/postgresql-17.6/contrib'

总结编译过程:

代码语言:javascript
复制
1# 安装依赖包
2yum install-y gcc libicu-devel bison flex perl readline-devel zlib-devel openssl-devel libxml2-devel systemd-devel docbook-dtds docbook-style-xsl libxslt
3
4# 进入PostgreSQL包解压的目录:
5cd postgresql-17.6
6
7# 执行configure
8./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
9
10# 执行make
11make-j$(nproc) world
12
13# 执行make install
14make install-world
2.3.2.6 UOS Server V20

进入PostgreSQL包解压的目录:

代码语言:javascript
复制
1cd postgresql-17.6

执行configure:

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

安装libicu-devel包:

代码语言:javascript
复制
1yum install-y libicu-devel

继续执行configure:

代码语言:javascript
复制
1./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
2...
3checking for bison... no
4configure: error: bison not found # 提示,未找到bison

安装bison包:

代码语言:javascript
复制
1yum install-y bison

继续执行configure:

代码语言:javascript
复制
1./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
2...
3checking for flex... no
4configure: error: flex not found # 提示,未找到flex

安装flex包:

代码语言:javascript
复制
1yum install-y flex

继续执行configure:

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

安装readline-devel包:

代码语言:javascript
复制
1yum install-y readline-devel

继续执行configure:

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

安装systemd-devel包:

代码语言:javascript
复制
1yum install-y systemd-devel

继续执行configure:

代码语言:javascript
复制
1./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd

执行make:

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

执行make install:

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

代码语言:javascript
复制
# 从“https://www.postgresql.org/docs/current/docguide-toolsets.html#DOCGUIDE-TOOLSETS-INST-FEDORA-ET-AL”网址看到安装文档需要安装的包:
1yum install-y docbook-dtds docbook-style-xsl libxslt

重新执行make install:

代码语言:javascript
复制
1make install-world
2。。。
3/usr/bin/mkdir -p'/apps/pgsql/lib'
4/usr/bin/mkdir -p'/apps/pgsql/share/extension'
5/usr/bin/mkdir -p'/apps/pgsql/share/extension'
6/usr/bin/install -c-m755  pgxml.so '/apps/pgsql/lib/pgxml.so'
7/usr/bin/install -c-m644 ./xml2.control '/apps/pgsql/share/extension/'
8/usr/bin/install -c-m644 ./xml2--1.1.sql ./xml2--1.0--1.1.sql  '/apps/pgsql/share/extension/'
9make[2]: Leaving directory '/usr/local/src/postgresql-17.6/contrib/xml2'
10make[1]: Leaving directory '/usr/local/src/postgresql-17.6/contrib'

总结编译过程:

代码语言:javascript
复制
1# 安装依赖包
2yum install-y libicu-devel bison flex perl readline-devel systemd-devel docbook-dtds docbook-style-xsl libxslt
3
4# 进入PostgreSQL包解压的目录:
5cd postgresql-17.6
6
7# 执行configure
8./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
9
10# 执行make
11make-j$(nproc) world
12
13# 执行make install
14make install-world
2.3.2.7 openSUSE 15

进入PostgreSQL包解压的目录:

代码语言:javascript
复制
1cd postgresql-17.6

执行configure:

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

安装gcc包:

代码语言:javascript
复制
1zypperinstall-y gcc

继续执行configure:

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

安装libicu-devel包:

代码语言:javascript
复制
1zypperinstall-y libicu-devel

继续执行configure:

代码语言:javascript
复制
1./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
2...
3checking for bison... no
4configure: error: bison not found # 提示,未找到bison

安装bison包:

代码语言:javascript
复制
1zypperinstall-y bison

继续执行configure:

代码语言:javascript
复制
1./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
2...
3checking for flex... no
4configure: error: flex not found # 提示,未找到flex

安装flex包:

代码语言:javascript
复制
1zypperinstall-y flex

继续执行configure:

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

安装readline-devel包:

代码语言:javascript
复制
1zypperinstall-y readline-devel

继续执行configure:

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

安装zlib-devel包:

代码语言:javascript
复制
1zypperinstall-y zlib-devel

继续执行configure:

代码语言:javascript
复制
1./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
2...
3checking forCRYPTO_new_ex_datain -lcrypto... no
4configure: error: library 'crypto' is required for OpenSSL # 提示,需要库 'crypto' 来支持 OpenSSL

安装openssl-devel包:

代码语言:javascript
复制
1zypperinstall-y openssl-devel

继续执行configure:

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

安装libxml2-devel包:

代码语言:javascript
复制
1zypperinstall-y libxml2-devel

继续执行configure:

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

安装systemd-devel包:

代码语言:javascript
复制
1zypperinstall-y systemd-devel

继续执行configure:

代码语言:javascript
复制
1./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd

执行make:

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

代码语言:javascript
复制
# 从“https://www.postgresql.org/docs/current/docguide-toolsets.html#DOCGUIDE-TOOLSETS-INST-FEDORA-ET-AL”网址看到安装文档需要安装的包:
1zypperinstall-y docbook-xsl-stylesheets

重新执行configure:

代码语言:javascript
复制
1# 再次执行make之前先清理之前的操作
2make clean
3
4./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd

重新执行make:

代码语言:javascript
复制
1make-j$(nproc) world

执行make install:

代码语言:javascript
复制
1# 默认 make install 不包括安装文档
2make install-world
3。。。
4/usr/bin/mkdir -p'/apps/pgsql/lib'
5/usr/bin/mkdir -p'/apps/pgsql/share/extension'
6/usr/bin/mkdir -p'/apps/pgsql/share/extension'
7/usr/bin/install -c-m755  pgxml.so '/apps/pgsql/lib/pgxml.so'
8/usr/bin/install -c-m644 ./xml2.control '/apps/pgsql/share/extension/'
9/usr/bin/install -c-m644 ./xml2--1.1.sql ./xml2--1.0--1.1.sql  '/apps/pgsql/share/extension/'
10make[2]: Leaving directory '/usr/local/src/postgresql-17.6/contrib/xml2'
11make[1]: Leaving directory '/usr/local/src/postgresql-17.6/contrib'

总结编译过程:

代码语言:javascript
复制
1# 安装依赖包
2zypperinstall-y gcc libicu-devel bison flex readline-devel zlib-devel openssl-devel libxml2-devel systemd-devel make docbook-xsl-stylesheets
3
4# 进入PostgreSQL包解压的目录:
5cd postgresql-17.6
6
7# 执行configure
8./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
9
10# 执行make
11make-j$(nproc) world
12
13# 执行make install
14make install-world
2.3.2.8 Ubuntu Server 20.04/22.04/24.04 LTS、Debian 11/12/13

进入PostgreSQL包解压的目录:

代码语言:javascript
复制
1cd postgresql-17.6

执行configure:

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

安装gcc包:

代码语言:javascript
复制
1aptinstall-y gcc

继续执行configure:

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

安装pkg-config和libicu-dev包:

代码语言:javascript
复制
1aptinstall-y pkg-config libicu-dev

继续执行configure:

代码语言:javascript
复制
1./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
2...
3checking for bison... no
4configure: error: bison not found # 提示,未找到bison

安装bison包:

代码语言:javascript
复制
1aptinstall-y bison

继续执行configure:

代码语言:javascript
复制
1./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
2...
3checking for flex... no
4configure: error: flex not found # 提示,未找到flex

安装flex包:

代码语言:javascript
复制
1aptinstall-y flex

继续执行configure:

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

安装libreadline-dev包:

代码语言:javascript
复制
1aptinstall-y libreadline-dev

继续执行configure:

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

安装zlib1g-dev包:

代码语言:javascript
复制
1aptinstall-y zlib1g-dev

继续执行configure:

代码语言:javascript
复制
1./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
2...
3checking forCRYPTO_new_ex_datain -lcrypto... no
4configure: error: library 'crypto' is required for OpenSSL # 提示,需要库 'crypto' 来支持 OpenSSL

安装libssl-dev包:

代码语言:javascript
复制
1aptinstall-y libssl-dev

继续执行configure:

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

安装libxml2-dev包:

代码语言:javascript
复制
1aptinstall-y libxml2-dev

继续执行configure:

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

安装libsystemd-dev包:

代码语言:javascript
复制
1aptinstall-y libsystemd-dev

继续执行configure:

代码语言:javascript
复制
1./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd

执行make:

代码语言:javascript
复制
1aptinstall-ymake
2
3# 默认 make 不包括文档和其它模块,$(nproc)表示当产主机的CPU核心
4make-j$(nproc) world
5...
6make[2]: Leaving directory '/usr/local/src/postgresql-17.6/src/test/isolation'
7make-C test/perl all
8make[2]: Entering directory '/usr/local/src/postgresql-17.6/src/test/perl'
9make[2]: Nothing to be donefor'all'.
10make[2]: Leaving directory '/usr/local/src/postgresql-17.6/src/test/perl'
11make[1]: Leaving directory '/usr/local/src/postgresql-17.6/src'

执行make install:

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

代码语言:javascript
复制
# 从“https://www.postgresql.org/docs/current/docguide-toolsets.html#DOCGUIDE-TOOLSETS-INST-FEDORA-ET-AL”网址看到安装文档需要安装的包
1aptinstall-y docbook-xml docbook-xsl libxml2-utils xsltproc fop

重新执行make install:

代码语言:javascript
复制
1make install-world
2...
3ERROR: `xmllint' is missing on your system.
4***
5make[3]: *** [Makefile:72: postgres-full.xml] Error 1
6make[3]: Leaving directory '/usr/local/src/postgresql-17.6/doc/src/sgml'
7make[2]: *** [Makefile:8: install] Error 2
8make[2]: Leaving directory '/usr/local/src/postgresql-17.6/doc/src'
9make[1]: *** [Makefile:16: install] Error 2
10make[1]: Leaving directory '/usr/local/src/postgresql-17.6/doc'
11make: *** [GNUmakefile:32: install-world-doc-recurse] Error 2

重新执行configure:

代码语言:javascript
复制
1# 再次执行make之前先清理之前的操作
2make clean
3
4./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd

重新执行make:

代码语言:javascript
复制
1make-j$(nproc) world

重新执行make install:

代码语言:javascript
复制
1make install-world
2。。。
3/usr/bin/mkdir -p'/apps/pgsql/lib'
4/usr/bin/mkdir -p'/apps/pgsql/share/extension'
5/usr/bin/mkdir -p'/apps/pgsql/share/extension'
6/usr/bin/install -c-m755  pgxml.so '/apps/pgsql/lib/pgxml.so'
7/usr/bin/install -c-m644 ./xml2.control '/apps/pgsql/share/extension/'
8/usr/bin/install -c-m644 ./xml2--1.1.sql ./xml2--1.0--1.1.sql  '/apps/pgsql/share/extension/'
9make[2]: Leaving directory '/usr/local/src/postgresql-17.6/contrib/xml2'
10make[1]: Leaving directory '/usr/local/src/postgresql-17.6/contrib'

总结编译过程:

代码语言:javascript
复制
1# 安装依赖包
2apt update
3aptinstall-y gcc pkg-config libicu-dev bison flex libreadline-dev zlib1g-dev libssl-dev libxml2-dev libsystemd-dev make docbook-xml docbook-xsl libxml2-utils xsltproc fop
4
5# 进入PostgreSQL包解压的目录:
6cd postgresql-17.6
7
8# 执行configure
9./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
10
11# 执行make
12make-j$(nproc) world
13
14# 执行make install
15make install-world
2.3.2.9 Ubuntu Server 18.04 LTS

进入PostgreSQL包解压的目录:

代码语言:javascript
复制
1cd postgresql-17.6

执行configure:

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

安装gcc包:

代码语言:javascript
复制
1aptinstall-y gcc

继续执行configure:

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

安装pkg-config和libicu-dev包:

代码语言:javascript
复制
1aptinstall-y pkg-config libicu-dev

继续执行configure:

代码语言:javascript
复制
1./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
2...
3checking for bison... no
4configure: error: bison not found # 提示,未找到bison

安装bison包:

代码语言:javascript
复制
1aptinstall-y bison

继续执行configure:

代码语言:javascript
复制
1./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
2...
3checking for flex... no
4configure: error: flex not found # 提示,未找到flex

安装flex包:

代码语言:javascript
复制
1aptinstall-y flex

继续执行configure:

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

安装libreadline-dev包:

代码语言:javascript
复制
1aptinstall-y libreadline-dev

继续执行configure:

代码语言:javascript
复制
1./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
2...
3checking forCRYPTO_new_ex_datain -lcrypto... no
4configure: error: library 'crypto' is required for OpenSSL # 提示,需要库 'crypto' 来支持 OpenSSL

安装libssl-dev包:

代码语言:javascript
复制
1aptinstall-y libssl-dev

继续执行configure:

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

安装libxml2-dev包:

代码语言:javascript
复制
1aptinstall-y libxml2-dev

继续执行configure:

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

安装libsystemd-dev包:

代码语言:javascript
复制
1aptinstall-y libsystemd-dev

继续执行configure:

代码语言:javascript
复制
1./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd

执行make:

代码语言:javascript
复制
1aptinstall-ymake
2
3# 默认 make 不包括文档和其它模块,$(nproc)表示当产主机的CPU核心
4make-j$(nproc) world
5...
6make[2]: Leaving directory '/usr/local/src/postgresql-17.6/src/test/isolation'
7make-C test/perl all
8make[2]: Entering directory '/usr/local/src/postgresql-17.6/src/test/perl'
9make[2]: Nothing to be donefor'all'.
10make[2]: Leaving directory '/usr/local/src/postgresql-17.6/src/test/perl'
11make[1]: Leaving directory '/usr/local/src/postgresql-17.6/src'

执行make install:

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

代码语言:javascript
复制
# 从“https://www.postgresql.org/docs/current/docguide-toolsets.html#DOCGUIDE-TOOLSETS-INST-FEDORA-ET-AL”网址看到安装文档需要安装的包:
1aptinstall-y docbook-xml docbook-xsl libxml2-utils xsltproc fop

重新执行configure:

代码语言:javascript
复制
1# 再次执行make之前先清理之前的操作
2make clean
3
4./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd

重新执行make:

代码语言:javascript
复制
1make-j$(nproc) world

重新执行make install:

代码语言:javascript
复制
1make install-world
2。。。
3/usr/bin/mkdir -p'/apps/pgsql/lib'
4/usr/bin/mkdir -p'/apps/pgsql/share/extension'
5/usr/bin/mkdir -p'/apps/pgsql/share/extension'
6/usr/bin/install -c-m755  pgxml.so '/apps/pgsql/lib/pgxml.so'
7/usr/bin/install -c-m644 ./xml2.control '/apps/pgsql/share/extension/'
8/usr/bin/install -c-m644 ./xml2--1.1.sql ./xml2--1.0--1.1.sql  '/apps/pgsql/share/extension/'
9make[2]: Leaving directory '/usr/local/src/postgresql-17.6/contrib/xml2'
10make[1]: Leaving directory '/usr/local/src/postgresql-17.6/contrib'

总结编译过程:

代码语言:javascript
复制
1# 安装依赖包
2apt update
3aptinstall-y gcc pkg-config libicu-dev bison flex libreadline-dev libssl-dev libxml2-dev libsystemd-dev make docbook-xml docbook-xsl libxml2-utils xsltproc fop
4
5# 进入PostgreSQL包解压的目录:
6cd postgresql-17.6
7
8# 执行configure
9./configure --prefix=/apps/pgsql --with-openssl --with-libxml --with-systemd
10
11# 执行make
12make-j$(nproc) world
13
14# 执行make install
15make 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 7、CentOS Stream 8/9/10、OpenCloudOS 8
      • 2.3.2.2 openEuler 22.03/24.03 LTS
      • 2.3.2.3 AnolisOS 23
      • 2.3.2.4 AnolisOS 8
      • 2.3.2.5 OpenCloudOS 9、Kylin Server V10/V11
      • 2.3.2.6 UOS Server V20
      • 2.3.2.7 openSUSE 15
      • 2.3.2.8 Ubuntu Server 20.04/22.04/24.04 LTS、Debian 11/12/13
      • 2.3.2.9 Ubuntu Server 18.04 LTS
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档