精简安装
只安装高可用 PostgreSQL 集群及其最小依赖的精简安装模式
如果您只想要高可用 PostgreSQL 本身,而不需要监控、基础设施等功能,请考虑精简安装。
没有 INFRA 模块,没有监控,没有 本地仓库,只有 ETCD 和 PGSQL 以及部分 NODE 功能
概览
使用精简安装,您需要:
- 使用
slim.yml配置模板(configure -c slim) - 运行
slim.yml剧本而不是install.yml
curl https://repo.pigsty.cc/get | bash
./configure -c slim
./slim.yml
精简安装只安装这些核心组件:
| 组件 | 必需性 | 描述 |
|---|---|---|
| patroni | ⚠️ 必需 | 引导高可用 PostgreSQL 集群 |
| etcd | ⚠️ 必需 | Patroni 的元数据库依赖(DCS) |
| pgbouncer | ✔️ 可选 | PostgreSQL 连接池 |
| vip-manager | ✔️ 可选 | L2 VIP 绑定到 PostgreSQL 集群主节点 |
| haproxy | ✔️ 可选 | 自动路由 服务 |
| chronyd | ✔️ 可选 | 与 NTP 服务器的时间同步 |
| tuned | ✔️ 可选 | 节点调优模板和内核参数管理 |
您可以关闭可选组件,只有两个必需组件是 patroni 和 etcd。
软件包直接从互联网上游仓库安装,离线安装 在此处不适用。
配置
精简安装的配置文件示例:conf/slim.yml:
all:
children:
etcd: # DCS 服务,用于 PostgreSQL/Patroni 高可用共识
hosts: # 测试用 1 节点,生产环境用 3 或 5 节点
10.10.10.10: { etcd_seq: 1 } # etcd_seq 必需
#10.10.10.11: { etcd_seq: 2 } # 从 1 ~ n 分配
#10.10.10.12: { etcd_seq: 3 } # 请使用奇数个节点
vars:
etcd_cluster: etcd # 标记 etcd 集群名称
#----------------------------------------------#
# PostgreSQL 集群
#----------------------------------------------#
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, 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' ] # 每天凌晨 1 点全量备份
vars:
version: v4.0.0 # pigsty 版本字符串
admin_ip: 10.10.10.10 # 管理节点 IP 地址
region: default # 上游镜像区域: default,china,europe
nodename_overwrite: false # 单节点模式下不覆盖节点主机名
node_repo_modules: node,infra,pgsql # 直接添加这些仓库到单节点
node_tune: oltp # 节点调优规格: oltp,olap,tiny,crit
pg_conf: oltp.yml # pgsql 调优规格: {oltp,olap,tiny,crit}.yml
pg_version: 18 # 默认 PostgreSQL 主版本为 18
pg_packages: [ pgsql-main, pgsql-common ] # pg 内核和常用工具
#----------------------------------------------#
# 密码配置
#----------------------------------------------#
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 剧本而不是 install.yml 剧本:
./slim.yml
不要使用 install.yml 进行精简安装
这个 slim.yml 剧本是专门用来在精简安装场景中取代默认 install.yml 剧本的。