|
|
Riga 1: |
Riga 1: |
| !! ATTENZIONE !!
| | Tips: |
|
| |
|
| https://www.scaleway.com/en/docs/tutorials/back-up-postgresql-barman/ù
| | Controllo tempo di risposta sito: |
| | |
| 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 | | curl -k --connect-timeout 30 --max-time 30 --write-out '%{time_total};%{http_code}\n' http://www.gazzi.net/ |
|
| |
|
| | [[PIP]] |
|
| |
|
| Restore esempio di lancio:
| | [[TimeZone]] |
|
| |
|
| barman recover main 20161117ET220002 /tmp
| | [[EPEL Oracle]] |