精简安装

只安装高可用 PostgreSQL 集群及其最小依赖的精简安装模式

如果您只想要高可用 PostgreSQL 数据库集群本身,而不需要监控、基础设施等功能,请考虑 精简安装

精简安装没有 INFRA 模块,没有监控,没有 本地仓库,只有 ETCDPGSQL 以及部分 NODE 功能。

精简安装适合以下场景:

  • 只需要 PostgreSQL 数据库本身,不需要可观测性基础设施。
  • 资源极度受限的环境,不愿意承担基础设施开销(单机约 0.2 vCPU / 500MB 开销)
  • 已有外部监控系统,希望统一使用自己的监控管理体系。
  • 不希望引入 AGPLv3 许可证的 Grafana 可视化看板组件。

精简安装的局限性:

  • 没有 基础设施模块,无法使用 WebUI 和本地软件仓库功能。
  • 离线安装 仅限单机模式使用,多节点精简安装只能在线安装。

概览

使用精简安装,您需要:

  1. 使用 slim.yml 精简安装配置模板(configure -c slim
  2. 执行 slim.yml 剧本进行部署,而不是默认的 deploy.yml
curl https://repo.pigsty.cc/get | bash
./configure -g -c slim
./slim.yml

说明

精简安装只安装/配置以下组件:

组件必要性描述
patroni⚠️ 必需引导高可用 PostgreSQL 集群
etcd⚠️ 必需Patroni 的元数据库依赖(DCS)
pgbouncer✔️ 可选PostgreSQL 连接池
vip-manager✔️ 可选L2 VIP 绑定到 PostgreSQL 集群主节点
haproxy✔️ 可选根据 Patroni 健康检查,自动路由 服务
chronyd✔️ 可选与 NTP 服务器的时间同步
tuned✔️ 可选节点调优模板和内核参数管理

你可以通过进一步的配置,关闭所有可选组件,只保留必需组件 patronietcd

因为缺少 Infra 模块的 Nginx 提供本地仓库服务,只有单机安装的时候可以进行离线安装


配置

精简安装的配置文件示例:conf/slim.yml

IDNODEPGSQLINFRAETCD
110.10.10.10pg-meta-1不安装基础设施模块etcd-1
---
#==============================================================#
# File      :   slim.yml
# Desc      :   Pigsty slim installation config template
# Ctime     :   2020-05-22
# Mtime     :   2025-12-28
# Docs      :   https://doc.pgsty.com/config
# License   :   Apache-2.0 @ https://pigsty.io/docs/about/license/
# Copyright :   2018-2026  Ruohang Feng / Vonng (rh@vonng.com)
#==============================================================#

# This is the config template for slim / minimal installation
# No monitoring & infra will be installed, just raw postgresql
#
# Usage:
#   curl https://repo.pigsty.io/get | bash
#   ./configure -c slim
#   ./slim.yml

all:
  children:

    etcd: # dcs service for postgres/patroni ha consensus
      hosts: # 1 node for testing, 3 or 5 for production
        10.10.10.10: { etcd_seq: 1 }  # etcd_seq required
        #10.10.10.11: { etcd_seq: 2 }  # assign from 1 ~ n
        #10.10.10.12: { etcd_seq: 3 }  # odd number please
      vars: # cluster level parameter override roles/etcd
        etcd_cluster: etcd  # mark etcd cluster name etcd

    #----------------------------------------------#
    # PostgreSQL Cluster
    #----------------------------------------------#
    pg-meta:
      hosts:
        10.10.10.10: { pg_seq: 1, pg_role: primary }
        #10.10.10.11: { pg_seq: 2, pg_role: replica } # you can add more!
        #10.10.10.12: { pg_seq: 3, pg_role: replica, pg_offline_query: true }
      vars:
        pg_cluster: pg-meta
        pg_users:
          - { name: dbuser_meta ,password: DBUser.Meta   ,pgbouncer: true ,roles: [dbrole_admin   ] ,comment: pigsty admin user }
          - { name: dbuser_view ,password: DBUser.Viewer ,pgbouncer: true ,roles: [dbrole_readonly] ,comment: read-only viewer  }
        pg_databases:
          - { name: meta, baseline: cmdb.sql ,comment: pigsty meta database ,schemas: [pigsty] ,extensions: [ vector ]}
        node_crontab: [ '00 01 * * * postgres /pg/bin/pg-backup full' ] # make a full backup every 1am

  vars:
    version: v4.0.0                   # pigsty version string
    admin_ip: 10.10.10.10             # admin node ip address
    region: default                   # upstream mirror region: default,china,europe
    nodename_overwrite: false           # do not overwrite node hostname on single node mode
    node_repo_modules: node,infra,pgsql # add these repos directly to the singleton node
    node_tune: oltp                     # node tuning specs: oltp,olap,tiny,crit
    pg_conf: oltp.yml                   # pgsql tuning specs: {oltp,olap,tiny,crit}.yml
    pg_version: 18                      # Default PostgreSQL Major Version is 18
    pg_packages: [ pgsql-main, pgsql-common ]   # pg kernel and common utils
    #pg_extensions: [ pg18-time ,pg18-gis ,pg18-rag ,pg18-fts ,pg18-olap ,pg18-feat ,pg18-lang ,pg18-type ,pg18-util ,pg18-func ,pg18-admin ,pg18-stat ,pg18-sec ,pg18-fdw ,pg18-sim ,pg18-etl]

    #----------------------------------------------#
    # PASSWORD : https://doc.pgsty.com/config/security
    #----------------------------------------------#
    grafana_admin_password: pigsty
    grafana_view_password: DBUser.Viewer
    pg_admin_password: DBUser.DBA
    pg_monitor_password: DBUser.Monitor
    pg_replication_password: DBUser.Replicator
    patroni_password: Patroni.API
    haproxy_admin_password: pigsty
    minio_secret_key: S3User.MinIO
    etcd_root_password: Etcd.Root
...

部署

精简安装需要使用 slim.yml 剧本而不是 deploy.yml 剧本进行部署:

./slim.yml

高可用集群

精简安装模式也可以部署高可用集群,在 etcdpg-meta 分组中添加更多节点即可,一个三节点的部署样例:

IDNODEPGSQLINFRAETCD
110.10.10.10pg-meta-1不安装基础设施模块etcd-1
210.10.10.11pg-meta-2不安装基础设施模块etcd-2
310.10.10.12pg-meta-3不安装基础设施模块etcd-3
all:
  children:
    etcd:
      hosts:
        10.10.10.10: { etcd_seq: 1 }
        10.10.10.11: { etcd_seq: 2 }  # <-- 新增
        10.10.10.12: { etcd_seq: 3 }  # <-- 新增

    pg-meta:
      hosts:
        10.10.10.10: { pg_seq: 1, pg_role: primary }
        10.10.10.11: { pg_seq: 2, pg_role: replica } # <-- 新增
        10.10.10.12: { pg_seq: 3, pg_role: replica } # <-- 新增
      vars:
        pg_cluster: pg-meta
        pg_users:
          - { name: dbuser_meta ,password: DBUser.Meta   ,pgbouncer: true ,roles: [dbrole_admin   ] ,comment: pigsty admin user }
          - { name: dbuser_view ,password: DBUser.Viewer ,pgbouncer: true ,roles: [dbrole_readonly] ,comment: read-only viewer  }
        pg_databases:
          - { name: meta, baseline: cmdb.sql ,comment: pigsty meta database ,schemas: [pigsty] ,extensions: [ vector ]}
        node_crontab: [ '00 01 * * * postgres /pg/bin/pg-backup full' ] # make a full backup every 1am
  vars:
    # 省略 ……