BarMan: differenze tra le versioni
|  (Creata pagina con "!! ATTENZIONE !!  Per chissà quale motivo nelle installazioni di Postgres CentOs 6 e PostGres non c'e' nel path i binari di alcuni componenti di postgres. Per inserire il path in modo "corretto":  echo "pathmunge /usr/pgsql-9.6/bin" > /etc/profile.d/postgres.sh   # .bash_profile  # Get the aliases and functions if [ -f ~/.bashrc ]; then         . ~/.bashrc fi # User specific environment and startup programs   PATH=$PATH:$HOME/bin export PATH   SULLA MACCHINA DB:  Utente...") | Nessun oggetto della modifica | ||
| (7 versioni intermedie di uno stesso utente non sono mostrate) | |||
| Riga 1: | Riga 1: | ||
| !! ATTENZIONE !! | !! ATTENZIONE !! | ||
|  https://www.scaleway.com/en/docs/tutorials/back-up-postgresql-barman/ | |||
| Per chissà quale motivo nelle installazioni di Postgres CentOs 6 e PostGres non c'e' nel path i binari di alcuni componenti di postgres. Per inserire il path in modo "corretto": | Per chissà quale motivo nelle installazioni di Postgres CentOs 6 e PostGres non c'e' nel path i binari di alcuni componenti di postgres. Per inserire il path in modo "corretto": | ||
| echo "pathmunge /usr/pgsql- |  echo "pathmunge /usr/pgsql-15/bin" > /etc/profile.d/postgres.sh | ||
| Riga 20: | Riga 22: | ||
| Utente di accesso al Management DB: | Utente di accesso al Management DB: | ||
| createuser -s barman |  createuser -s barman | ||
| Utente di streaming replication con autorizzazione Replication: | Utente di streaming replication con autorizzazione Replication: | ||
| createuser --replication streaming_barman |  createuser --replication streaming_barman | ||
| Da psql: | Da psql: | ||
| ALTER USER barman WITH PASSWORD 'orione'; |  ALTER USER barman WITH PASSWORD 'orione'; | ||
|  ALTER USER streaming_barman WITH PASSWORD 'orione'; | |||
| Esempio di HBA: | Esempio di HBA: | ||
| Riga 36: | Riga 39: | ||
|      TYPE DATABASE USER ADDRESS METHOD |      TYPE DATABASE USER ADDRESS METHOD | ||
| host    all             barman          10.240.1.252/32            password   |  host    all             barman          10.240.1.252/32            password | ||
| host    replication     streaming_barman 10.240.1.252/32           password | |||
|  host    replication     streaming_barman 10.240.1.252/32           password | |||
| SULLA MACCHINA BARMAN: | |||
|  # Install the repository RPM: | |||
|  sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-9-x86_64/pgdg-redhat-repo-latest.noarch.rpm | |||
|  # Disable the built-in PostgreSQL module: | |||
|  sudo dnf -qy module disable postgresql <-- Importante!!  | |||
|  # Install PostgreSQL: | |||
|  sudo dnf install -y postgresql15 | |||
|  sudo dnf install -y barman | |||
| Consiglio: Aggiungere nelle prime installazioni nel file host l'ip del server con risoluzione di pg :D |  Consiglio: Aggiungere nelle prime installazioni nel file host l'ip del server con risoluzione di pg :D | ||
| 10.240.1.114 SRV01 |  10.240.1.114 SRV01 | ||
| Test di accesso all'utente di DB: | Test di accesso all'utente di DB: | ||
| psql -c 'SELECT version()' -U barman -h SRV01 postgres |  psql -c 'SELECT version()' -U barman -h SRV01 postgres | ||
| Esempio di Output: |  Esempio di Output: | ||
| "" PostgreSQL 9.6.1 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-17), 64-bit "" |  "" PostgreSQL 9.6.1 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-17), 64-bit "" | ||
| Test di accesso all'utente di replication: | Test di accesso all'utente di replication: | ||
| psql -U streaming_barman -h SRV01 -c "IDENTIFY_SYSTEM" replication=1 |  psql -U streaming_barman -h SRV01 -c "IDENTIFY_SYSTEM" replication=1 | ||
| Esempio di Output: | Esempio di Output: | ||
| "" psql: FATALE:  il numero di richieste di connessioni di standby supera max_wal_senders (attualmente 0) "" |  "" psql: FATALE:  il numero di richieste di connessioni di standby supera max_wal_senders (attualmente 0) "" | ||
| Attivazione automatica della connessione nel profilo di barman: | Attivazione automatica della connessione nel profilo di barman: | ||
| vi .pgpass   |  vi .pgpass   | ||
| *:*:*:barman:orione |  *:*:*:barman:orione | ||
| *:*:*:streaming_barman:orione |  *:*:*:streaming_barman:orione | ||
|  chmod 0600 .pgpass | |||
| SULLA MACCHINA POSTGRES - da Utente Postgres: | SULLA MACCHINA POSTGRES - da Utente Postgres: | ||
| Riga 85: | Riga 90: | ||
| ""Numero di massimo di connessioni per lo streaming di backup/replication""   | ""Numero di massimo di connessioni per lo streaming di backup/replication""   | ||
| max_wal_senders = 2 |  max_wal_senders = 2 | ||
| ""Numero di Replication Slot necessari minimi"" | ""Numero di Replication Slot necessari minimi"" | ||
| max_replication_slots = 2 |  max_replication_slots = 2 | ||
| ""Attivazione della replicazione""   | ""Attivazione della replicazione""   | ||
| Riga 95: | Riga 100: | ||
| SULLA MACCHINA DI BACKUP: | SULLA MACCHINA DI BACKUP: | ||
| File di configurazione di connessione: Es.: /etc/barman.d/pg.conf | File di configurazione di connessione: Es.: /etc/barman.d/pg.conf | ||
|  [SRV01] | |||
| [SRV01] |  description = "My First Server" | ||
| description = "My First Server" |  conninfo = host=pg  port=5432 user=barman dbname=postgres | ||
| conninfo = host=pg  port=5432 user=barman dbname=postgres |  backup_method = postgres | ||
| backup_method = postgres |  streaming_conninfo = host=hostsrv01  port=5432 user=streaming_barman dbname=postgres | ||
| streaming_conninfo = host=hostsrv01  port=5432 user=streaming_barman dbname=postgres |  streaming_archiver = on | ||
| streaming_archiver = on |  slot_name = barman | ||
| slot_name = barman | |||
| Inizializzione slot da farsi la prima volta di installazione di Barman: | Inizializzione slot da farsi la prima volta di installazione di Barman: | ||
| barman receive-wal --create-slot SRV01 |  barman receive-wal --create-slot SRV01 | ||
| Attivazione Reciver (sono da avere attivi ogni volta che si fà un task di backup): | Attivazione Reciver (sono da avere attivi ogni volta che si fà un task di backup): | ||
| barman cron |  barman cron | ||
| Lancio del primo get del Recevice dei WAL: | Lancio del primo get del Recevice dei WAL: | ||
| barman receive-wal SRV01 &   |  barman receive-wal SRV01 &   | ||
| Lancio del backup: | Lancio del backup: | ||
| barman backup SRV01 |  barman backup SRV01 | ||
| Utility per forzare il checkpoint. | Utility per forzare il checkpoint. | ||
| barman switch-xlog --force SRV01 |  barman switch-xlog --force SRV01 | ||
| Restore esempio di lancio: | Restore esempio di lancio: | ||
| barman recover main 20161117ET220002 /tmp |  barman recover main 20161117ET220002 /tmp | ||
Versione attuale delle 08:21, 12 giu 2023
!! ATTENZIONE !!
https://www.scaleway.com/en/docs/tutorials/back-up-postgresql-barman/
Per chissà quale motivo nelle installazioni di Postgres CentOs 6 e PostGres non c'e' nel path i binari di alcuni componenti di postgres. Per inserire il path in modo "corretto":
echo "pathmunge /usr/pgsql-15/bin" > /etc/profile.d/postgres.sh
- .bash_profile
- Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
- User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
SULLA MACCHINA DB:
Utente di accesso al Management DB:
createuser -s barman
Utente di streaming replication con autorizzazione Replication:
createuser --replication streaming_barman
Da psql:
ALTER USER barman WITH PASSWORD 'orione';
ALTER USER streaming_barman WITH PASSWORD 'orione';
Esempio di HBA:
TYPE DATABASE USER ADDRESS METHOD
host all barman 10.240.1.252/32 password host replication streaming_barman 10.240.1.252/32 password
SULLA MACCHINA BARMAN:
# Install the repository RPM: sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-9-x86_64/pgdg-redhat-repo-latest.noarch.rpm
# Disable the built-in PostgreSQL module: sudo dnf -qy module disable postgresql <-- Importante!!
# Install PostgreSQL: sudo dnf install -y postgresql15 sudo dnf install -y barman
Consiglio: Aggiungere nelle prime installazioni nel file host l'ip del server con risoluzione di pg :D
10.240.1.114 SRV01
Test di accesso all'utente di DB:
psql -c 'SELECT version()' -U barman -h SRV01 postgres
Esempio di Output:
"" PostgreSQL 9.6.1 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-17), 64-bit ""
Test di accesso all'utente di replication:
psql -U streaming_barman -h SRV01 -c "IDENTIFY_SYSTEM" replication=1
Esempio di Output:
"" psql: FATALE: il numero di richieste di connessioni di standby supera max_wal_senders (attualmente 0) ""
Attivazione automatica della connessione nel profilo di barman:
vi .pgpass *:*:*:barman:orione *:*:*:streaming_barman:orione
chmod 0600 .pgpass
SULLA MACCHINA POSTGRES - da Utente Postgres:
Modificare su postgresql.conf
""Numero di massimo di connessioni per lo streaming di backup/replication""
max_wal_senders = 2
""Numero di Replication Slot necessari minimi""
max_replication_slots = 2
""Attivazione della replicazione""
wal_level = replica
SULLA MACCHINA DI BACKUP:
File di configurazione di connessione: Es.: /etc/barman.d/pg.conf
[SRV01] description = "My First Server" conninfo = host=pg port=5432 user=barman dbname=postgres backup_method = postgres streaming_conninfo = host=hostsrv01 port=5432 user=streaming_barman dbname=postgres streaming_archiver = on slot_name = barman
Inizializzione slot da farsi la prima volta di installazione di Barman:
barman receive-wal --create-slot SRV01
Attivazione Reciver (sono da avere attivi ogni volta che si fà un task di backup):
barman cron
Lancio del primo get del Recevice dei WAL:
barman receive-wal SRV01 &
Lancio del backup:
barman backup SRV01
Utility per forzare il checkpoint.
barman switch-xlog --force SRV01
Restore esempio di lancio:
barman recover main 20161117ET220002 /tmp