Skip to content

Commit

Permalink
DISTPG-667 Run in a Docker doc (15) (#470)
Browse files Browse the repository at this point in the history
DISTPG-667 Run in a Docker doc (15)

Reworked install section to include Docker

modified:   docs/apt.md
	new file:   docs/docker.md
	modified:   docs/installing.md
	modified:   docs/repo-overview.md
	modified:   docs/yum.md
	modified:   mkdocs-base.yml
	new file:   snippets/supported-versions.md
	modified:   variables.yml
  • Loading branch information
nastena1606 authored Nov 30, 2023
1 parent d14c5da commit b0a6592
Show file tree
Hide file tree
Showing 10 changed files with 329 additions and 126 deletions.
33 changes: 32 additions & 1 deletion _resource/overrides/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,35 @@ <h1>{{ page.title | d(config.site_name, true)}}</h1>
{% endif %}
{% endblock %}


{% block site_nav %}
{% if nav %}
{% if page.meta and page.meta.hide %}
{% set hidden = "hidden" if "navigation" in page.meta.hide %}
{% endif %}
<div class="md-sidebar md-sidebar--primary" data-md-component="sidebar" data-md-type="navigation" {{ hidden }}>
<div class="md-sidebar__scrollwrap">
<div class="md-sidebar__inner">
{% include "partials/nav.html" %}
<br>
<label class="md-nav__title" for="__drawer">
<a href="https://learn.percona.com/download-manual-percona-distribution-for-postgresql-15" onclick="_gaq.push(['b._trackEvent', 'Percona Distribution for PostgreSQL 15', 'Download', 'Download Manual Percona Distribution for PostgreSQL 15']);" class="md-nav__link md-nav__link--active" style="font-size: .7rem;">
Download PDF
</a>
</label>
</div>
</div>
</div>
{% endif %}
{% if "toc.integrate" not in features %}
{% if page.meta and page.meta.hide %}
{% set hidden = "hidden" if "toc" in page.meta.hide %}
{% endif %}
<div class="md-sidebar md-sidebar--secondary" data-md-component="sidebar" data-md-type="toc" {{ hidden }}>
<div class="md-sidebar__scrollwrap">
<div class="md-sidebar__inner">
{% include "partials/toc.html" %}
</div>
</div>
</div>
{% endif %}
{% endblock %}
36 changes: 0 additions & 36 deletions _resource/overrides/partials/nav.html

This file was deleted.

21 changes: 11 additions & 10 deletions docs/apt.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Install Percona Distribution for PostgreSQL on Debian and Ubuntu

This document describes how to install Percona Server for PostgreSQL from Percona repositories on DEB-based distributions such as Debian and Ubuntu.
This document describes how to install Percona Server for PostgreSQL from Percona repositories on DEB-based distributions such as Debian and Ubuntu. [Read more about Percona repositories :material-arrow-top-right:](repo-overview.md).

## Preconditions

Expand Down Expand Up @@ -37,40 +37,40 @@ Run all the commands in the following sections as root or using the `sudo` comma

Percona provides [two repositories](repo-overview.md) for Percona Distribution for PostgreSQL. We recommend enabling the Major release repository to timely receive the latest updates.

To enable a repository, we recommend using the `setup` command:

```{.bash data-prompt="$"}
$ sudo percona-release setup ppg-15
$ sudo percona-release setup ppg-{{pgversion}}
```

### Install packages

=== "Install using meta-package"

The [meta package](repo-overview.md#percona-ppg-server){:target=”_blank”} enables you to install several components of the distribution in one go.

```{.bash data-prompt="$"}
$ sudo apt install percona-ppg-server-15
$ sudo apt install percona-ppg-server-{{pgversion}}
```

=== "Install packages individually"

1. Install the PostgreSQL server package:

```{.bash data-prompt="$"}
$ sudo apt install percona-postgresql-15
$ sudo apt install percona-postgresql-{{pgversion}}
```

2. Install the components:

Install `pg_repack`:

```{.bash data-prompt="$"}
$ sudo apt install percona-postgresql-15-repack
$ sudo apt install percona-postgresql-{{pgversion}}-repack
```

Install `pgAudit`:

```{.bash data-prompt="$"}
$ sudo apt install percona-postgresql-15-pgaudit
$ sudo apt install percona-postgresql-{{pgversion}}-pgaudit
```

Install `pgBackRest`:
Expand All @@ -97,7 +97,7 @@ Run all the commands in the following sections as root or using the `sudo` comma
Install `pgAudit-set_user`:

```{.bash data-prompt="$"}
$ sudo apt install percona-pgaudit15-set-user
$ sudo apt install percona-pgaudit{{pgversion}}-set-user
```

Install `pgBadger`:
Expand All @@ -109,7 +109,7 @@ Run all the commands in the following sections as root or using the `sudo` comma
Install `wal2json`:

```{.bash data-prompt="$"}
$ sudo apt install percona-postgresql-15-wal2json
$ sudo apt install percona-postgresql-{{pgversion}}-wal2json
```

Install PostgreSQL contrib extensions:
Expand Down Expand Up @@ -177,3 +177,4 @@ $ \q



[^1]: Are included in repositories for Debian 12 operating system
168 changes: 168 additions & 0 deletions docs/docker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
# Run Percona Distribution for PostgreSQL in a Docker container

Docker images of Percona Distribution for PostgreSQL are hosted publicly on [Docker Hub](https://hub.docker.com/r/percona/percona-distribution-postgresql/).

For more information about using Docker, see the [Docker Docs](https://docs.docker.com/).

!!! note ""

Make sure that you are using the latest version of Docker. The ones provided via `apt` and `yum` may be outdated and cause errors.

By default, Docker pulls the image from Docker Hub if it is not available locally.

???+ admonition "Docker image contents"

The Docker image of Percona Distribution for PostgreSQL includes the following components:

| Component name | Description |
|-------------------------------|--------------------------------------|
| `percona-postgresql{{pgversion}}`| A metapackage that installs the latest version of PostgreSQL|
| `percona-postgresql{{pgversion}}-server` | The PostgreSQL server package. |
| `percona-postgresql-common` | PostgreSQL database-cluster manager. It provides a structure under which multiple versions of PostgreSQL may be installed and/or multiple clusters maintained at one time.|
| `percona-postgresql-client-common`| The manager for multiple PostgreSQL client versions.|
| `percona-postgresql{{pgversion}}-contrib` | A collection of additional PostgreSQLcontrib extensions |
| `percona-postgresql{{pgversion}}-libs`| Libraries for use with PostgreSQL.|
| `percona-pg-stat-monitor{{pgversion}}` | A Query Performance Monitoring tool for PostgreSQL. |
| `percona-pgaudit{{pgversion}}` | Provides detailed session or object audit logging via the standard PostgreSQL logging facility. |
| `percona-pgaudit{{pgversion}}_set_user`| An additional layer of logging and control when unprivileged users must escalate themselves to superuser or object owner roles in order to perform needed maintenance tasks.|
| `percona-pg_repack{{pgversion}}`| rebuilds PostgreSQL database objects.|
| `percona-wal2json{{pgversion}}` | a PostgreSQL logical decoding JSON output plugin.|

## Start the container

1. Start a Percona Distribution for PostgreSQL container as follows:

```{.bash data-prompt="$"}
$ docker run --name container-name -e POSTGRES_PASSWORD=secret -d percona/percona-distribution-postgresql:tag
```

Where:

* `container-name` is the name you assign to your container
* `POSTGRES_PASSWORD` is the superuser password
* `tag` is the tag specifying the version you want.

Check the [full list of tags](https://hub.docker.com/r/percona/percona-distribution-postgresql/tags/).


!!! tip

You can secure the password by exporting it to the environment file and using that to start the container.

1. Export the password to the environment file:

```{.bash data-prompt="$"}
$ echo "POSTGRES_PASSWORD=secret" > .my-pg.env
```

2. Start the container:

```{.bash data-prompt="$"}
$ docker run --name container-name --env-file ./.my-pg.env -d percona/percona-distribution-postgresql:tag
```

2. Connect to the container's interactive terminal:
```{.bash data-prompt="$"}
$ docker exec -it container-name bash
```
The `container-name` is the name of the container that you started in the previous step.
## Connect to Percona Distribution for PostgreSQL from an application in another Docker container
This image exposes the standard PostgreSQL port (`5432`), so container linking makes the instance available to other containers. Start other containers like this in order to link it to the Percona Distribution for PostgreSQL container:
```{.bash data-prompt="$"}
$ docker run --name app-container-name --network container:container-name -d app-that-uses-postgresql
```
where:
* `app-container-name` is the name of the container where your application is running,
* `container name` is the name of your Percona Distribution for PostgreSQL container, and
* `app-that-uses-postgresql` is the name of your PostgreSQL client.
## Connect to Percona Distribution for PostgreSQL from the `psql` command line client
The following command starts another container instance and runs the `psql` command line client against your original container, allowing you to execute SQL statements against your database:
```{.bash data-prompt="$"}
$ docker run -it --network container:db-container-name --name container-name percona/percona-distribution-postgresql:tag psql -h address -U postgres
```
Where:
* `db-container-name` is the name of your database container
* `container-name` is the name of your container that you will use to connect to the database container using the `psql` command line client
* `tag` is the tag specifying the Docker image version you want to use.
* `address` is the network address where your database container is running. Use 127.0.0.1, if the database container is running on the local machine/host.
## Enable `pg_stat_monitor`
To enable the `pg_stat_monitor` extension after launching the container, do the following:
* connect to the server,
* select the desired database and enable the `pg_stat_monitor` view for that database:
```sql
create extension pg_stat_monitor;
```
* to ensure that everything is set up correctly, run:
```sql
\d pg_stat_monitor;
```
??? example "Output"
```
View "public.pg_stat_monitor"
Column | Type | Collation | Nullable | Default
---------------------+--------------------------+-----------+----------+---------
bucket | integer | | |
bucket_start_time | timestamp with time zone | | |
userid | oid | | |
dbid | oid | | |
queryid | text | | |
query | text | | |
plan_calls | bigint | | |
plan_total_time | numeric | | |
plan_min_timei | numeric | | |
plan_max_time | numeric | | |
plan_mean_time | numeric | | |
plan_stddev_time | numeric | | |
plan_rows | bigint | | |
calls | bigint | | |
total_time | numeric | | |
min_time | numeric | | |
max_time | numeric | | |
mean_time | numeric | | |
stddev_time | numeric | | |
rows | bigint | | |
shared_blks_hit | bigint | | |
shared_blks_read | bigint | | |
shared_blks_dirtied | bigint | | |
shared_blks_written | bigint | | |
local_blks_hit | bigint | | |
local_blks_read | bigint | | |
local_blks_dirtied | bigint | | |
local_blks_written | bigint | | |
temp_blks_read | bigint | | |
temp_blks_written | bigint | | |
blk_read_time | double precision | | |
blk_write_time | double precision | | |
host | bigint | | |
client_ip | inet | | |
resp_calls | text[] | | |
cpu_user_time | double precision | | |
cpu_sys_time | double precision | | |
tables_names | text[] | | |
wait_event | text | | |
wait_event_type | text | | |
```
Note that the `pg_stat_monitor` view is available only for the databases where you enabled it. If you create a new database, make sure to create the view for it to see its statistics data.
Loading

0 comments on commit b0a6592

Please sign in to comment.