You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ubuntu22.04.1 LTS环境下pg_repack安装失败问题求助

解决pg_repack安装失败的问题

针对第一个错误:gcc: No such file or directory

该错误源于系统缺少编译pg_repack所需的基础工具与PostgreSQL开发依赖包,按以下步骤修复:

  • 安装编译依赖(根据系统发行版选择对应命令):
    • Debian/Ubuntu 系列:
      sudo apt update && sudo apt install gcc make postgresql-server-dev-14
      
    • RHEL/CentOS/Rocky 系列:
      sudo dnf install gcc make postgresql14-devel
      
    注意:上述命令中的版本号14需与你服务器上安装的PostgreSQL版本保持一致,若为13则替换为postgresql-server-dev-13或postgresql13-devel。
  • 依赖安装完成后,重新执行pgxn安装命令:
    sudo pgxn install pg_repack
    

针对第二个错误:gmake: *** No rule to make target 'all'. Stop.

该问题是由于执行编译命令时路径错误或未预先配置编译环境,正确操作步骤如下:

  • 克隆仓库后进入项目目录:
    git clone https://github.com/reorg/pg_repack.git
    cd pg_repack
    
  • 先执行配置操作(指定正确的pg_config路径,通常为/usr/bin/pg_config或/usr/pgsql-14/bin/pg_config):
    make PG_CONFIG=/usr/bin/pg_config configure
    
  • 再完成编译与安装:
    make PG_CONFIG=/usr/bin/pg_config all
    sudo make PG_CONFIG=/usr/bin/pg_config install
    

验证安装结果

安装完成后,登录PostgreSQL数据库执行以下命令确认:

CREATE EXTENSION pg_repack;
SELECT * FROM pg_extension WHERE extname = 'pg_repack';

若能查询到对应扩展记录,则说明安装成功。

内容的提问来源于stack exchange,提问作者Prince Kushwaha

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.02 05:10:23