Ubuntu 22.04 安装 Steampipe 2.4.9 指南

在 Ubuntu 22.04 服务器上安装 Steampipe v2.4.9 的三种方案实测:官方安装脚本、手动 tar.gz(sha256 校验)、deb/rpm 包,含 workspace 初始化、内嵌 PostgreSQL 服务、插件管理与 systemd 托管,命令回显逐行照抄。

SteampipeSteampipePostgreSQLCLI数据库2026/11/03

Ubuntu 22.04 安装 Steampipe 2.4.9 指南

目标:在一台干净的 Ubuntu 22.04 服务器上从零装好 Steampipe v2.4.9,跑通「内嵌数据库服务 + 免凭证插件实时查询」,并沉淀 systemd 托管与卸载清理的完整实操。选型背景见 《Steampipe 介绍与选型指南》。

一、环境信息

项目值
操作系统Ubuntu 22.04.5 LTS (Jammy Jellyfish)
架构x86_64
内核5.15.0-181-generic
软件版本Steampipe v2.4.9(2026-11-01 发布的最新稳定版,2026-11-03 实查)
内嵌数据库PostgreSQL 14.19(Steampipe 自动下载初始化)
服务端口9193(默认)
安装日期2026-11-03
运行用户普通用户 admin(Steampipe 拒绝 root 运行,见第二节)

二、前置条件

# 基础工具(Ubuntu 22.04 最小安装可能缺 wget/curl)
apt-get update && apt-get install -y wget curl ca-certificates

关键前提:创建非 root 运行用户。 直接以 root 运行会立刻被拒(实测回显逐行照抄):

$ steampipe --version
Error: Steampipe cannot be run as the "root" user.
To reduce security risk, use an unprivileged user account instead.
$ useradd -m -s /bin/bash admin && echo "admin:q1w2e3r4" | chpasswd && id admin
uid=1000(admin) gid=1000(admin) groups=1000(admin)

后续所有 steampipe 命令均以 admin 用户执行。网络需可达 github.com(发布件)与 hub.steampipe.io(插件市场)。

三、版本选择说明

  • 本文基线 v2.4.9:Releases 页最新稳定版(2026-11-01),近三个月发布节奏为 v2.4.6(09-09)→ v2.4.7(09-16)→ v2.4.8(10-22)→ v2.4.9(11-01);
  • 存在 v2.5.0-beta 预发布线(beta 构建 2026-06-22),生产不建议追 beta;
  • 每个发布带 checksums.txt,列出全部平台资产与 SHA256,便于锁版本与校验;
  • 手动安装与官方脚本的差异:脚本默认装「最新稳定版」,脚本也支持显式传版本参数(如 sh install.sh v2.4.9),但传参时走 GitHub 直链、无代理支持(脚本源码可见)。

四、方案 A:官方安装脚本(在线,最省事)

官方 README 推荐的一行式安装(需 sudo,脚本内部自动补):

sudo /bin/sh -c "$(curl -fsSL https://steampipe.io/install/steampipe.sh)"

脚本先做架构映射(x86_64 → linux_amd64)、检查 root 场景,然后下载最新稳定版 tar 包解压安装。实测收尾回显(2026-11-03):

2026-11-03 04:52:21 (15.8 MB/s) - '/tmp/tmp.5SptVyZzsZ/steampipe.tar.gz' saved [21753392/21753392]

Deflating downloaded archive
Installing
Applying necessary permissions
Removing downloaded archive
Steampipe was installed successfully to /usr/local/bin/steampipe

验证:

$ su - admin -c "steampipe --version"
Steampipe v2.4.9

⚠️ 提示:脚本走 GitHub 直连,实测下载耗时波动大(一次约 5 分钟、一次 1.3 秒,取决于 CDN 命中)。国内网络超时时改用方案 B 并配置代理(见第五节降级实录)。

五、方案 B:手动 tar.gz(推荐,版本可控可离线)

5.1 下载发布件与校验文件

cd /root
wget https://github.com/turbot/steampipe/releases/download/v2.4.9/steampipe_linux_amd64.tar.gz
wget https://github.com/turbot/steampipe/releases/download/v2.4.9/checksums.txt

实测下载结果:主包 21,753,392 字节直连官方源成功(耗时数分钟);checksums.txt 直连超时失败(timeout 60 秒无响应),按「官方源 → 代理」降级链改走企业代理成功:

$ wget https://github.com/turbot/steampipe/releases/download/v2.4.9/checksums.txt
Connecting to github.com (github.com)... 20.205.243.166...
# —— 60 秒无响应,超时 ——

$ wget -e https_proxy=http://192.168.1.72:7897 \
    https://github.com/turbot/steampipe/releases/download/v2.4.9/checksums.txt
Connecting to github.com (github.com)... 20.205.243.166, 2606:50c0:8000::154
Connected to github.com (github.com) via proxy 192.168.1.72:7897.
HTTP request sent, awaiting response... 200 OK
Length: 744 [text/plain]

checksums.txt      100[===================>]     744  --.-KB/s    in 0s

2026-11-03 04:32:43 (104 MB/s) - 'checksums.txt' saved [744/744]

⚠️ 降级说明:本次实验网络对 GitHub 直连时好时坏,代理地址 192.168.1.72:7897 为本机企业代理,请按你的环境替换或去掉 -e https_proxy=...。

5.2 SHA256 校验

$ grep " steampipe_linux_amd64.tar.gz$" checksums.txt
3a59bbed43019cb17b9b9adbc8b559772c6b49ac22e6579bd63c9cae5e4ba413  steampipe_linux_amd64.tar.gz

$ sha256sum -c <(grep " steampipe_linux_amd64.tar.gz$" checksums.txt)
steampipe_linux_amd64.tar.gz: OK

5.3 解压安装

$ tar -xzf steampipe_linux_amd64.tar.gz
$ ls -l steampipe
-rw-r--r-- 1 1000 1000 73822370 Oct 23 14:01 steampipe

$ install -m 0755 steampipe /usr/local/bin/steampipe && rm -f steampipe
$ su admin -c "steampipe --version"
Steampipe v2.4.9

单二进制 73.8 MB,内置全部运行时(含 PostgreSQL 分发下载器)。

六、方案 C:deb/rpm 发行版包

checksums.txt 同列有 steampipe_linux_amd64.deb(c58caebd…)与 steampipe_linux_amd64.rpm(d7b413e9…)。deb 实测(代理下载):

$ wget -e https_proxy=http://192.168.1.72:7897 \
    https://github.com/turbot/steampipe/releases/download/v2.4.9/steampipe_linux_amd64.deb
$ sha256sum steampipe_linux_amd64.deb
c58caebd445aa27f246bfc35a9b1c7aa9d683542333389ef14270d781d667c37  steampipe_linux_amd64.deb

$ dpkg -i steampipe_linux_amd64.deb
(Reading database ... 9503 files and directories currently installed.)
Preparing to unpack steampipe_linux_amd64.deb ...
Unpacking steampipe (2.4.9) ...
Setting up steampipe (2.4.9) ...

$ which steampipe
/usr/local/bin/steampipe
$ dpkg -l | grep steampipe
ii  steampipe  2.4.9  amd64  Use SQL to instantly query your cloud services (AWS, Azure, GCP and more). Open source CLI. No DB required.

RPM 系(RHEL/Rocky/openEuler)同理 rpm -ivh steampipe_linux_amd64.rpm——本次实验机为 Ubuntu,rpm 安装未实测,仅确认官方资产存在且带校验值。

七、方案对比与选型建议

方案版本可控离线可行包管理纳管实测结论
A 官方脚本传参可控(无代理支持)否否成功,下载速度波动大
B 手动 tar.gz强(URL 锁版本+sha256)是否成功,推荐
C deb/rpm强是是deb 成功;rpm 资产存在未实测
  • 单机/CI 快速体验 → A;
  • 生产标准化、需校验与锁版本 → B;
  • 已有 apt/yum 基线管理 → C。

八、workspace 初始化与内嵌数据库服务

首次执行查询会自动完成三件事:创建 workspace(~/.steampipe)、下载并初始化内嵌 PostgreSQL 数据目录、拉起服务。实测(admin 用户):

$ steampipe query "select 1 as hello, version();"
+-------+-----------------------------------------------+
| hello | version                                       |
+-------+-----------------------------------------------+
| 1     | PostgreSQL 14.19 on x86_64-pc-linux-gnu ...   |
+-------+-----------------------------------------------+

生成的 workspace 结构(节选):

~/.steampipe
├── config/
│   ├── default.spc.sample      # 数据库/通用参数样例
│   └── workspaces.spc.sample   # 多 workspace 档案样例
├── db/14.19.0/                 # 内嵌 PostgreSQL 数据目录
├── internal/
│   ├── connection.json         # 当前服务连接信息
│   └── .passwd                 # steampipe 数据库随机口令
├── logs/
└── plugin/

服务生命周期命令:

$ steampipe service start
Started Steampipe service (version: 2.4.9) in workspace "default"
...
Database Feedback:
Database is initialized and running with a Postgres version of 14.19
Database available via the following connection string:
  Connection String: postgresql://steampipe:****@127.0.0.1:9193/steampipe
  Database: steampipe
  User: steampipe
  Password: ****
  Port: 9193
  Host(s): localhost, 127.0.0.1, ::1, <本机IP>

$ steampipe service status
Service is running:
+-----------+------------------------------------------+
| Process   | Status                                   |
+-----------+------------------------------------------+
| database  | Running                                  |
| plugin    | Running (plugin manager, 2 subprocesses) |
+-----------+------------------------------------------+

$ steampipe service stop
Steampipe service stopped

演示环境统一把数据库口令设为 q1w2e3r4:steampipe service start --database-password q1w2e3r4。

九、插件管理

Steampipe 本体不含数据源,插件来自 Hub(hub.steampipe.io)。安装两个免云凭证插件做验证:

$ steampipe plugin install hackernews steampipe

Installed:
+--------------+---------+
| Plugin       | Version |
+--------------+---------+
| hackernews   | 1.2.0   |
| steampipe    | 1.1.0   |
+--------------+---------+

查看与更新:

$ steampipe plugin list
+--------------+---------+---------------------------+-------------+
| Plugin       | Version | Connections               | Mod Configs |
+--------------+---------+---------------------------+-------------+
| hackernews   | 1.2.0   | hackernews                | 0           |
| steampipe    | 1.1.0   | steampipe                 | 0           |
+--------------+---------+---------------------------+-------------+

$ steampipe plugin update hackernews
All plugins up to date!
Plugin                       Version   Status
hackernews                   v1.2.0    Up to date

安装插件时自动生成其默认连接文件(~/.steampipe/config/hackernews.spc,内容含官方注释的 max_items 参数)。实时查询验证(Hacker News 公开 API,无需任何凭证):

$ steampipe query "select id, title, score from hackernews_new order by score desc limit 5;"
+---------+---------------------------------------------------+-------+
| id      | title                                             | score |
+---------+---------------------------------------------------+-------+
| 46187... | ...                                               | 41    |
+---------+---------------------------------------------------+-------+

⚠️ 实测坑:官方文档常引用的示例插件 stub 在 Hub 已检索不到:

$ steampipe plugin install stub
Skipped the following plugin:
Plugin: stub@latest
Reason: Not found

这是 Hub 内容收缩的信号(详见选型篇 2.1 节),免凭证验证请用 hackernews 等公开数据插件。

十、systemd 托管

Steampipe 自带 steampipe service 生命周期,但服务器常驻建议交给 systemd。service start 支持 --foreground 前台模式,正好适配 Type=simple 单元:

# /etc/systemd/system/steampipe.service
[Unit]
Description=Steampipe database service
After=network.target

[Service]
Type=simple
User=admin
Environment=HOME=/home/admin
ExecStart=/usr/local/bin/steampipe service start --foreground --database-listen local --database-password q1w2e3r4
Restart=on-failure

[Install]
WantedBy=multi-user.target
$ systemctl daemon-reload && systemctl enable steampipe
Created symlink /etc/systemd/system/multi-user.target.wants/steampipe.service → /etc/systemd/system/steampipe.service.
$ systemctl is-enabled steampipe
enabled

$ systemctl start steampipe && systemctl is-active steampipe
active

$ systemctl status steampipe --no-pager | head -6
● steampipe.service - Steampipe database service
     Loaded: loaded (/etc/systemd/system/steampipe.service; enabled; vendor preset: enabled)
     Active: active (running) since Mon 2026-11-02 20:39:09 UTC; ...
   Main PID: 1454 (steampipe)

实测注意:--database-listen 不显式指定时按 CLI 默认值 network(监听所有网卡),会覆盖 default.spc 里的 listen = "local";生产单元里务必显式写 --database-listen local(验证方法见配置篇)。

十一、安装后验证清单

# 1. 任意 Postgres 客户端直连内嵌库
$ PGPASSWORD=q1w2e3r4 psql -h 127.0.0.1 -p 9193 -U steampipe -d steampipe \
    -c "select version();" -c "\dx"
 version                                                       
----------------------------------------------------------------
 PostgreSQL 14.19 on x86_64-pc-linux-gnu, compiled by gcc ...
                            List of installed extensions
       Name        | Version |    Type     | Description
-------------------+---------+-------------+--------------------------------
 steampipe_postgres | 1.0     | foreign-data| FDW for Steampipe data sources
                    _fdw    |           | wrapper     |

# 2. 跨表 JOIN(查询时实时调 API)
$ steampipe query --timing /home/admin/top.sql
+--------+----------------------------------------------+-------+
| id     | title                                        | score |
+--------+----------------------------------------------+-------+
| 46187… | ...                                          | 41    |
+--------+----------------------------------------------+-------+
Execution time: 1.3 seconds

十二、常见问题

  1. Steampipe cannot be run as the "root" user:设计如此(降低风险),用普通用户运行;安装类动作交给 sudo。
  2. 官方源下载超时:按「官方直连 → 代理」降级;wget -e https_proxy=http://<你的代理>:7897 ...。本文 checksums.txt 即直连超时、代理成功的实录。
  3. plugin install stub 报 Not found:Hub 已无该示例插件,改用 hackernews 等公开数据插件验证。
  4. 改连接配置不生效:~/.steampipe/config/*.spc 变更后需 steampipe service restart(实测命名连接重启后才出现在 plugin list)。
  5. steampipe query "select 1; select 2;" 报 cannot insert multiple commands into a prepared statement:非交互模式一条 query 参数只放一条语句,多条分别传参。
  6. 交互式控制台管道输入报 no such device or address:控制台需要 TTY,脚本化用 steampipe query "SQL" 或传 .sql 文件。

十三、卸载与清理

# systemd 托管先停并删单元
systemctl disable --now steampipe
rm /etc/systemd/system/steampipe.service && systemctl daemon-reload

# 方案 C(deb)安装:
apt-get purge -y steampipe
# After this operation, 73.8 MB disk space will be freed.

# 方案 A/B 安装:删二进制
rm -f /usr/local/bin/steampipe

# 删 workspace(含内嵌数据库数据、插件、配置)——不可逆,先备份 ~/.steampipe/config
rm -rf ~/.steampipe

十四、参考链接