PolarDB PG

使用阿里云开源的 PolarDB for PostgreSQL 内核提供国产信创资质支持,与类似 Oracle RAC 的使用体验。

概览

Pigsty 允许使用 PolarDB 创建带有 “国产化信创资质” 的 PostgreSQL 集群!

PolarDB for PostgreSQL 当前以 PostgreSQL 17 为基线,Pigsty 中的 polar 模板、默认路径与扩展说明也已经同步到 PG17。任何兼容 PostgreSQL 线缆协议的客户端工具都可以访问 PolarDB 集群。

Pigsty 的 PGSQL 仓库中提供了 PolarDB PG 开源版安装包,但不会在 Pigsty 安装时下载到本地软件仓库。


安装

使用 Pigsty 内置模板:

./configure -c polar
./deploy.yml

变更摘要

项目旧文档 / 旧默认值当前值
内核基线PostgreSQL 15PostgreSQL 17
默认 PolarDB 路径/u01/polardb_pg/u01/polardb_pg_17
支持架构x86_64x86_64, aarch64
可用扩展数旧文档正文写为 61pg_available_extensions 查询结果为 93
复制用户要求replicator 需要 SUPERUSER保持不变

配置

以下参数需要针对 PolarDB 数据库集群进行特殊配置:

#----------------------------------#
# PGSQL & PolarDB
#----------------------------------#
pg_version: 17
pg_mode: polar
pg_packages: [ polardb, pgsql-common ]
pg_exporter_exclude_database: 'template0,template1,postgres,polardb_admin'
pg_default_roles:
  - { name: dbrole_readonly  ,login: false ,comment: role for global read-only access     }
  - { name: dbrole_offline   ,login: false ,comment: role for restricted read-only access }
  - { name: dbrole_readwrite ,login: false ,roles: [dbrole_readonly] ,comment: role for global read-write access }
  - { name: dbrole_admin     ,login: false ,roles: [pg_monitor, dbrole_readwrite] ,comment: role for object creation }
  - { name: postgres     ,superuser: true  ,comment: system superuser }
  - { name: replicator   ,superuser: true  ,replication: true ,roles: [pg_monitor, dbrole_readonly] ,comment: system replicator } # <- superuser is required for replication
  - { name: dbuser_dba   ,superuser: true  ,roles: [dbrole_admin]  ,pgbouncer: true ,pool_mode: session, pool_connlimit: 16 ,comment: pgsql admin user }
  - { name: dbuser_monitor ,roles: [pg_monitor] ,pgbouncer: true ,parameters: {log_min_duration_statement: 1000 } ,pool_mode: session ,pool_connlimit: 8 ,comment: pgsql monitor user }

默认 polar 内核安装目录已调整为 /u01/polardb_pg_17。这里特别注意,PolarDB PG 要求 replicator 复制用户为 SUPERUSER,与原生 PG 不同。


扩展列表

绝大多数 PGSQL 模块的 扩展插件(尤其是需要二进制编译的扩展)都不能直接复用在 PolarDB 内核上;如果需要使用,请针对 PolarDB 17 内核重新编译安装。

与旧文档相比,PolarDB PG 17 的扩展列表已经明显变化。旧文档正文写成 “61 个扩展”,但旧表格实际列出了 74 个条目;根据最新 SELECT * FROM pg_available_extensions; 查询结果,当前可用扩展为 93 个。

变化类型数量说明
新增扩展33新增了 pgauditpg_partmanpg_profilepg_repackpg_stat_kcachepg_jiebapg_cronpg_hint_planpg_walinspect,以及 polar_advisorpolar_feature_utilspolar_parameter_managerpolar_proxy_utilspolar_resource_managerpolar_smgrperf 等 PolarDB / 运维相关扩展。
移除扩展14旧文档中的 polar_csnpolar_pxpolar_stat_envpolar_stat_sqltimetravelsmlar 已不在当前 PG17 可用列表中;同时,多项 plpython2u / plpythonu 兼容扩展也一并移除。

PolarDB PG 17 最新完整扩展列表如下(按 pg_available_extensions 查询结果顺序整理):

namedefault_versioncomment
pg_jieba1.1.0a parser for full-text search of Chinese
polar_monitor1.3monitor functions for PolarDB
plpgsql1.0PL/pgSQL procedural language
cube1.5data type for multidimensional cubes
bool_plperl1.0transform between bool and plperl
pg_partman5.2.4Extension to manage partitioned tables by time or ID
pg_buffercache1.6examine the shared buffer cache
pgaudit17.1provides auditing functionality
pg_profile4.10PostgreSQL load profile repository and report builder
pg_stat_statements1.11track planning and execution statistics of all SQL statements executed
plperlu1.0PL/PerlU untrusted procedural language
fuzzystrmatch1.2determine similarities and distance between strings
pltcl1.0PL/Tcl procedural language
jsonb_plpython3u1.0transform between jsonb and plpython3u
polar_parameter_manager1.2Extension to select parameters for manger.
sequential_uuids1.0.3generator of sequential UUIDs
unaccent1.1text search dictionary that removes accents
autoinc1.0functions for autoincrementing fields
plpython3u1.0PL/Python3U untrusted procedural language
amcheck1.4functions for verifying relation integrity
pg_cron1.5Job scheduler for PostgreSQL
polar_advisor1.1polar_advisor
tsm_system_rows1.0TABLESAMPLE method which accepts number of rows as a limit
pase0.0.1ant ai similarity search
pg_squeeze1.9A tool to remove unused space from a relation.
dict_xsyn1.0text search dictionary template for extended synonym processing
prefix1.2.0Prefix Range module for PostgreSQL
ip4r2.4
ltree1.3data type for hierarchical tree-like structures
btree_gist1.7support for indexing common datatypes in GiST
hstore_plpython3u1.0transform between hstore and plpython3u
pg_cron_preload1.0polardb pg extend catalog
tablefunc1.0functions that manipulate whole tables, including crosstab
refint1.0functions for implementing referential integrity (obsolete)
pgtap1.3.3Unit testing for PostgreSQL
pgstattuple1.5show tuple-level statistics
polar_smgrperf1.0smgr perf test extension
pg_repack1.5.1-1Reorganize tables in PostgreSQL databases with minimal locks
file_fdw1.0foreign-data wrapper for flat file access
pg_stat_kcache2.3.0Kernel statistics gathering
pgcrypto1.3cryptographic functions
hll2.18type for storing hyperloglog data
pgrowlocks1.2show row-level locking information
intagg1.1integer aggregator and enumerator (obsolete)
sslinfo1.2information about SSL certificates
pg_trgm1.6text similarity measurement and index searching based on trigrams
isn1.2data types for international product numbering standards
ltree_plpython3u1.0transform between ltree and plpython3u
hstore1.8data type for storing sets of (key, value) pairs
hstore_plperlu1.0transform between hstore and plperlu
log_fdw1.4foreign-data wrapper for Postgres log file access
dblink1.2connect to other PostgreSQL databases from within a database
btree_gin1.3support for indexing common datatypes in GIN
dict_int1.0text search dictionary template for integers
polar_worker1.1polar_worker
polar_resource_manager1.0a background process that forcibly frees user session process memory
insert_username1.0functions for tracking who changed a table
polar_feature_utils1.0PolarDB feature utilization
polar_vfs1.0polar virtual file system for different storage
uuid-ossp1.1generate universally unique identifiers (UUIDs)
pg_walinspect1.1functions to inspect contents of PostgreSQL Write-Ahead Log
pldbgapi1.1server-side support for debugging PL/pgSQL functions
earthdistance1.2calculate great-circle distances on the surface of the Earth
polar_tde_utils1.0Internal extension for TDE
pageinspect1.12inspect the contents of database pages at a low level
seg1.4data type for representing line segments or floating-point intervals
pg_freespacemap1.2examine the free space map (FSM)
bloom1.0bloom access method - signature file based index
pg_similarity1.0support similarity queries
tsm_system_time1.0TABLESAMPLE method which accepts time in milliseconds as a limit
polar_monitor_preload1.0examine the polardb information
pg_bigm1.2text similarity measurement and index searching based on bigrams
pg_visibility1.2examine the visibility map (VM) and page-level visibility info
pg_surgery1.0extension to perform surgery on a damaged relation
pg_hint_plan1.7.0optimizer hints for PostgreSQL
postgres_fdw1.1foreign-data wrapper for remote PostgreSQL servers
lo1.1Large Object maintenance
polar_io_stat1.0polar io stat in multi dimension
jsonb_plperlu1.0transform between jsonb and plperlu
moddatetime1.0functions for tracking last modification time
pg_prewarm1.2prewarm relation data
plperl1.0PL/Perl procedural language
citext1.6data type for case-insensitive character strings
xml21.1XPath querying and XSLT
tcn1.0Triggered change notifications
bool_plperlu1.0transform between bool and plperlu
roaringbitmap0.5support for Roaring Bitmaps
polar_proxy_utils1.0Extension to provide operations about proxy.
hstore_plperl1.0transform between hstore and plperl
jsonb_plperl1.0transform between jsonb and plperl
varbitx1.1varbit functions pack
pltclu1.0PL/TclU untrusted procedural language
intarray1.5functions, operators, and index support for 1-D arrays of integers
  • Pigsty 专业版提供 PolarDB 离线安装支持,扩展插件编译支持,以及针对 PolarDB 集群进行专门适配的监控与管控支持。
  • Pigsty 与阿里云内核团队有合作,可以提供有偿内核兜底支持服务。

最后修改 2026-04-15: update config files (fc38c40)