Skip to content

Commit 724c7ef

Browse files
author
Andre Wanderley de Souza
committed
barman is working
1 parent 26a85d5 commit 724c7ef

File tree

7 files changed

+39
-5
lines changed

7 files changed

+39
-5
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ docker exec -it pg-pgbouncer-1 psql -U postgres -c "select client_addr, state, s
6969
#### BARMAN
7070
docker run --name pg-barman-1 --network pg_stream -e BARMAN_PASSWORD=$BARMAN_PASSWORD -e STREAMING_PASSWORD=$STREAMING_PASSWORD -e PRIMARY_NODE=pg-repmgr-1 -d postgres-barman
7171

72+
sleep 60
7273
docker exec -it pg-barman-1 barman check pg-repmgr-1
7374

7475
### FORCE FAILOVER

barman/Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@ RUN apt-get update \
77
&& sed -i 's/\(.*pam_loginuid.so\)/#\1/' /etc/pam.d/cron
88

99
ENV \
10-
BARMAN_VERSION=2.1 \
1110
BARMAN_DATA_DIR=/var/lib/barman \
1211
BARMAN_LOG_DIR=/var/log/barman
1312

14-
RUN pip3 install barman==${BARMAN_VERSION} requests==2.13.0
13+
RUN pip3 install barman requests psycopg2-binary
1514

1615
RUN useradd --system --shell /bin/bash barman
1716
RUN install -d -m 0700 -o barman -g barman /home/barman/.ssh
1817

1918
COPY barman.pem /home/barman/.ssh/id_rsa
2019
RUN chmod 600 /home/barman/.ssh/id_rsa
2120
RUN chown barman:barman /home/barman/.ssh/id_rsa
22-
RUN gosu barman bash -c 'echo -e "Host *\n\tCheckHostIP no" > ~/.ssh/config'
21+
COPY ssh_config /home/barman/.ssh/config
22+
RUN chown -R barman:barman /home/barman/.ssh
2323

2424
ENV \
2525
BARMAN_USER=barman \

barman/entrypoint.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,8 @@ sed -i "s#\$BARMAN_USER#$BARMAN_USER#g" /etc/barman/barman.d/pg.conf
1818
sed -i "s#\$BARMAN_SLOT_NAME#$BARMAN_SLOT_NAME#g" /etc/barman/barman.d/pg.conf
1919
sed -i "s#\$STREAMING_USER#$STREAMING_USER#g" /etc/barman/barman.d/pg.conf
2020

21+
gosu barman barman -q cron
22+
23+
gosu barman barman switch-xlog --force --archive $PRIMARY_NODE
24+
2125
exec "$@"

barman/etc/barman.d/pg.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ description = 'Test database'
2020
path_prefix = /usr/lib/postgresql/10
2121
; recovery_options =
2222
; retention_policy_mode = auto
23-
ssh_command = 'ssh postgres@$PRIMARY_NODE'
23+
ssh_command = 'ssh -l postgres $PRIMARY_NODE'
2424
slot_name = $BARMAN_SLOT_NAME
2525
; streaming_archiver = off
2626
; streaming_archiver_batch_size = 0

barman/ssh_config

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
Host *
3+
LogLevel=ERROR
4+
StrictHostKeyChecking no
5+
UserKnownHostsFile /dev/null

postgresql.conf

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,25 @@ wal_level = 'hot_standby'
2020
max_wal_senders = 10
2121
hot_standby = on
2222
max_replication_slots = 5
23+
24+
work_mem = 32MB # min 64kB
25+
maintenance_work_mem = 128MB # min 1MB
26+
wal_buffers = 16MB # min 32kB, -1 sets based on shared_buffers
27+
28+
checkpoint_timeout = 20min # range 30s-1h
29+
checkpoint_completion_target = 0.9 # checkpoint target duration, 0.0 - 1.0
30+
31+
effective_cache_size = 938MB
32+
33+
# logging
34+
logging_collector = on
35+
log_destination = 'csvlog' # Valid values are combinations of
36+
log_filename = 'postgresql-%a.log' # log file name pattern,
37+
log_rotation_age = 1440
38+
log_truncate_on_rotation = on
39+
log_min_duration_statement = 600ms # -1 is disabled, 0 logs all statements
40+
log_checkpoints = on
41+
log_connections = off
42+
log_disconnections = off
43+
log_lock_waits = on # log lock waits >= deadlock_timeout
44+
log_temp_files = 0 # log temporary files equal or larger

promote.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,6 @@ do
3636
done
3737
done
3838

39-
rm ${PGBOUNCER_DATABASE_INI_NEW}
39+
rm ${PGBOUNCER_DATABASE_INI_NEW}
40+
41+
# TODO Generate new config file for barman, reconfigure barman, reload barman

0 commit comments

Comments
 (0)