# Pigsty v4.0.0

> Victoria 可观测性，安全加固，JUICE/VIBE 模块，容器支持，Apache-2.0

---

LLMS 索引： [llms.txt](/zh/llms.txt)

---

**v4\.0\.0 · 2026-01-28**
- [查看发布](https://github.com/pgsty/pigsty/releases/tag/v4.0.0)
- [源码 · tar\.gz](https://github.com/pgsty/pigsty/archive/refs/tags/v4.0.0.tar.gz)
- [源码 · zip](https://github.com/pgsty/pigsty/archive/refs/tags/v4.0.0.zip)
- [pgsty\/pigsty](https://github.com/pgsty/pigsty)

```bash
curl https://pigsty.cc/get | bash -s v4.0.0
```

**318 个提交**，604 文件变更，+118,655 / -327,552 行，发布页面: https://github.com/pgsty/pigsty/releases/tag/v4.0.0

## 亮点特性

- **可观测性革命**：Prometheus → VictoriaMetrics（10x 性能提升），Loki + Promtail → VictoriaLogs + Vector
- **安全加固**：自动生成强密码、etcd RBAC、防火墙/SELinux 模式、权限收紧、Nginx Basic Auth
- **容器支持**：支持在 Docker 容器中运行 Pigsty 本身
- **新增模块**：JUICE，提供将 PG 挂载为文件系统并进行 PITR 的能力
- **新增模块**：VIBE，提供 Claude Code、JupyterLab、VS Code Server、Node.js 的配置与可观测性
- **数据库管理**: `pg_databases` state（create/absent/recreate）、`strategy` 瞬间克隆数据库
- **PITR 与分叉**: `/pg/bin/pg-fork` CoW 瞬间克隆、`pg-pitr` 增强支持 PITR 前备份
- **高可用增强**: `pg_rto_plan` 提供四档 RTO 预置参数（fast/norm/safe/wide），`pg_crontab` 定时任务
- **多云 Terraform**：AWS、Azure、GCP、Hetzner、DigitalOcean、Linode、Vultr、腾讯云模板
- **许可证变更**：AGPL-3.0 → Apache-2.0

## 基础设施软件包更新

MinIO 开始使用 [pgsty/minio](https://github.com/pgsty/minio) fork RPM/DEB

| 软件包                 | 版本      | 软件包               | 版本       |
|---------------------|---------|-------------------|----------|
| victoria-metrics    | 1.134.0 | victoria-logs     | 1.43.1   |
| vector              | 0.52.0  | grafana           | 12.3.1   |
| alertmanager        | 0.30.1  | etcd              | 3.6.7    |
| duckdb              | 1.4.4   | pg_exporter       | 1.1.2    |
| pgbackrest_exporter | 0.22.0  | blackbox_exporter | 0.28.0   |
| node_exporter       | 1.10.2  | minio             | 20251203 |
| pig                 | 1.0.0   | claude            | 2.1.19   |
| opencode            | 1.1.34  | uv                | 0.9.26   |
| asciinema           | 3.1.0   | prometheus        | 3.9.1    |
| pushgateway         | 1.11.2  | juicefs           | 1.4.0    |
| code-server         | 4.100.2 | caddy             | 2.10.2   |
| hugo                | 0.154.5 | cloudflared       | 2026.1.1 |
| headscale           | 0.27.1  |                   |          |
{.full-width}

## 新增模块

- **JUICE 模块**：JuiceFS 分布式文件系统，使用 PostgreSQL 作为元数据引擎，支持利用 PITR 恢复文件系统
- **VIBE 模块**：AI 辅助编程沙箱环境（整合了 Code-Server、JupyterLab、Node.js 与 Claude Code）
  - Code-Server：浏览器中的 VS Code
  - JupyterLab：交互式计算环境
  - Node.js：JavaScript 运行时环境
  - Claude Code：AI 编程助手 CLI 配置，内置 OpenTelemetry 可观测性

## PostgreSQL 扩展

**新扩展**: [pg_textsearch](https://github.com/timescale/pg_textsearch) 0.4.0, [pg_clickhouse](https://github.com/clickhouse/pg_clickhouse/) 0.1.3, [pg_ai_query](https://github.com/benodiwal/pg_ai_query) 0.1.1, [etcd_fdw](https://github.com/pgsty/etcd_fdw), [pg_ttl_index](https://github.com/pg-ttl-index) 0.1.0, [pljs](https://github.com/plv8/pljs) 1.0.4, [pg_retry](https://github.com/pg-retry/pg_retry) 1.0.0, [pg_weighted_statistics](https://github.com/pgsty/pg_weighted_statistics) 1.0.0, [pg_enigma](https://github.com/pgsty/pg_enigma) 0.5.0, [pglinter](https://github.com/pgsty/pglinter) 1.0.1, [documentdb_extended_rum](https://github.com/microsoft/documentdb) 0.109, [mobilitydb_datagen](https://github.com/MobilityDB) 1.3.0

**重要更新**：timescaledb 2.24.0, pg_search 0.21.4, citus 14.0.0, documentdb 0.109, age 1.7.0, pg_duckdb 1.1.1, vchord 1.0.0, vchord_bm25 0.3.0, pg_biscuit 2.2.2, pg_anon 2.5.1, wrappers 0.5.7, pg_vectorize 0.26.0, pg_session_jwt 0.4.0, pg_partman 5.4.0, pgmq 1.9.0, pg_bulkload 3.1.23, pg_timeseries 0.2.0, pg_convert 0.1.0, pgBackRest 2.58

## 破坏性变更

## 可观测性栈

| 旧组件        | 新组件             |
|------------|-----------------|
| Prometheus | VictoriaMetrics |
| Loki       | VictoriaLogs    |
| Promtail   | Vector          |
{.full-width}

## 参数变更

| 移除                         | 替代                                                  |
|----------------------------|-----------------------------------------------------|
| `node_disable_firewall`    | `node_firewall_mode` (off/none/zone)                |
| `node_disable_selinux`     | `node_selinux_mode` (disabled/permissive/enforcing) |
| `pg_pwd_enc`               | 已移除，统一使用 scram-sha-256                              |
| `infra_pip_packages`       | `node_pip_packages`                                 |
| `code_home`/`jupyter_home` | `vibe_data`                                         |
{.full-width}

## 默认值变更

| 参数                         | 变化                 |
|----------------------------|--------------------|
| `grafana_clean`            | true → false       |
| `effective_io_concurrency` | 1000 → 200         |
| `install.yml`              | 重命名为 `deploy.yml`  |
{.full-width}

## 可观测性

- 使用全新的 VictoriaMetrics 替代 Prometheus，用几分之一的资源实现数倍的性能
- 使用全新的日志收集方案：VictoriaLogs + Vector，取代 Promtail + Loki
- 统一调整了所有组件的日志格式，PG 日志使用 UTC 时间戳（log_timezone）
- 调整了 PostgreSQL 日志的轮换方式，使用按周循环截断日志轮转模式
- 在 PG 日志中记录超过 1MB 的临时文件分配，在特定模版中启用 PG 17/18 日志新参数
- 新增了 Nginx / Syslog / PG CSV / Pgbackrest / Grafana / Redis / etcd / MinIO 等日志的 Vector 解析配置
- 注册数据源现在会在所有 Infra 节点上进行，Victoria 数据源将自动注册入 Grafana
- 新增 `grafana_pgurl` 参数，允许指定 Grafana 使用 PG 作为后端存储元数据库
- 新增 `grafana_view_password` 参数，指定 Grafana Meta 数据源使用的密码
- `pgbackrest_exporter` 的默认选项现在设置 120 秒的内部缓存间隔（原本为 600s）
- `grafana_clean` 参数的默认值现在由 `true` 改为 `false`，即默认不清除
- 新增指标收集器 `pg_timeline`，收集更实时的时间线指标 `pg_timeline_id`
- `pg_exporter` 更新至 1.1.2，新增 `pg_timeline` 采集器，修复大量历史遗留问题
- 新增 `node-vector` 仪表盘，监控 Vector 日志收集器状态
- 新增 `node-juice` 仪表盘，监控 JuiceFS 分布式文件系统状态
- 新增 `claude-code` 仪表盘，监控 Claude Code AI 编程助手使用情况
- PGSQL Cluster/Instance 仪表盘新增版本横幅显示
- 所有仪表盘使用 compact JSON 格式，大幅减少文件体积

## 接口改进

- `install.yml` 剧本现在重命名为 `deploy.yml` 以更符合语义
- 新增 `vibe.yml` 剧本，用于部署 VIBE AI 编程沙箱环境
- `pg_databases` 数据库制备功能改进
  - 添加删库能力：可以使用 `state` 字段指定 `create`, `absent`, `recreate` 三种状态
  - 添加克隆能力：数据库定义中使用 `strategy` 参数指定克隆方法
  - 支持较新版本引入的 locale 配置参数：`locale_provider`，`icu_locale`，`icu_rules`，`builtin_locale`
  - 支持 `is_template` 参数，将数据库标记为模板数据库
  - 添加了更多类型检查，避免了字符类参数的注入
  - 允许在 extension 中指定 `state: absent` 以删除扩展
- `pg_users` 用户制备功能改进，新增参数 `admin`，类似 `roles`，但是带有 `ADMIN OPTION` 权限可以转授
- `pg_hba` 支持 `order` 字段，允许指定 HBA 规则的排序优先级，支持 IPv6 的 localhost 访问
- 新增 `infra_extra_services` 参数用于首页额外服务入口导航

## 参数优化

- `pg_io_method` 参数：auto, sync, worker, io_uring 四种方式可选，默认 worker
- `maintenance_io_concurrency` 设置为 100（如果使用 SSD）
- `effective_io_concurrency` 从 1000 减小为 200
- `file_copy_method` 参数为 PG18 默认设置为 `clone`，提供瞬间克隆数据库的能力
- `idle_replication_slot_timeout` 默认 7d，crit 模板 3d
- `log_lock_failures`：oltp, crit 模版开启
- `track_cost_delay_timing`：olap, crit 模版开启
- `log_connections`：oltp/olap 开启认证日志，crit 开启全部日志
- 新增 `pg_rto_plan` 参数，整合 Patroni 与 HAProxy 的 RTO 相关配置（fast/norm/safe/wide）
- `pg_crontab` 参数：为 postgres dbsu 配置定时任务
- 对于 PG17+，如果 `pg_checksums` 开关关闭，在 Patroni 初始化集群时显式禁用校验和
- Crit 模板启用 Patroni 严格同步模式
- PITR 默认 `archive_mode` 改为 `preserve`，确保恢复后保留归档能力
- `pg-pitr` 支持恢复前自动备份数据
- 修复了 `duckdb.allow_community_extensions` 总是生效的问题
- 允许通过 `node_firewall_intranet` 指定 HBA 信任的 "内网网段"
- 现在 pg_hba 与 pgbouncer_hba 支持 IPv6 的 localhost 访问

## 架构改进

- 在 Infra 节点上，设置固定的 `/infra` 软连接指向 Infra 数据目录 `/data/infra`
- 现在 Infra 的数据默认放置于 `/data/infra` 目录下，这使得在容器中使用更为便利
- 本地软件仓库现在放置于 `/data/nginx/pigsty`，`/www` 现在作为软链接指向 `/data/nginx` 确保兼容
- DNS 解析记录现放置于 dnsmasq 专属的 `/etc/dnsmasq.d/pigsty` 目录，并保留原子发布，兼容 SELinux 与 AppArmor
- 默认首页域名从 `h.pigsty` 更名为 `i.pigsty`，新增中文首页支持
- 新增了 `/pg/bin/pg-fork` 脚本，用于快速创建 CoW 副本数据库实例
- 调整 `/pg/bin/pg-pitr` 脚本，现在可以用于实例级别的 PITR 恢复，支持恢复前自动备份
- 新增 `/pg/bin/pg-drop-role` 脚本，用于安全删除用户角色
- 新增 `bin/pgsql-ext` 脚本，用于安装 PostgreSQL 扩展
- 恢复 `pg-vacuum` 和 `pg-repack` 脚本
- 新增剧本 `juice.yml`：部署 JuiceFS 分布式文件系统实例
- 新增剧本 `vibe.yml`：部署 VIBE AI 编程沙箱环境（含 Code-Server、JupyterLab、Claude Code）
- 显式安装 cron/cronie 包，确保定时任务功能在最小化安装的系统上可用
- UV Python 包管理器从 `infra` 模块迁移至 `node` 模块，新增 `node_uv_env` 参数指定虚拟环境路径
- `pg_remove`/`pg_pitr` 移除 etcd 元数据的任务，现在不再依赖 admin_ip 管理节点，而在 etcd 集群上执行
- 36 节点仿真模板 simu 简化为 20 节点的版本
- 适配上游变化，移除 PGDG sysupdate 仓库，移除 EL 系统上所有 llvmjit 的相关包
- 为 EPEL 10 / PGDG 9/10 仓库使用操作系统完整版本号（`major.minor`）
- 允许在仓库定义中指定 `meta` 参数，覆盖 yum 仓库的定义元数据
- 确保 Vagrant libvirt 模板默认带有 128GB 磁盘，以 xfs 挂载于 `/data`
- 确保 pgbouncer 不再将 `0.0.0.0` 监听地址修改为 `*`
- 新增 10 节点、Citus 等 Vagrant 配置模板
- 恢复 EL7 系统兼容性支持
- 多云 Terraform 模板：AWS、Azure、GCP、Hetzner、DigitalOcean、Linode、Vultr、腾讯云

## 安全改进

- `configure` 现在支持 `-g` 参数自动生成随机强密码，避免使用默认密码带来的安全隐患
- 更改了 MinIO 模块的默认密码，避免与众所周知的默认密码冲突
- 移除 `node_disable_firewall`，新增 `node_firewall_mode`，支持 off, none, zone 三种模式
- 移除 `node_disable_selinux`，新增 `node_selinux_mode`，支持 disabled, permissive, enforcing 三种模式
- 为 HAProxy、Nginx、DNSMasq、Redis 等组件配置了正确的 SELinux 上下文
- 启用了针对 etcd 的 RBAC，每个集群现在只能管理自己的 PostgreSQL 数据库集群
- etcd root 密码现在放置于 `/etc/etcd/etcd.pass` 文件中，仅对管理员可读
- 将 `admin_ip` 添加到 Patroni API 允许访问的 IP 列表白名单中
- 总是创建 admin 系统用户组，patronictl 配置收紧为仅限 admin 组用户访问
- 新增 `node_admin_sudo` 参数，允许指定/调整数据库管理员的 sudo 权限模式（all/nopass）
- 收回了所有非 root 用户对可执行脚本的拥有权限
- 新增 Nginx Basic Auth 支持，可以为 Nginx Server 设置可选的 HTTP Basic Auth
- 修复 ownca 证书有效期问题，确保了 Chrome 可以识别自签名证书
- 新增 `vip_auth_pass` 参数用于 VRRP 认证
- 修复了若干 `ansible copy content` 字段为空时报错的问题
- 修复了 `pg_pitr` 中遗留的一些问题，确保 Patroni 集群恢复时没有竞态条件
- 使用 `mode 0700` 保护 `files/pki/ca` 目录

## 问题修复

- 修复 ownca 证书有效期 Chrome 兼容性问题
- 修复 Vector 0.52 syslog_raw 解析问题
- 修复 pg_pitr 多副本 clonefrom 时序问题
- 修复 Ansible SELinux dnsmasq 竞态条件
- 修复 EL9 aarch64 patroni & llvmjit 问题
- 修复 Debian groupadd 路径问题
- 修复空 sudoers 文件生成问题
- 修复 pgbouncer pid 路径（`/run/postgresql`）
- 修复 `duckdb.allow_community_extensions` 始终生效问题
- 因上游问题隐藏 EL8 上的 pg_partman 扩展
- 修复 HAProxy 服务模板变量路径
- 修复 Redis remove 任务变量名
- 移除 MinIO reload handler 无效处理器
- 修正 vmetrics_port 默认值为 8428
- 修复 pg-failover-callback 脚本处理所有 Patroni 回调事件
- 修复 pg-vacuum 事务块处理逻辑
- 添加 PG16+ 并行逻辑复制支持
- 修复 FerretDB 证书配置和服务重启策略
- 修正 Polar Exporter 监控指标类型定义
- 修复代理环境变量未传递问题
- 修复移除模式下 postgres 服务配置
- 更新 Docker 默认数据目录路径
- 修复 EL10 系统上的缓存问题
- 修复 etcd/MinIO 移除时 systemd 服务和 DNS 条目清理

## 新增参数

| 参数                       | 类型     | 默认值           | 说明                                 |
|--------------------------|--------|---------------|------------------------------------|
| `node_firewall_mode`     | enum   | none (v4.0)   | 防火墙模式：off/none/zone（v4.1 起默认 zone） |
| `node_selinux_mode`      | enum   | permissive    | SELinux 模式                         |
| `node_firewall_intranet` | string | -             | HBA 信任的内网网段                        |
| `node_admin_sudo`        | enum   | nopass        | 管理员 sudo 权限级别                      |
| `pg_io_method`           | enum   | worker        | I/O 方法：auto/sync/worker/io_uring   |
| `pg_rto_plan`            | dict   | -             | RTO 预设：fast/norm/safe/wide         |
| `pg_crontab`             | list   | []            | postgres dbsu 定时任务                 |
| `vip_auth_pass`          | string | -             | VRRP 认证密码                          |
| `grafana_pgurl`          | string | -             | Grafana PG 后端连接字符串                 |
| `grafana_view_password`  | string | DBUser.Viewer | Grafana Meta 数据源密码                 |
| `infra_extra_services`   | list   | []            | 首页额外服务入口                           |
| `juice_cache`            | path   | /data/juice   | JuiceFS 共享缓存目录                     |
| `juice_instances`        | dict   | {}            | JuiceFS 实例定义                       |
| `vibe_data`              | path   | /fs           | VIBE 工作空间目录                        |
| `code_enabled`           | bool   | true          | 是否启用 Code-Server                   |
| `code_port`              | port   | 8443          | Code-Server 监听端口                   |
| `code_data`              | path   | /data/code    | Code-Server 数据目录                   |
| `code_password`          | string | Vibe.Coding   | Code-Server 登录密码                   |
| `code_gallery`           | enum   | openvsx       | 扩展市场：openvsx/microsoft             |
| `jupyter_enabled`        | bool   | true          | 是否启用 JupyterLab                    |
| `jupyter_port`           | port   | 8888          | JupyterLab 监听端口                    |
| `jupyter_data`           | path   | /data/jupyter | JupyterLab 数据目录                    |
| `jupyter_password`       | string | Vibe.Coding   | JupyterLab 登录 Token                |
| `jupyter_venv`           | path   | /data/venv    | Python 虚拟环境路径                      |
| `claude_enabled`         | bool   | true          | 是否启用 Claude Code 配置                |
| `claude_env`             | dict   | {}            | Claude Code 额外环境变量                 |
| `nodejs_enabled`         | bool   | true          | 是否启用 Node.js 安装                    |
| `nodejs_registry`        | string | ''            | npm registry，自动配置中国镜像              |
| `node_uv_env`            | path   | /data/venv    | 节点 UV 虚拟环境路径，空则跳过                  |
| `node_pip_packages`      | string | ''            | UV 虚拟环境中安装的 pip 包                  |
{.full-width}

## 兼容性

| 操作系统               | x86_64 | aarch64 |
|--------------------|:------:|:-------:|
| EL 8/9/10          |   ✅    |    ✅    |
| Debian 11/12/13    |   ✅    |    ✅    |
| Ubuntu 22.04/24.04 |   ✅    |    ✅    |
{.full-width}

**PostgreSQL**: 13, 14, 15, 16, 17, 18

## 校验和

```bash
9f42b8c64180491b59bd03016c26e8ca  pigsty-v4.0.0.tgz
db9797c3c8ae21320b76a442c1135c7b  pigsty-pkg-v4.0.0.d12.aarch64.tgz
1eed26eee42066ca71b9aecbf2ca1237  pigsty-pkg-v4.0.0.d12.x86_64.tgz
03540e41f575d6c3a7c63d1d30276d49  pigsty-pkg-v4.0.0.d13.aarch64.tgz
36a6ee284c0dd6d9f7d823c44280b88f  pigsty-pkg-v4.0.0.d13.x86_64.tgz
f2b6ec49d02916944b74014505d05258  pigsty-pkg-v4.0.0.el10.aarch64.tgz
73f64c349366fe23c022f81fe305d6da  pigsty-pkg-v4.0.0.el10.x86_64.tgz
287f767fbb66a9aaca9f0f22e4f20491  pigsty-pkg-v4.0.0.el8.aarch64.tgz
c0886aab454bd86245f3869ef2ab4451  pigsty-pkg-v4.0.0.el8.x86_64.tgz
094ab31bcf4a3cedbd8091bc0f3ba44c  pigsty-pkg-v4.0.0.el9.aarch64.tgz
235ccba44891b6474a76a81750712544  pigsty-pkg-v4.0.0.el9.x86_64.tgz
f2791c96db4cc17a8a4008fc8d9ad310  pigsty-pkg-v4.0.0.u22.aarch64.tgz
3099c4453eef03b766d68e04b8d5e483  pigsty-pkg-v4.0.0.u22.x86_64.tgz
49a93c2158434f1adf0d9f5bcbbb1ca5  pigsty-pkg-v4.0.0.u24.aarch64.tgz
4acaa5aeb39c6e4e23d781d37318d49b  pigsty-pkg-v4.0.0.u24.x86_64.tgz
```

## 信息来源

- [GitHub Release](https://github.com/pgsty/pigsty/releases/tag/v4.0.0)
- [Pigsty v4.0 发布文章](https://pigsty.cc/blog/pigsty/v4.0/)
- [历史 About / 发布注记](https://pigsty.cc/docs/about/release/#v400)
- [源码对比：`v3.7.0...v4.0.0`](https://github.com/pgsty/pigsty/compare/v3.7.0...v4.0.0)
