TIPS DATABASE e BarMan: differenze tra le pagine

Da GazziNet.
(Differenze fra le pagine)
Vai alla navigazione Vai alla ricerca
Nessun oggetto della modifica
Etichetta: Ripristino manuale
 
(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...")
 
Riga 1: Riga 1:
[[PostgreSQL]]
!! 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 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
 
ALTER USER barman WITH PASSWORD 'orione';
ALTER USER streaming_barman WITH PASSWORD 'orione';
 
 
SULLA MACCHINA BARMAN:
 
yum install https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-6-x86_64/pgdg-redhat96-9.6-3.noarch.rpm -y
yum install yum install postgresql96-server postgresql96-contrib -y
yum install barman -y
 
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

Versione delle 20:26, 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

ALTER USER barman WITH PASSWORD 'orione'; ALTER USER streaming_barman WITH PASSWORD 'orione';


SULLA MACCHINA BARMAN:

yum install https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-6-x86_64/pgdg-redhat96-9.6-3.noarch.rpm -y yum install yum install postgresql96-server postgresql96-contrib -y yum install barman -y

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