首页 > 解决方案 > 在 ubuntu 18 上使用 postgres 12 安装 pg_partman 和 pg_squeeze 时出错

问题描述

我有一个专用的数据库服务器(ubuntu 18),它安装了 postgres 10,11 和 12。我目前正在使用 postgres 12。我正在尝试在 postgres 12 上安装 pg_partman 和 pg_squeeze 扩展。

我已经在 /etc/pg_parman 中下载了 git repo。当我运行命令时"sudo make",出现以下错误。

gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -g -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -fno-omit-frame-pointer -fPIC -I. -I./ -I/usr/include/postgresql/12/server -I/usr/include/postgresql/internal  -Wdate-time -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -I/usr/include/libxml2  -I/usr/include/mit-krb5  -c -o src/pg_partman_bgw.o src/pg_partman_bgw.c
src/pg_partman_bgw.c:10:10: fatal error: postgres.h: No such file or directory
 #include "postgres.h"
          ^~~~~~~~~~~~
compilation terminated.
<builtin>: recipe for target 'src/pg_partman_bgw.o' failed
make: *** [src/pg_partman_bgw.o] Error 1

经过一番搜索,我发现这postgresql-server-dev-12是必需的,但是当我尝试安装这个包时,我得到了错误。

> sudo apt install postgresql-server-dev-12

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 postgresql-server-dev-12 : Depends: clang-6.0 but it is not installable
                            Depends: llvm-6.0-dev but it is not installable
E: Unable to correct problems, you have held broken packages.

我也从“软件和更新”更改为从“主服务器”下载。我已经读过,如果我卸载所有 postgres 包然后再次安装它们,那么我可能能够下载 postgresql-server-dev-12。但我不想卸载 postgres 12,因为它也可能会删除大小超过 100GB 的数据库。

我看到很多用户都遇到了这个问题。在这方面的任何帮助将不胜感激。谢谢

标签: postgresqlubuntu-18.04postgresql-12pg-partman

解决方案


所以在为这个问题苦苦挣扎了很久之后,我终于找到了解决办法。这实际上与 linux 没有正确更新有关。我的 apt-update 出现错误,因此我必须先清理它。

sudo apt-get clean
sudo mv /var/lib/apt/lists /tmp
sudo mkdir -p /var/lib/apt/lists/partial
sudo apt-get clean
sudo apt-get update

// Then try to install postgres-server-dev-12 again
sudo apt-get install postgresql-server-dev-12

推荐阅读