# 精简安装

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

---

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

---

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

精简安装没有 [**`INFRA`**](/docs/infra/) 模块，没有监控，没有 [**本地仓库**](/docs/setup/offline/)，只有 [**`ETCD`**](/docs/etcd/) 和 [**`PGSQL`**](/docs/pgsql/) 以及部分 [**`NODE`**](/docs/node/) 功能。

> [!TIP] 精简安装适合以下场景
> - 只需要 PostgreSQL 数据库本身，不需要可观测性基础设施。
> - 资源极度受限的环境，不愿意承担基础设施开销（单机约 0.2 vCPU / 500MB 开销）
> - 已有外部监控系统，希望统一使用自己的监控管理体系。
> - 不需要 Grafana 可视化看板组件。

> [!WARNING] 精简安装的局限性
> - 没有 [**基础设施模块**](/docs/infra)，无法使用 WebUI 和本地软件仓库功能。
> - [**离线安装**](/docs/setup/offline) 仅限单机模式使用，多节点精简安装只能在线安装。


--------

## 概览

使用精简安装，您需要：

1. 使用 [**`slim.yml`**](/docs/conf/slim) 精简安装配置模板（`configure -c slim`）
2. 执行 `slim.yml` 剧本进行部署，而不是默认的 `deploy.yml`
{.steps}

```bash
curl https://repo.pigsty.cc/get | bash
./configure -g -c slim
./slim.yml
```

<div id="td-asciinema-ae74ea9edb0377c0376fb963fc0afbac-0" class="td-asciinema td-max-width-on-larger-screens" data-td-asciinema
  data-td-timer-label="播放时间">
  <div class="td-asciinema__chrome">
    <span class="td-asciinema__lights" aria-hidden="true"><i></i><i></i><i></i></span>
    <span class="td-asciinema__title" dir="auto">demo/install-slim.cast</span>
  </div>
  <div data-td-asciinema-player></div>
  <script type="application/json" data-td-asciinema-config>{"options":{"autoPlay":true,"fit":"width","loop":true,"markers":[3,"安装",13,"配置",22,"部署"],"preload":false,"speed":1.3,"startAt":0},"src":"/demo/install-slim.cast","theme":"auto"}</script>
</div>



--------

## 说明

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

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

你可以通过进一步的配置，关闭所有可选组件，只保留必需组件 `patroni` 和 `etcd`。

因为缺少 Infra 模块的 Nginx 提供本地仓库服务，只有单机安装的时候可以进行 [**离线安装**](/docs/setup/offline/)。


--------

## 配置

精简安装的配置文件示例：[**`conf/slim.yml`**](https://github.com/pgsty/pigsty/blob/main/conf/slim.yml)：

| ID | [NODE](/docs/node/) | [PGSQL](/docs/pgsql/) | [INFRA](/docs/infra/) | [**ETCD**](/docs/etcd/) |
|:--:|:-------------------:|:---------------------:|:---------------------:|:-----------------------:|
| 1  |    `10.10.10.10`    |      `pg-meta-1`      |     **不安装基础设施模块**     |        `etcd-1`         |
{.full-width}


```yaml
---
#==============================================================#
# File      :   slim.yml
# Desc      :   Pigsty slim installation config template
# Ctime     :   2020-05-22
# Mtime     :   2025-12-28
# Docs      :   https://pigsty.io/docs/conf/slim
# 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 }  # three-member cluster keeps an odd voter count
      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 ]}
        pg_hba_rules:   # https://pigsty.io/docs/pgsql/config/hba
          - { user: all ,db: all ,addr: intra ,auth: pwd ,title: 'everyone intranet access with password' ,order: 800 }
        pg_crontab:     # https://pigsty.io/docs/pgsql/admin/crontab
          - '00 01 * * * /pg/bin/pg-backup full'

  vars:
    version: v4.5.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://pigsty.io/docs/setup/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`](https://github.com/pgsty/pigsty/blob/main/slim.yml) 剧本而不是 [`deploy.yml`](https://github.com/pgsty/pigsty/blob/main/deploy.yml) 剧本进行部署：

```bash
./slim.yml
```


--------

## 高可用集群

精简安装模式也可以部署高可用集群，在 `etcd` 和 `pg-meta` 分组中添加更多节点即可，一个三节点的部署样例：

| ID | [NODE](/docs/node/) | [PGSQL](/docs/pgsql/) | [INFRA](/docs/infra/) | [**ETCD**](/docs/etcd/) |
|:--:|:-------------------:|:---------------------:|:---------------------:|:-----------------------:|
| 1  |    `10.10.10.10`    |      `pg-meta-1`      |     **不安装基础设施模块**     |        `etcd-1`         |
| 2  |    `10.10.10.11`    |      `pg-meta-2`      |     **不安装基础设施模块**     |        `etcd-2`         |
| 3  |    `10.10.10.12`    |      `pg-meta-3`      |     **不安装基础设施模块**     |        `etcd-3`         |
{.full-width}


```yaml
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 ]}
        pg_crontab: [ '00 01 * * * /pg/bin/pg-backup full' ] # 每天凌晨 1 点执行全量备份
  vars:
    # 省略 ……
```
