暂无图片
源码安装PG16
我来答
分享
Thomas
2024-04-15
源码安装PG16

OS是ORACLE LINUX 9,下载源码并解压,先运行./configure, 提示如下:

[root@localhost postgresql-16.2]# ./configure
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking which template to use... linux
checking whether NLS is wanted... no
checking for default port number... 5432
checking for block size... 8kB
checking for segment size... 1GB
checking for WAL block size... 8kB
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for gcc option to accept ISO C99... none needed
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking for gawk... gawk
checking whether gcc supports -Wdeclaration-after-statement, for CFLAGS... yes
checking whether gcc supports -Werror=vla, for CFLAGS... yes
checking whether gcc supports -Werror=unguarded-availability-new, for CFLAGS... no
checking whether g++ supports -Werror=unguarded-availability-new, for CXXFLAGS... no
checking whether gcc supports -Wendif-labels, for CFLAGS... yes
checking whether g++ supports -Wendif-labels, for CXXFLAGS... yes
checking whether gcc supports -Wmissing-format-attribute, for CFLAGS... yes
checking whether g++ supports -Wmissing-format-attribute, for CXXFLAGS... yes
checking whether gcc supports -Wimplicit-fallthrough=3, for CFLAGS... yes
checking whether g++ supports -Wimplicit-fallthrough=3, for CXXFLAGS... yes
checking whether gcc supports -Wcast-function-type, for CFLAGS... yes
checking whether g++ supports -Wcast-function-type, for CXXFLAGS... yes
checking whether gcc supports -Wshadow=compatible-local, for CFLAGS... yes
checking whether g++ supports -Wshadow=compatible-local, for CXXFLAGS... yes
checking whether gcc supports -Wformat-security, for CFLAGS... yes
checking whether g++ supports -Wformat-security, for CXXFLAGS... yes
checking whether gcc supports -fno-strict-aliasing, for CFLAGS... yes
checking whether g++ supports -fno-strict-aliasing, for CXXFLAGS... yes
checking whether gcc supports -fwrapv, for CFLAGS... yes
checking whether g++ supports -fwrapv, for CXXFLAGS... yes
checking whether gcc supports -fexcess-precision=standard, for CFLAGS... yes
checking whether g++ supports -fexcess-precision=standard, for CXXFLAGS... no
checking whether gcc supports -funroll-loops, for CFLAGS_UNROLL_LOOPS... yes
checking whether gcc supports -ftree-vectorize, for CFLAGS_VECTORIZE... yes
checking whether gcc supports -Wunused-command-line-argument, for NOT_THE_CFLAGS... no
checking whether gcc supports -Wcompound-token-split-by-macro, for NOT_THE_CFLAGS... no
checking whether gcc supports -Wformat-truncation, for NOT_THE_CFLAGS... yes
checking whether gcc supports -Wstringop-truncation, for NOT_THE_CFLAGS... yes
checking whether gcc supports -Wcast-function-type-strict, for NOT_THE_CFLAGS... no
checking whether gcc supports -fvisibility=hidden, for CFLAGS_SL_MODULE... yes
checking whether g++ supports -fvisibility=hidden, for CXXFLAGS_SL_MODULE... yes
checking whether g++ supports -fvisibility-inlines-hidden, for CXXFLAGS_SL_MODULE... yes
checking whether the C compiler still works... yes
checking how to run the C preprocessor... gcc -E
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking allow thread-safe client libraries... yes
checking whether to build with ICU support... yes
checking for icu-uc icu-i18n... no
configure: error: ICU library not found
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.

感觉可以继续吧。于是运行make, 报错如下:

[root@localhost postgresql-16.2]# make
You need to run the 'configure' program first. See the file
'INSTALL' for installation instructions, or visit:
<https://www.postgresql.org/docs/devel/installation.html>
make: *** [Makefile:19: all] Error 1

打开Makefile看,头几句如下:

  @if [ ! -f GNUmakefile ] ; then \
if [ -f INSTALL ] ; then \
INSTRUCTIONS="INSTALL"; \
else \
INSTRUCTIONS="README.git"; \
fi; \
echo "You need to run the 'configure' program first. See the file"; \
echo "'$$INSTRUCTIONS' for installation instructions, or visit: " ; \
echo "<https://www.postgresql.org/docs/devel/installation.html>" ; \
false ; \

似乎再判断时,走到了echo "You need to run the 'configure' program first. See the file"; \  判断的意思时是否有Makefile吧?不是有吗,怎会走到这一步?求PG高手解答

我来答
添加附件
收藏
分享
问题补充
7条回答
默认
最新
小满未满、

要是不想折腾的话 不用这个功能 编译configure时 就加上这个–without-icu 忽略掉这个

./configure --without-icu 

要是需要ICU功能(一般是用来排序)的话 就查查看怎么在你现有的操作系统环境下安装这个libicu 就先把icu依赖先装好
比如说centos系统

yum install libicu-devel

然后跑configure 等configure编译过了之后 再跑

 make && make install 
暂无图片 评论
暂无图片 有用 1
暂无图片
subverter

./configure--prefix=自定义路径 --with-pgport=自定义端口,然后使用  install 或者 make install-world 进行安装 $ make install-world

暂无图片 评论
暂无图片 有用 0
Thomas

./configure--prefix=/postgres

执行正常,之后运行以下两命令均报错

[root@localhost postgresql-16.2]# make install-world
You need to run the 'configure' program first. See the file
'INSTALL' for installation instructions, or visit:
<https://www.postgresql.org/docs/devel/installation.html>
make: *** [Makefile:19: install-world] Error 1
[root@localhost postgresql-16.2]# make install
You need to run the 'configure' program first. See the file
'INSTALL' for installation instructions, or visit:
<https://www.postgresql.org/docs/devel/installation.html>
make: *** [Makefile:19: install] Error 1

暂无图片 评论
暂无图片 有用 0
subverter
2024-04-15
从上面你运行configure的日志看,缺少ICU的包,然后在重新configure,直到一点错误也没有才可以编译。
Thomas

缺ICU包和后面的make报错无关吧?

暂无图片 评论
暂无图片 有用 0
小满未满、
2024-04-15
configure没成功编译的话 执行后面的make没有意义
Thomas

谢谢两位答主,现在configure不报错了。但是make时,有如下错误:

gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type -Wshadow=compatible-local -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -Wno-stringop-truncation -O2 clusterdb.o common.o -L../../../src/port -L../../../src/common -L../../../src/fe_utils -lpgfeutils -L../../../src/common -lpgcommon -L../../../src/port -lpgport -L../../../src/interfaces/libpq -lpq -Wl,--as-needed -Wl,-rpath,'/pg/lib',--enable-new-dtags -lpgcommon -lpgport -lz -lreadline -lm -o clusterdb

不知如何解决

暂无图片 评论
暂无图片 有用 0
小满未满、
2024-04-16
错误信息有吗 贴的这块好像没看见
小满未满、
2024-04-16
贴的这个不是错误 这个就是一个gcc完整的编译命令
Thomas

现在好歹算是装上了,也init db了。启动成功,但再主机上无法psql

[postgres@localhost data]$ pg_ctl -D /pg/data -l logfile start
waiting for server to start.... stopped waiting
pg_ctl: could not start server
Examine the log output.
[postgres@localhost data]$ psql
psql: error: connection to server on socket "/pg/data/.s.PGSQL.5432" failed: No such file or directory
Is the server running locally and accepting connections on that socket?

暂无图片 评论
暂无图片 有用 0
nick_liu
2024-04-19
检查下/pg/data/ 的权限吧
小满未满、

启动失败了

pg_ctl: could not start server
暂无图片 评论
暂无图片 有用 0
回答交流
提交
问题信息
请登录之后查看
邀请回答
暂无人订阅该标签,敬请期待~~
暂无图片墨值悬赏