From 00b754727d9b16b13de7591b07d5bf0635029c4b Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Wed, 24 Aug 2022 19:54:15 +0200 Subject: Add postgres + WIP plume + fix diplonat --- cluster/prod/app/postgres/build/docker-compose.yml | 9 ++++++++ .../0001-Add-max-rate-to-pg_basebackup.patch | 25 ++++++++++++++++++++++ .../prod/app/postgres/build/postgres/Dockerfile | 16 ++++++++++++++ .../app/postgres/build/postgres/postgresql.conf | 25 ++++++++++++++++++++++ 4 files changed, 75 insertions(+) create mode 100644 cluster/prod/app/postgres/build/docker-compose.yml create mode 100644 cluster/prod/app/postgres/build/postgres/0001-Add-max-rate-to-pg_basebackup.patch create mode 100644 cluster/prod/app/postgres/build/postgres/Dockerfile create mode 100644 cluster/prod/app/postgres/build/postgres/postgresql.conf (limited to 'cluster/prod/app/postgres/build') diff --git a/cluster/prod/app/postgres/build/docker-compose.yml b/cluster/prod/app/postgres/build/docker-compose.yml new file mode 100644 index 0000000..852dd7b --- /dev/null +++ b/cluster/prod/app/postgres/build/docker-compose.yml @@ -0,0 +1,9 @@ +version: '3.4' +services: + postgres: + build: + args: + # https://github.com/sorintlab/stolon/releases + STOLON_VERSION: 3bb7499f815f77140551eb762b200cf4557f57d3 + context: ./postgres + image: superboum/amd64_postgres:v11 diff --git a/cluster/prod/app/postgres/build/postgres/0001-Add-max-rate-to-pg_basebackup.patch b/cluster/prod/app/postgres/build/postgres/0001-Add-max-rate-to-pg_basebackup.patch new file mode 100644 index 0000000..9277ac4 --- /dev/null +++ b/cluster/prod/app/postgres/build/postgres/0001-Add-max-rate-to-pg_basebackup.patch @@ -0,0 +1,25 @@ +From c4e0e967752868626772a3317a17d25d181daeda Mon Sep 17 00:00:00 2001 +From: Quentin Dufour +Date: Thu, 15 Apr 2021 12:35:12 +0200 +Subject: [PATCH] Add max-rate to pg_basebackup + +--- + internal/postgresql/postgresql.go | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/internal/postgresql/postgresql.go b/internal/postgresql/postgresql.go +index 00c14bc..a37a28c 100644 +--- a/internal/postgresql/postgresql.go ++++ b/internal/postgresql/postgresql.go +@@ -963,7 +963,7 @@ func (p *Manager) SyncFromFollowed(followedConnParams ConnParams, replSlot strin + + log.Infow("running pg_basebackup") + name := filepath.Join(p.pgBinPath, "pg_basebackup") +- args := []string{"-R", "-v", "-P", "-Xs", "-D", p.dataDir, "-d", followedConnString} ++ args := []string{"-R", "-v", "-P", "--max-rate", "5M", "-Xs", "-D", p.dataDir, "-d", followedConnString} + if replSlot != "" { + args = append(args, "--slot", replSlot) + } +-- +2.30.2 + diff --git a/cluster/prod/app/postgres/build/postgres/Dockerfile b/cluster/prod/app/postgres/build/postgres/Dockerfile new file mode 100644 index 0000000..d7b3473 --- /dev/null +++ b/cluster/prod/app/postgres/build/postgres/Dockerfile @@ -0,0 +1,16 @@ +FROM golang:1.19.0-bullseye AS builder + +ARG STOLON_VERSION +WORKDIR /stolon +RUN git clone https://github.com/sorintlab/stolon . +RUN git pull && git checkout ${STOLON_VERSION} +RUN go mod download +COPY 0001-Add-max-rate-to-pg_basebackup.patch . +RUN git apply 0001-Add-max-rate-to-pg_basebackup.patch +RUN make && chmod +x /stolon/bin/* + +FROM postgres:14.5-bullseye +COPY --from=builder /stolon/bin /usr/local/bin +USER postgres +ENTRYPOINT [] +CMD ["/bin/bash"] diff --git a/cluster/prod/app/postgres/build/postgres/postgresql.conf b/cluster/prod/app/postgres/build/postgres/postgresql.conf new file mode 100644 index 0000000..8e0af2b --- /dev/null +++ b/cluster/prod/app/postgres/build/postgres/postgresql.conf @@ -0,0 +1,25 @@ +data_directory = '/var/lib/postgresql/9.6/main' # use data in another directory +hba_file = '/etc/postgresql/9.6/main/pg_hba.conf' # host-based authentication file +ident_file = '/etc/postgresql/9.6/main/pg_ident.conf' # ident configuration file +external_pid_file = '/var/run/postgresql/9.6-main.pid' # write an extra PID file +listen_addresses = '*' #listen on every ip / interfaces +port = 5432 # (change requires restart) +max_connections = 100 # (change requires restart) +unix_socket_directories = '/var/run/postgresql' # comma-separated list of directories +ssl = true # (change requires restart) +ssl_cert_file = '/etc/ssl/certs/ssl-cert-snakeoil.pem' # (change requires restart) +ssl_key_file = '/etc/ssl/private/ssl-cert-snakeoil.key' # (change requires restart) +shared_buffers = 128MB # min 128kB +dynamic_shared_memory_type = posix # the default is the first option +log_line_prefix = '%m [%p] %q%u@%d ' # special values: +log_timezone = 'UTC' +cluster_name = '9.6/main' # added to process titles if nonempty +stats_temp_directory = '/var/run/postgresql/9.6-main.pg_stat_tmp' +datestyle = 'iso, mdy' +timezone = 'UTC' +lc_messages = 'C.UTF-8' # locale for system error message +lc_monetary = 'C.UTF-8' # locale for monetary formatting +lc_numeric = 'C.UTF-8' # locale for number formatting +lc_time = 'C.UTF-8' # locale for time formatting +default_text_search_config = 'pg_catalog.english' + -- cgit v1.2.3