|
| 1 | +:sectnums: |
| 2 | +:sectnumlevels: 5 |
| 3 | + |
| 4 | += PoWA |
| 5 | + |
| 6 | +== Overview |
| 7 | + |
| 8 | +PoWA (PostgreSQL Workload Analyzer) collects workload statistics and presents them through a web interface. A complete deployment can contain: |
| 9 | + |
| 10 | +* `powa-archivist`, the database extension that stores and aggregates metrics; |
| 11 | +* `powa-web`, the visualization interface; |
| 12 | +* `powa-collector`, the optional daemon used to collect multiple remote servers. |
| 13 | + |
| 14 | +`pg_stat_statements` is the mandatory primary data source. Other statistics extensions are optional. |
| 15 | + |
| 16 | +This guide was validated on x86_64 Linux with IvorySQL 5.4 (PostgreSQL 18.4) and PoWA Archivist 5.3.0. The extension built without source changes, and all eight upstream PostgreSQL regression tests passed. |
| 17 | + |
| 18 | +== Choose a deployment mode |
| 19 | + |
| 20 | +In *local mode*, PoWA's background worker collects and stores metrics in the monitored IvorySQL instance. This is simple for evaluation, but collection, storage, and visualization queries add load to that instance. |
| 21 | + |
| 22 | +In *remote mode*, `powa-collector` reads statistics from monitored instances and writes them to a dedicated repository. This is the recommended production architecture because it moves storage and visualization overhead away from monitored databases and can monitor read-only standbys. |
| 23 | + |
| 24 | +== Build PoWA Archivist |
| 25 | + |
| 26 | +Install the IvorySQL server development files, then build against the matching `pg_config`: |
| 27 | + |
| 28 | +[source,bash] |
| 29 | +---- |
| 30 | +git clone --branch REL_5_3_0 --depth 1 \ |
| 31 | + https://github.com/powa-team/powa-archivist.git |
| 32 | +cd powa-archivist |
| 33 | +
|
| 34 | +make PG_CONFIG=/path-to/ivorysql/bin/pg_config |
| 35 | +sudo make PG_CONFIG=/path-to/ivorysql/bin/pg_config install |
| 36 | +---- |
| 37 | + |
| 38 | +Run the upstream regression suite against a test instance: |
| 39 | + |
| 40 | +[source,bash] |
| 41 | +---- |
| 42 | +PGUSER=ivorysql PGPORT=5432 \ |
| 43 | + make PG_CONFIG=/path-to/ivorysql/bin/pg_config installcheck |
| 44 | +---- |
| 45 | + |
| 46 | +== Configure local mode |
| 47 | + |
| 48 | +Append `pg_stat_statements` and `powa` to the existing `shared_preload_libraries` value in `ivorysql.conf`. Preserve the IvorySQL libraries already configured: |
| 49 | + |
| 50 | +[source,conf] |
| 51 | +---- |
| 52 | +shared_preload_libraries = 'gb18030_2022, liboracle_parser, ivorysql_ora, pg_stat_statements, powa' |
| 53 | +track_io_timing = on |
| 54 | +---- |
| 55 | + |
| 56 | +Restart IvorySQL, create a dedicated database, and install the required extensions through the PostgreSQL-compatible port: |
| 57 | + |
| 58 | +[source,bash] |
| 59 | +---- |
| 60 | +pg_ctl restart -D /path-to/data |
| 61 | +createdb -p 5432 powa |
| 62 | +psql -p 5432 -d powa |
| 63 | +---- |
| 64 | + |
| 65 | +[source,sql] |
| 66 | +---- |
| 67 | +CREATE EXTENSION pg_stat_statements; |
| 68 | +CREATE EXTENSION btree_gist; |
| 69 | +CREATE EXTENSION powa; |
| 70 | +---- |
| 71 | + |
| 72 | +Generate a small workload and confirm that a snapshot captures statements: |
| 73 | + |
| 74 | +[source,sql] |
| 75 | +---- |
| 76 | +SELECT sum(i) FROM generate_series(1, 100) AS g(i); |
| 77 | +SELECT powa_take_snapshot(); |
| 78 | +
|
| 79 | +SELECT count(*) > 0 AS captured_statements |
| 80 | +FROM powa_statements_history_current; |
| 81 | +---- |
| 82 | + |
| 83 | +Install and configure `powa-web` with a PostgreSQL DSN pointing to the `powa` database to view dashboards. Place the web service behind an authenticated TLS reverse proxy in production. |
| 84 | + |
| 85 | +== Remote mode |
| 86 | + |
| 87 | +For production or multiple monitored instances, install PoWA Archivist in a dedicated repository and run `powa-collector`. Each monitored IvorySQL instance still needs `pg_stat_statements` loaded and created. Register monitored servers with PoWA's remote-server API, then configure the collector with the repository DSN. |
| 88 | + |
| 89 | +Avoid storing plaintext passwords in `powa_servers`. Prefer a supported libpq authentication method such as certificates or a protected password file. Use a monitoring role with `pg_read_all_stats` instead of a superuser where possible. |
| 90 | + |
| 91 | +== Oracle-compatible mode |
| 92 | + |
| 93 | +[IMPORTANT] |
| 94 | +==== |
| 95 | +Install and operate PoWA's collection path through the PostgreSQL-compatible port. On IvorySQL 5.4, creating the prerequisites directly through the Oracle-compatible port fails because their upstream installation scripts use PostgreSQL syntax. Calling `powa_take_snapshot()` after switching an interactive session to Oracle mode can also encounter identifier-folding differences. These limitations do not affect PostgreSQL-mode background collection or a PoWA Web connection using the PostgreSQL port. |
| 96 | +==== |
| 97 | + |
| 98 | +An Oracle-compatible session can still query workload tables with explicitly quoted schema and object names when required, but administrative setup and snapshot operations should remain in PostgreSQL mode. |
| 99 | + |
| 100 | +See the https://powa.readthedocs.io/en/latest/architecture.html[PoWA architecture documentation] for local and remote designs, and the https://powa.readthedocs.io/en/latest/security.html[PoWA security guidance] before production deployment. |
0 commit comments