PIGSTY

PolarDB

PolarDB for PostgreSQL,带有 aurora 风格的 RAC

PolarDB 是一个由阿里云开发并开源的 aurora RAC 风格"云原生"数据库系统。

当前仓库中的最新版本 v15.15.5.0 与 PostgreSQL 15 兼容,在所有 Pigsty 支持的操作系统上都可用。


快速开始

使用 polar 配置模板 安装 Pigsty。

curl -fsSL https://repo.pigsty.io/get | bash; cd ~/pigsty;
./configure -c polar     # 使用 polar(PolarDB)模板
./install.yml            # 运行部署剧本

配置

需要调整以下参数来部署 PolarDB 集群:

pg-meta:
  hosts:
    10.10.10.10: { pg_seq: 1, pg_role: primary }
  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 for meta database }
    pg_databases:
      - {name: meta ,baseline: cmdb.sql ,comment: pigsty meta database ,schemas: [pigsty]}
    pg_hba_rules:
      - {user: dbuser_view , db: all ,addr: infra ,auth: pwd ,title: 'allow grafana dashboard access cmdb from infra nodes'}
    node_crontab: [ '00 01 * * * postgres /pg/bin/pg-backup full' ] # 每天凌晨 1 点进行全量备份

    # PolarDB 临时设置
    pg_version: 15                            # PolarDB PG 基于 PG 15
    pg_mode: polar                            # PolarDB PG 兼容模式
    pg_packages: [ polardb, pgsql-common ]    # 用 PolarDB 内核替换 PG 内核
    pg_exporter_exclude_database: 'template0,template1,postgres,polardb_admin'
    pg_default_roles:                         # PolarDB 要求 replicator 为超级用户
      - { 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 } # <- 复制需要超级用户权限
      - { 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 }

PolarDB for PostgreSQL 本质上等价于 PostgreSQL 15,任何与 PostgreSQL 线协议兼容的客户端工具都可以访问 PolarDB 集群。

扩展

PGSQL 模块的大多数扩展(非纯 SQL)不能直接在 PolarDB 内核上使用。如果您需要使用它们,您需要为新内核从源代码重新编译和安装。

这是 PolarDB 内核提供的扩展列表:

nameVersioncomment
adminpack2.1administrative functions for PostgreSQL
amcheck1.3functions for verifying relation integrity
autoinc1.0functions for autoincrementing fields
bloom1.0bloom access method - signature file based index
bool_plperl1.0transform between bool and plperl
bool_plperlu1.0transform between bool and plperlu
btree_gin1.3support for indexing common datatypes in GIN
btree_gist1.7support for indexing common datatypes in GiST
citext1.6data type for case-insensitive character strings
cube1.5data type for multidimensional cubes
dblink1.2connect to other PostgreSQL databases from within a database
dict_int1.0text search dictionary template for integers
dict_xsyn1.0text search dictionary template for extended synonym processing
earthdistance1.1calculate great-circle distances on the surface of the Earth
file_fdw1.0foreign-data wrapper for flat file access
fuzzystrmatch1.1determine similarities and distance between strings
hll2.18type for storing hyperloglog data
hstore1.8data type for storing sets of (key, value) pairs
hstore_plperl1.0transform between hstore and plperl
hstore_plperlu1.0transform between hstore and plperlu
hstore_plpython3u1.0transform between hstore and plpython3u
hypopg1.3.1Hypothetical indexes for PostgreSQL
insert_username1.0functions for tracking who changed a table
intagg1.1integer aggregator and enumerator (obsolete)
intarray1.5functions, operators, and index support for 1-D arrays of integers
isn1.2data types for international product numbering standards
jsonb_plperl1.0transform between jsonb and plperl
jsonb_plperlu1.0transform between jsonb and plperlu
jsonb_plpython3u1.0transform between jsonb and plpython3u
lo1.1Large Object maintenance
log_fdw1.4foreign-data wrapper for Postgres log file access
ltree1.2data type for hierarchical tree-like structures
ltree_plpython3u1.0transform between ltree and plpython3u
moddatetime1.0functions for tracking last modification time
old_snapshot1.0utilities in support of old_snapshot_threshold
pageinspect1.11inspect the contents of database pages at a low level
pase0.0.1ant ai similarity search
pg_bigm1.2text similarity measurement and index searching based on bigrams
pg_buffercache1.4examine the shared buffer cache
pg_freespacemap1.2examine the free space map (FSM)
pg_jieba1.1.0a parser for full-text search of Chinese
pg_prewarm1.2prewarm relation data
pg_repack1.5.1-1Reorganize tables in PostgreSQL databases with minimal locks
pg_stat_statements1.10track planning and execution statistics of all SQL statements executed
pg_surgery1.0extension to perform surgery on a damaged relation
pg_trgm1.6text similarity measurement and index searching based on trigrams
pg_visibility1.2examine the visibility map (VM) and page-level visibility info
pg_walinspect1.0functions to inspect contents of PostgreSQL Write-Ahead Log
pgcrypto1.3cryptographic functions
pgrowlocks1.2show row-level locking information
pgstattuple1.5show tuple-level statistics
plperl1.0PL/Perl procedural language
plperlu1.0PL/PerlU untrusted procedural language
plpgsql1.0PL/pgSQL procedural language
plpython3u1.0PL/Python3U untrusted procedural language
pltcl1.0PL/Tcl procedural language
pltclu1.0PL/TclU untrusted procedural language
polar_audit1.0provides auditing functionality
polar_feature_utils1.0PolarDB feature utilization
polar_io_stat1.0polar io stat in multi dimension
polar_login_history1.0record user login information
polar_masking1.0.0provides data masking for polardb
polar_monitor1.0monitor functions for PolarDB
polar_monitor_preload1.0examine the polardb information
polar_parameter_manager1.1Extension to select parameters for manger.
polar_password_policy1.0create password policies and check user passwords based on the policies
polar_proxy_utils1.0Extension to provide operations about proxy.
polar_resource_manager1.0a background process that forcibly frees user session process memory
polar_smgrperf1.0smgr perf test extension
polar_sql_mapping1.0Record error sqls and mapping them to correct one
polar_stat_env1.0env stat functions for PolarDB
polar_vfs1.0polar virtual file system for different storage
polar_worker1.0polar_worker
postgres_fdw1.1foreign-data wrapper for remote PostgreSQL servers
refint1.0functions for implementing referential integrity (obsolete)
roaringbitmap0.5support for Roaring Bitmaps
seg1.4data type for representing line segments or floating-point intervals
sslinfo1.2information about SSL certificates
tablefunc1.0functions that manipulate whole tables, including crosstab
tcn1.0Triggered change notifications
tsm_system_rows1.0TABLESAMPLE method which accepts number of rows as a limit
tsm_system_time1.0TABLESAMPLE method which accepts time in milliseconds as a limit
unaccent1.1text search dictionary that removes accents
uuid-ossp1.1generate universally unique identifiers (UUIDs)
vector0.6.2vector data type and ivfflat and hnsw access methods
xml21.1XPath querying and XSLT

PolarDB for Oracle

还有 PolarDB 的第二个分支,即 PolarDB for Oracle,它不是开源的。

Pigsty Pro 支持将 PolarDB for Oracle 作为 RDS 运行。