BarMan: differenze tra le versioni

Da GazziNet.
Vai alla navigazione Vai alla ricerca
Nessun oggetto della modifica
Nessun oggetto della modifica
(3 versioni intermedie di uno stesso utente non sono mostrate)
Riga 20: Riga 20:
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';


ALTER USER streaming_barman WITH PASSWORD 'orione'


Esempio di HBA:
Esempio di HBA:
Riga 41: Riga 42:




ALTER USER barman WITH PASSWORD 'orione';
SULLA MACCHINA BARMAN:
ALTER USER streaming_barman WITH PASSWORD 'orione';


# 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


SULLA MACCHINA BARMAN:
# Disable the built-in PostgreSQL module:
sudo dnf -qy module disable postgresql <-- Importante!!


yum install https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-6-x86_64/pgdg-redhat96-9.6-3.noarch.rpm -y
# Install PostgreSQL:
yum install yum install postgresql96-server postgresql96-contrib -y
sudo dnf install -y postgresql15
yum install barman -y
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
 


chmod 0600 .pgpass


SULLA MACCHINA POSTGRES - da Utente Postgres:
SULLA MACCHINA POSTGRES - da Utente Postgres:
Riga 87: Riga 88:


""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 97: Riga 98:


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 delle 20:47, 11 giu 2023

!! 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


  1. .bash_profile
  2. Get the aliases and functions

if [ -f ~/.bashrc ]; then

       . ~/.bashrc

fi

  1. 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