Skip to content

Commit

Permalink
Добавлены новые версии контейнеров
Browse files Browse the repository at this point in the history
  • Loading branch information
sergey grinko committed Feb 14, 2024
1 parent 7be47cd commit 58e463e
Show file tree
Hide file tree
Showing 155 changed files with 8,169 additions and 546 deletions.
2 changes: 1 addition & 1 deletion 12/backup-service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ services:
EMAIL_SERVER: "mail.company.ru"
EMAIL_HOSTNAME: "[email protected]"
BACKUP_THREADS: "4"
BACKUP_MODE: "page"
BACKUP_MODE: ""
BACKUP_STREAM: "yes"
1 change: 1 addition & 0 deletions 12/bin/clear_all_docker.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
# docker system prune -a # чистка всех образов в каталоге /var/lib/docker/overlay2
docker stop $(docker ps -q)
docker rm -v $(docker ps -aq -f status=exited)
docker rmi $(docker image ls -q) -f
Expand Down
2 changes: 1 addition & 1 deletion 12/bin/docker_start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ docker run -p 127.0.0.1:5433:5432/tcp --shm-size 2147483648 \
-e POSTGRES_HOST_AUTH_METHOD=trust \
-e DEPLOY_PASSWORD=postgres \
-e TZ="Etc/UTC" \
grufos/postgres:12.17 \
grufos/postgres:12.18 \
-c shared_preload_libraries="plugin_debugger,plpgsql_check,pg_stat_statements,auto_explain,pg_buffercache,pg_cron,shared_ispell,pg_prewarm" \
-c shared_ispell.max_size=70MB
2 changes: 1 addition & 1 deletion 12/bin/harbor_push.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
VERSION=12
MINOR=17
VERS_BOUNCER="1.21.0"
VERS_BOUNCER="1.22.0"
VERS_PROBACKUP="2.5.13"
VERS_MAMONSU="3.5.5"
PROJECT=dba_postgres
Expand Down
2 changes: 1 addition & 1 deletion 12/bin/hub_push.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
VERSION=12
MINOR=17
VERS_BOUNCER="1.21.0"
VERS_BOUNCER="1.22.0"
VERS_PROBACKUP="2.5.13"
VERS_MAMONSU="3.5.5"
ACCOUNT=grufos
Expand Down
2 changes: 1 addition & 1 deletion 12/docker-mamonsu/bootstrap_post.sql
Original file line number Diff line number Diff line change
@@ -1 +1 @@
select 'GRANT EXECUTE ON FUNCTION mamonsu.' || proname || '() TO mamonsu;' from pg_proc where pronamespace = 'mamonsu'::regnamespace \gexec
select 'GRANT EXECUTE ON FUNCTION mamonsu.' || oid::regprocedure || ' TO mamonsu;' from pg_proc where pronamespace = 'mamonsu'::regnamespace \gexec
164 changes: 82 additions & 82 deletions 12/docker-mamonsu/metrics.ru.md

Large diffs are not rendered by default.

35 changes: 25 additions & 10 deletions 12/docker-pgprobackup/backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,16 @@ if [ "$BACKUP_THREADS" = "" ]; then
BACKUP_THREADS=4
fi

if [ "$BACKUP_MODE" = "" ]; then
BACKUP_MODE=page
fi

if [ "$DOW" = "6" ] ; then
# make a full backup once a week (Saturday)
BACKUP_MODE=full
BACKUPMODE=full
else
# make an incremental backup on other days of the week
BACKUPMODE=page
fi
if [ "$BACKUP_MODE" != "" ]; then
# The backup creation mode is given forcibly
BACKUPMODE=$BACKUP_MODE
fi

if [ "$BACKUP_STREAM" = "" ]; then
Expand Down Expand Up @@ -70,21 +73,33 @@ if ! [ -f $PGDATA/archive_active.trigger ] ; then
touch $PGDATA/archive_active.trigger
fi

if [[ "$IS_FULL" = "" || $BACKUP_MODE = "full" ]] ; then
if [[ "$IS_FULL" = "" || $BACKUPMODE = "full" ]] ; then
echo "The initial backup must be type FULL ..."
/usr/bin/pg_probackup-$PG_MAJOR backup -d postgres --backup-path=$BACKUP_PATH -b full $BACKUP_STREAM --instance=$PG_MAJOR -w --threads=$BACKUP_THREADS --delete-expired --delete-wal
/usr/bin/pg_probackup-$PG_MAJOR backup -d postgres --backup-path=$BACKUP_PATH -b full $BACKUP_STREAM --instance=$PG_MAJOR -w --threads=$BACKUP_THREADS
else
# Backup type depends on day or input parameter
/usr/bin/pg_probackup-$PG_MAJOR backup --backup-path=$BACKUP_PATH -b $BACKUP_MODE $BACKUP_STREAM --instance=$PG_MAJOR -w --threads=$BACKUP_THREADS --delete-expired --delete-wal
if [[ $BACKUPMODE = "merge" ]]; then
# в этом режиме здесь всегда PAGE
/usr/bin/pg_probackup-$PG_MAJOR backup --backup-path=$BACKUP_PATH -b page $BACKUP_STREAM --instance=$PG_MAJOR -w --threads=$BACKUP_THREADS
else
/usr/bin/pg_probackup-$PG_MAJOR backup --backup-path=$BACKUP_PATH -b $BACKUPMODE $BACKUP_STREAM --instance=$PG_MAJOR -w --threads=$BACKUP_THREADS
fi
STATUS=`/usr/bin/pg_probackup-$PG_MAJOR show --backup-path=$BACKUP_PATH --instance=$PG_MAJOR --format=json | jq -c '.[].backups[0].status'`
LAST_STATE=${STATUS//'"'/''}
if [[ "$LAST_STATE" = "CORRUPT" || "$LAST_STATE" = "ERROR" || "$LAST_STATE" = "ORPHAN" ]] ; then
# You need to run a full backup, as an error occurred with incremental
# Perhaps the loss of the segment at Failover ...
/usr/bin/pg_probackup-$PG_MAJOR backup --backup-path=$BACKUP_PATH -b full $BACKUP_STREAM --instance=$PG_MAJOR -w --threads=$BACKUP_THREADS --delete-expired --delete-wal
/usr/bin/pg_probackup-$PG_MAJOR backup --backup-path=$BACKUP_PATH -b full $BACKUP_STREAM --instance=$PG_MAJOR -w --threads=$BACKUP_THREADS
fi
fi

if [[ $BACKUPMODE = "merge" ]] ; then
# объединяем старые бэкапы в соответствии с настройками
/usr/bin/pg_probackup-$PG_MAJOR delete --backup-path=$BACKUP_PATH --instance=$PG_MAJOR --delete-expired --delete-wal --merge-expired --no-validate --threads=$BACKUP_THREADS
else
# чистим старые бэкапы в соответствии с настройками
/usr/bin/pg_probackup-$PG_MAJOR delete --backup-path=$BACKUP_PATH --instance=$PG_MAJOR --delete-expired --delete-wal --threads=$BACKUP_THREADS
fi

# collecting statistics on backups
/usr/bin/pg_probackup-$PG_MAJOR show --backup-path=$BACKUP_PATH > ~postgres/backups.txt
/usr/bin/pg_probackup-$PG_MAJOR show --backup-path=$BACKUP_PATH --archive >> ~postgres/backups.txt
Expand Down
8 changes: 4 additions & 4 deletions 12/docker-postgres/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# https://hub.docker.com/r/postgis/postgis
# https://github.com/postgis/docker-postgis
#
FROM postgres:12.17
FROM postgres:12.18

LABEL maintainer="Sergey Grinko <[email protected]>"

Expand All @@ -16,7 +16,7 @@ ENV BACKUP_PATH /mnt/pgbak
ENV POSTGRES_INITDB_ARGS "--locale=ru_RU.UTF8 --data-checksums"
ENV RUM_VERSION 1.3.13

RUN localedef -i ru_RU -c -f UTF-8 -A /usr/share/locale/locale.alias ru_RU.UTF-8 \
RUN echo ru_RU.UTF-8 UTF-8 >> /etc/locale.gen; locale-gen \
&& apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates jq wget freetds-dev freetds-common git make gcc postgresql-server-dev-$PG_MAJOR libicu-dev sendemail htop mc systemtap-sdt-dev vim \
# подключаем репозитарий архивной утилиты
Expand Down Expand Up @@ -64,7 +64,7 @@ RUN localedef -i ru_RU -c -f UTF-8 -A /usr/share/locale/locale.alias ru_RU.UTF-8
&& make USE_PGXS=1 install \
# ====== pg_variables
&& cd /tmp/build_ext \
&& git clone https://github.com/postgrespro/pg_variables \
&& git clone https://github.com/xinferum/pg_variables \
&& cd pg_variables \
&& make USE_PGXS=1 \
&& make USE_PGXS=1 install \
Expand Down Expand Up @@ -102,7 +102,7 @@ RUN localedef -i ru_RU -c -f UTF-8 -A /usr/share/locale/locale.alias ru_RU.UTF-8
&& cd / \
&& ln -s /usr/share/postgresql/$PG_MAJOR/tsearch_data /usr/share/postgresql/ \
# ====== clean all unused package...
&& apt-get purge -y git* mariadb* make gcc gcc-12 cpp cpp-12 clang* golang* postgresql-server-dev-$PG_MAJOR *-dev *-man \
&& apt-get purge -y make gcc gcc-12 cpp cpp-12 clang* golang* postgresql-server-dev-$PG_MAJOR *-dev *-man \
&& apt-get -f install \
&& apt-get -y autoremove \
&& apt-get -y clean \
Expand Down
34 changes: 20 additions & 14 deletions 12/docker-postgres/backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ if [ "$BACKUP_THREADS" = "" ]; then
BACKUP_THREADS=4
fi

if [ "$BACKUP_MODE" = "" ]; then
BACKUP_MODE=page
fi

if [ "$BACKUP_STREAM" = "" ]; then
BACKUP_STREAM="stream"
fi
Expand All @@ -51,15 +47,14 @@ fi

if [ "$DOW" = "6" ] ; then
# make a full backup once a week (Saturday)
BACKUP_MODE=full
BACKUPMODE=full
else
# make an incremental backup on other days of the week
BACKUP_MODE=page
BACKUPMODE=page
fi

if [ "$1" != "" ]; then
if [ "$BACKUP_MODE" != "" ]; then
# The backup creation mode is given forcibly
BACKUP_MODE=$1
BACKUPMODE=$BACKUP_MODE
fi

BACKUP_STREAM="--stream"
Expand All @@ -75,7 +70,6 @@ if [ "$3" != "" ]; then
BACKUP_THREADS=$3
fi


cd $BACKUP_PATH

COUNT_DIR=`ls -l $BACKUP_PATH | grep "^d" | wc -l`
Expand All @@ -98,21 +92,33 @@ if ! [ -f $PGDATA/archive_active.trigger ] ; then
su - postgres -c "touch $PGDATA/archive_active.trigger"
fi

if [[ "$IS_FULL" = "" || $BACKUP_MODE = "full" ]] ; then
if [[ "$IS_FULL" = "" || $BACKUPMODE = "full" ]] ; then
# Full backup needs to be forcibly
su - postgres -c "/usr/bin/pg_probackup-$PG_MAJOR backup --backup-path=$BACKUP_PATH -b full $BACKUP_STREAM --instance=$PG_MAJOR -w --threads=$BACKUP_THREADS --delete-expired --delete-wal"
su - postgres -c "/usr/bin/pg_probackup-$PG_MAJOR backup --backup-path=$BACKUP_PATH -b full $BACKUP_STREAM --instance=$PG_MAJOR -w --threads=$BACKUP_THREADS"
else
# Backup type depends on day or input parameter
su - postgres -c "/usr/bin/pg_probackup-$PG_MAJOR backup --backup-path=$BACKUP_PATH -b $BACKUP_MODE $BACKUP_STREAM --instance=$PG_MAJOR -w --threads=$BACKUP_THREADS --delete-expired --delete-wal"
if [[ $BACKUPMODE = "merge" ]]; then
# в этом режиме здесь всегда PAGE
su - postgres -c "/usr/bin/pg_probackup-$PG_MAJOR backup --backup-path=$BACKUP_PATH -b page $BACKUP_STREAM --instance=$PG_MAJOR -w --threads=$BACKUP_THREADS"
else
su - postgres -c "/usr/bin/pg_probackup-$PG_MAJOR --backup-path=$BACKUP_PATH -b $BACKUPMODE $BACKUP_STREAM --instance=$PG_MAJOR -w --threads=$BACKUP_THREADS"
fi
STATUS=`su - postgres -c "/usr/bin/pg_probackup-$PG_MAJOR show --backup-path=$BACKUP_PATH --instance=$PG_MAJOR --format=json | jq -c '.[].backups[0].status'"`
LAST_STATE=${STATUS//'"'/''}
if [[ "$LAST_STATE" = "CORRUPT" || "$LAST_STATE" = "ERROR" || "$LAST_STATE" = "ORPHAN" ]] ; then
# You need to run a full backup, as an error occurred with incremental
# Perhaps the loss of the segment at Failover ...
su - postgres -c "/usr/bin/pg_probackup-$PG_MAJOR backup --backup-path=$BACKUP_PATH -b full $BACKUP_STREAM --instance=$PG_MAJOR -w --threads=$BACKUP_THREADS --delete-expired --delete-wal"
su - postgres -c "/usr/bin/pg_probackup-$PG_MAJOR backup --backup-path=$BACKUP_PATH -b full $BACKUP_STREAM --instance=$PG_MAJOR -w --threads=$BACKUP_THREADS"
fi
fi

if [[ $BACKUPMODE = "merge" ]] ; then
# объединяем старые бэкапы в соответствии с настройками
su - postgres -c "/usr/bin/pg_probackup-$PG_MAJOR delete --backup-path=$BACKUP_PATH --instance=$PG_MAJOR --delete-expired --delete-wal --merge-expired --no-validate --threads=$BACKUP_THREADS"
else
# чистим старые бэкапы в соответствии с настройками
su - postgres -c "/usr/bin/pg_probackup-$PG_MAJOR delete --backup-path=$BACKUP_PATH --instance=$PG_MAJOR --delete-expired --delete-wal --threads=$BACKUP_THREADS"
fi

# collecting statistics on backups
su - postgres -c "/usr/bin/pg_probackup-$PG_MAJOR show --backup-path=$BACKUP_PATH > ~postgres/backups.txt"
Expand Down
18 changes: 9 additions & 9 deletions 12/docker-postgres/sql/user_lookup.sql
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
CREATE OR REPLACE FUNCTION pgbouncer.user_lookup(p_username text, OUT uname text, OUT phash text) RETURNS record
LANGUAGE plpgsql SECURITY DEFINER
AS $$
BEGIN
SELECT usename, passwd FROM pg_catalog.pg_shadow
WHERE usename = p_username INTO uname, phash;
RETURN;
END;
$$;
CREATE OR REPLACE FUNCTION pgbouncer.user_lookup(p_username text, OUT uname text, OUT phash text) RETURNS record
LANGUAGE plpgsql SECURITY DEFINER
AS $$
BEGIN
SELECT usename, passwd FROM pg_catalog.pg_shadow
WHERE usename = p_username INTO uname, phash;
RETURN;
END;
$$;
2 changes: 1 addition & 1 deletion 12/docker_start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ docker run --rm --name my_postgres_12 --shm-size 2147483648 -p 5433:5432/tcp --s
-v /mnt/pgbak2/:/mnt/pgbak \
-v /usr/share/postgres/12_1/tsearch_data:/usr/share/postgresql/tsearch_data \
-e POSTGRES_PASSWORD=postgres -e POSTGRES_HOST_AUTH_METHOD=trust -e DEPLOY_PASSWORD=postgres -e PGBOUNCER_PASSWORD=postgres -e TZ="Etc/UTC" \
grufos/postgres:12.17 \
grufos/postgres:12.18 \
-c shared_preload_libraries="plugin_debugger,plpgsql_check,pg_stat_statements,auto_explain,pg_buffercache,pg_cron,shared_ispell,pg_prewarm" -c shared_ispell.max_size=70MB
4 changes: 2 additions & 2 deletions 12/postgres-service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ services:

postgres:

# image: grufos/postgres:12.17
# image: grufos/postgres:12.18
build:
context: ./docker-postgres
dockerfile: Dockerfile
Expand Down Expand Up @@ -35,5 +35,5 @@ services:
EMAIL_SERVER: "mail.company.ru"
EMAIL_HOSTNAME: "[email protected]"
BACKUP_THREADS: "4"
BACKUP_MODE: "page"
BACKUP_MODE: ""

6 changes: 3 additions & 3 deletions 12/postgres-service_all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ services:

postgres:

# image: grufos/postgres:12.17
# image: grufos/postgres:12.18
build:
context: ./docker-postgres
dockerfile: Dockerfile
Expand Down Expand Up @@ -35,10 +35,10 @@ services:
EMAIL_SERVER: "mail.company.ru"
EMAIL_HOSTNAME: "[email protected]"
BACKUP_THREADS: "4"
BACKUP_MODE: "page"
BACKUP_MODE: ""

pgbouncer:
# image: grufos/pgbouncer:1.17.0
# image: grufos/pgbouncer:1.22.0
build:
context: ./docker-pgbouncer
dockerfile: Dockerfile
Expand Down
6 changes: 3 additions & 3 deletions 12/postgres-service_pgb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ services:

postgres:

# image: grufos/postgres:12.17
# image: grufos/postgres:12.18
build:
context: ./docker-postgres
dockerfile: Dockerfile
Expand Down Expand Up @@ -35,10 +35,10 @@ services:
EMAIL_SERVER: "mail.company.ru"
EMAIL_HOSTNAME: "[email protected]"
BACKUP_THREADS: "4"
BACKUP_MODE: "page"
BACKUP_MODE: ""

pgbouncer:
# image: grufos/pgbouncer:1.17.0
# image: grufos/pgbouncer:1.22.0
build:
context: ./docker-pgbouncer
dockerfile: Dockerfile
Expand Down
2 changes: 1 addition & 1 deletion 13/backup-service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ services:
EMAIL_SERVER: "mail.company.ru"
EMAIL_HOSTNAME: "[email protected]"
BACKUP_THREADS: "4"
BACKUP_MODE: "page"
BACKUP_MODE: ""
BACKUP_STREAM: "yes"
1 change: 1 addition & 0 deletions 13/bin/clear_all_docker.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
# docker system prune -a # чистка всех образов в каталоге /var/lib/docker/overlay2
docker stop $(docker ps -q)
docker rm -v $(docker ps -aq -f status=exited)
docker rmi $(docker image ls -q) -f
Expand Down
2 changes: 1 addition & 1 deletion 13/bin/docker_start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ docker run -p 127.0.0.1:5433:5432/tcp --shm-size 2147483648 \
-e POSTGRES_HOST_AUTH_METHOD=trust \
-e DEPLOY_PASSWORD=postgres \
-e TZ="Etc/UTC" \
grufos/postgres:13.13 \
grufos/postgres:13.14 \
-c shared_preload_libraries="plugin_debugger,plpgsql_check,pg_stat_statements,auto_explain,pg_buffercache,pg_cron,shared_ispell,pg_prewarm" \
-c shared_ispell.max_size=70MB
2 changes: 1 addition & 1 deletion 13/bin/harbor_push.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
VERSION=13
MINOR=13
VERS_BOUNCER="1.21.0"
VERS_BOUNCER="1.22.0"
VERS_PROBACKUP="2.5.13"
VERS_MAMONSU="3.5.5"
PROJECT=dba_postgres
Expand Down
2 changes: 1 addition & 1 deletion 13/bin/hub_push.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
VERSION=13
MINOR=13
VERS_BOUNCER="1.21.0"
VERS_BOUNCER="1.22.0"
VERS_PROBACKUP="2.5.13"
VERS_MAMONSU="3.5.5"
ACCOUNT=grufos
Expand Down
2 changes: 1 addition & 1 deletion 13/docker-mamonsu/bootstrap_post.sql
Original file line number Diff line number Diff line change
@@ -1 +1 @@
select 'GRANT EXECUTE ON FUNCTION mamonsu.' || proname || '() TO mamonsu;' from pg_proc where pronamespace = 'mamonsu'::regnamespace \gexec
select 'GRANT EXECUTE ON FUNCTION mamonsu.' || oid::regprocedure || ' TO mamonsu;' from pg_proc where pronamespace = 'mamonsu'::regnamespace \gexec
Loading

0 comments on commit 58e463e

Please sign in to comment.