SlideShare une entreprise Scribd logo
1  sur  28
Télécharger pour lire hors ligne
Patroni
Sébastien Lardière
Loxodata
mars 2019
slardiere PATR – mars 2019 1 / 28
PATRONI
slardiere PATR – mars 2019 2 / 28
Haute Disponibilité
Gestion de la haute disponibilité :
PostgreSQL : priorité aux données : pas de bascule automatique
si besoin de priorité du service : bascule automatique
outils :
PAF (Pacemaker et Corosync)
Repmgr (ad-hoc)
Patroni (DCS Raft) de Zalando
slardiere PATR – mars 2019 3 / 28
QU’EST-CE QUE C’EST ?
slardiere PATR – mars 2019 4 / 28
Quoi?
Gestion de la haute disponibilité du service PostgreSQL :
bascule automatique : failover
contrôle de la bascule : switchover
s’appuie sur un DCS :
etcd, consul, zookeeper et même kubernetes
consensus RAFT : http://thesecretlivesofdata.com/raft/
intégration avec les sauvegardes physiques (pgbackrest)
Source : https://github.com/zalando/patroni
Doc : https://patroni.readthedocs.io/en/latest/
Ansible : https://github.com/IrisNetwork/ansible-patroni
slardiere PATR – mars 2019 5 / 28
COMMENT ÇA MARCHE ?
slardiere PATR – mars 2019 6 / 28
Comment?
Composants :
Cluster de DCS : un nœud par instance PostgreSQL
démon (python) contrôlant l’instance PostgreSQL
et son merveilleux fichier de configuration en YAML
incluant une API REST
une commande patronictl
un mécanisme de sauvegarde physique, idéalement PgBackRest
slardiere PATR – mars 2019 7 / 28
Clients HAproxy Backups
PG1
PG2
PG3
PG4 PG5
DCS1
DCS2
DCS3
DCS4 DCS5
Patroni 1
Patroni 2
Patroni 3
Patroni 4 Patroni 5
Connect
Ask
Connect
Connect
Backup
Restore
slardiere PATR – mars 2019 8 / 28
Comment?
Configuration de Patroni :
syntaxe YAML
bootstrap :
création des données de PostgreSQL : initdb
restauration depuis PgBackRest
configuration de l’instance PostgreSQL
bootstrap des replicas
copie du primary avec pg_basebackup
restauration depuis PgBackRest
slardiere PATR – mars 2019 9 / 28
YAML
Exemple
scope: ats
name: pg1
restapi:
listen: 192.168.122.30:8008
connect_address: 192.168.122.30:8008
etcd:
host: 192.168.122.30:2379
slardiere PATR – mars 2019 10 / 28
Exemple
bootstrap:
dcs:
ttl: 30
loop_wait: 10
retry_timeout: 10
maximum_lag_on_failover: 1048576
postgresql:
use_pg_rewind: false
use_slots: true
parameters:
log_destination: "syslog"
log_checkpoints: "on"
archive_mode: "on"
archive_timeout: 1800s
archive_command: /usr/bin/pgbackrest --stanza=ats archive-push %p
recovery_conf:
restore_command: /usr/bin/pgbackrest --stanza=ats archive-get %f "%p"
pg_hba:
- host replication postgres 192.168.122.30/24 trust
- host all all 192.168.122.30/24 trust
slardiere PATR – mars 2019 11 / 28
Exemple
method: pgbackrest
pgbackrest:
command: /usr/local/bin/pgbackrest.sh
keep_existing_recovery_conf: False
recovery_conf:
recovery_target_action: promote
recovery_target_timeline: latest
restore_command: /usr/bin/pgbackrest --stanza=ats archive-get %f "%p"
initdb:
- encoding: UTF8
- data-checksums
slardiere PATR – mars 2019 12 / 28
Exemple
postgresql:
listen: 192.168.122.30:5432
connect_address: 192.168.122.30:5432
data_dir: /var/lib/postgresql/ats
bin_dir: /usr/lib/postgresql/11/bin
authentication:
replication:
username: postgres
password: azerty
superuser:
username: postgres
password: azerty
parameters:
work_mem: "16MB"
slardiere PATR – mars 2019 13 / 28
Exemple
create_replica_methods:
- pgbackrest
- basebackup
pgbackrest:
command: /usr/bin/pgbackrest --stanza=ats --delta restore
no_params: True
no_master: 1
keep_data: True
basebackup:
max-rate: ’100M’
slardiere PATR – mars 2019 14 / 28
Exemple
tags:
nofailover: false
noloadbalance: false
clonefrom: false
nosync: false
slardiere PATR – mars 2019 15 / 28
COMMENT FAIT-ON ?
slardiere PATR – mars 2019 16 / 28
Opérations :
démarrage du DCS
démarrage du démon Patroni
contrôle avec patroni list
slardiere PATR – mars 2019 17 / 28
Opérations avec patronictl :
Mode maintenance : pause/resume
restart des instances PostgreSQL
reinit des instances PostgreSQL
switchover, failover des instances
autres : dsn, query, show-config
slardiere PATR – mars 2019 18 / 28
Patronictl
Exemple
postgres@pg10_03:~$ /usr/bin/patronictl -c /etc/patroni/config.yml list
+---------+--------+-----------------+--------+---------+----+-----------+
| Cluster | Member | Host | Role | State | TL | Lag in MB |
+---------+--------+-----------------+--------+---------+----+-----------+
| ats | pg1 | 192.168.122.30 | | running | 47 | 0 |
| ats | pg2 | 192.168.122.102 | Leader | running | 47 | 0 |
| ats | pg3 | 192.168.122.32 | | running | 47 | 0 |
| ats | pg4 | 192.168.122.61 | | running | 47 | 0 |
| ats | pg5 | 192.168.122.8 | | running | 47 | 0 |
+---------+--------+-----------------+--------+---------+----+-----------+
slardiere PATR – mars 2019 19 / 28
Patronictl
Exemple
postgres@pg10_03:~$ /usr/bin/patronictl -c /etc/patroni/config.yml switchover
Master [pg2]:
Candidate [’pg1’, ’pg3’, ’pg4’, ’pg5’] []: pg1
When should the switchover take place (e.g. 2015-10-01T14:30) [now]:
Current cluster topology
+---------+--------+-----------------+--------+---------+----+-----------+
| Cluster | Member | Host | Role | State | TL | Lag in MB |
+---------+--------+-----------------+--------+---------+----+-----------+
| ats | pg1 | 192.168.122.30 | | running | 47 | 0 |
| ats | pg2 | 192.168.122.102 | Leader | running | 47 | 0 |
| ats | pg3 | 192.168.122.32 | | running | 47 | 0 |
| ats | pg4 | 192.168.122.61 | | running | 47 | 0 |
| ats | pg5 | 192.168.122.8 | | running | 47 | 0 |
+---------+--------+-----------------+--------+---------+----+-----------+
slardiere PATR – mars 2019 20 / 28
Patronictl
Exemple
Are you sure you want to switchover cluster ats, demoting current master pg2? [y/N]: y
2019-03-19 17:29:45.45659 Successfully switched over to "pg1"
+---------+--------+-----------------+--------+---------+----+-----------+
| Cluster | Member | Host | Role | State | TL | Lag in MB |
+---------+--------+-----------------+--------+---------+----+-----------+
| ats | pg1 | 192.168.122.30 | Leader | running | 47 | |
| ats | pg2 | 192.168.122.102 | | stopped | | unknown |
| ats | pg3 | 192.168.122.32 | | running | 47 | 0 |
| ats | pg4 | 192.168.122.61 | | running | 47 | 0 |
| ats | pg5 | 192.168.122.8 | | running | 47 | 0 |
+---------+--------+-----------------+--------+---------+----+-----------+
slardiere PATR – mars 2019 21 / 28
Patronictl
Exemple
postgres@pg10_03:~$ /usr/bin/patronictl -c /etc/patroni/config.yml list
+---------+--------+-----------------+--------+---------+----+-----------+
| Cluster | Member | Host | Role | State | TL | Lag in MB |
+---------+--------+-----------------+--------+---------+----+-----------+
| ats | pg1 | 192.168.122.30 | Leader | running | 48 | 0 |
| ats | pg2 | 192.168.122.102 | | running | 48 | 0 |
| ats | pg3 | 192.168.122.32 | | running | 48 | 0 |
| ats | pg4 | 192.168.122.61 | | running | 48 | 0 |
| ats | pg5 | 192.168.122.8 | | running | 48 | 0 |
+---------+--------+-----------------+--------+---------+----+-----------+
slardiere PATR – mars 2019 22 / 28
COMMENT S’EN SERT-ON ?
slardiere PATR – mars 2019 23 / 28
Connexions :
Template HAproxy et PgBouncer
confd crée les configs
en utilisant le DCS
HAProxy utilise l’API REST pour trouver le primary
l’application se connecte à HAProxy
slardiere PATR – mars 2019 24 / 28
/etc/haproxy/haproxy.cfg
Exemple
listen master
bind *:5000
option httpchk OPTIONS /master
http-check expect status 200
default-server inter 3s fall 3 rise 2 on-marked-down shutdown-sessions
server pg1 192.168.122.30:5432 maxconn 100 check port 8008
server pg2 192.168.122.102:5432 maxconn 100 check port 8008
server pg3 192.168.122.32:5432 maxconn 100 check port 8008
server pg4 192.168.122.61:5432 maxconn 100 check port 8008
server pg5 192.168.122.8:5432 maxconn 100 check port 8008
slardiere PATR – mars 2019 25 / 28
Sauvegardes :
Intégration avec pgBackRest
suit automatiquement les bascules
sert à l’initialisation
slardiere PATR – mars 2019 26 / 28
/etc/pgbackrest/conf.d/ats.conf
Exemple
[ats]
pg1-path=/var/lib/postgresql/ats
pg1-host=192.168.122.30
pg1-host-user=postgres
pg2-path=/var/lib/postgresql/ats
pg2-host=192.168.122.102
pg2-host-user=postgres
pg3-path=/var/lib/postgresql/ats
pg3-host=192.168.122.32
pg3-host-user=postgres
pg4-path=/var/lib/postgresql/ats
pg4-host=192.168.122.61
pg4-host-user=postgres
pg5-path=/var/lib/postgresql/ats
pg5-host=192.168.122.8
pg5-host-user=postgres
slardiere PATR – mars 2019 27 / 28
Questions?
slardiere PATR – mars 2019 28 / 28

Contenu connexe

Tendances

Deep dive to PostgreSQL Indexes
Deep dive to PostgreSQL IndexesDeep dive to PostgreSQL Indexes
Deep dive to PostgreSQL IndexesIbrar Ahmed
 
[pgday.Seoul 2022] PostgreSQL구조 - 윤성재
[pgday.Seoul 2022] PostgreSQL구조 - 윤성재[pgday.Seoul 2022] PostgreSQL구조 - 윤성재
[pgday.Seoul 2022] PostgreSQL구조 - 윤성재PgDay.Seoul
 
Advanced backup methods (Postgres@CERN)
Advanced backup methods (Postgres@CERN)Advanced backup methods (Postgres@CERN)
Advanced backup methods (Postgres@CERN)Anastasia Lubennikova
 
Mastering PostgreSQL Administration
Mastering PostgreSQL AdministrationMastering PostgreSQL Administration
Mastering PostgreSQL AdministrationEDB
 
How does PostgreSQL work with disks: a DBA's checklist in detail. PGConf.US 2015
How does PostgreSQL work with disks: a DBA's checklist in detail. PGConf.US 2015How does PostgreSQL work with disks: a DBA's checklist in detail. PGConf.US 2015
How does PostgreSQL work with disks: a DBA's checklist in detail. PGConf.US 2015PostgreSQL-Consulting
 
Shipping Data from Postgres to Clickhouse, by Murat Kabilov, Adjust
Shipping Data from Postgres to Clickhouse, by Murat Kabilov, AdjustShipping Data from Postgres to Clickhouse, by Murat Kabilov, Adjust
Shipping Data from Postgres to Clickhouse, by Murat Kabilov, AdjustAltinity Ltd
 
Deep dive into PostgreSQL statistics.
Deep dive into PostgreSQL statistics.Deep dive into PostgreSQL statistics.
Deep dive into PostgreSQL statistics.Alexey Lesovsky
 
Linux tuning to improve PostgreSQL performance
Linux tuning to improve PostgreSQL performanceLinux tuning to improve PostgreSQL performance
Linux tuning to improve PostgreSQL performancePostgreSQL-Consulting
 
Mvcc in postgreSQL 권건우
Mvcc in postgreSQL 권건우Mvcc in postgreSQL 권건우
Mvcc in postgreSQL 권건우PgDay.Seoul
 
Deploying PostgreSQL on Kubernetes
Deploying PostgreSQL on KubernetesDeploying PostgreSQL on Kubernetes
Deploying PostgreSQL on KubernetesJimmy Angelakos
 
Container Performance Analysis
Container Performance AnalysisContainer Performance Analysis
Container Performance AnalysisBrendan Gregg
 
Kevin Kempter PostgreSQL Backup and Recovery Methods @ Postgres Open
Kevin Kempter PostgreSQL Backup and Recovery Methods @ Postgres OpenKevin Kempter PostgreSQL Backup and Recovery Methods @ Postgres Open
Kevin Kempter PostgreSQL Backup and Recovery Methods @ Postgres OpenPostgresOpen
 
Troubleshooting PostgreSQL Streaming Replication
Troubleshooting PostgreSQL Streaming ReplicationTroubleshooting PostgreSQL Streaming Replication
Troubleshooting PostgreSQL Streaming ReplicationAlexey Lesovsky
 
Using JSON/BSON types in your hybrid application environment
Using JSON/BSON types in your hybrid application environmentUsing JSON/BSON types in your hybrid application environment
Using JSON/BSON types in your hybrid application environmentAjay Gupte
 
What is new in PostgreSQL 14?
What is new in PostgreSQL 14?What is new in PostgreSQL 14?
What is new in PostgreSQL 14?Mydbops
 
Pgsodium's Features: those not provided by pgcrypto and integration with rem...
 Pgsodium's Features: those not provided by pgcrypto and integration with rem... Pgsodium's Features: those not provided by pgcrypto and integration with rem...
Pgsodium's Features: those not provided by pgcrypto and integration with rem...EDB
 
Postgres Vision 2018: WAL: Everything You Want to Know
Postgres Vision 2018: WAL: Everything You Want to KnowPostgres Vision 2018: WAL: Everything You Want to Know
Postgres Vision 2018: WAL: Everything You Want to KnowEDB
 
PostgreSQL Performance Tuning
PostgreSQL Performance TuningPostgreSQL Performance Tuning
PostgreSQL Performance Tuningelliando dias
 
Vacuum in PostgreSQL
Vacuum in PostgreSQLVacuum in PostgreSQL
Vacuum in PostgreSQLRafia Sabih
 

Tendances (20)

Deep dive to PostgreSQL Indexes
Deep dive to PostgreSQL IndexesDeep dive to PostgreSQL Indexes
Deep dive to PostgreSQL Indexes
 
[pgday.Seoul 2022] PostgreSQL구조 - 윤성재
[pgday.Seoul 2022] PostgreSQL구조 - 윤성재[pgday.Seoul 2022] PostgreSQL구조 - 윤성재
[pgday.Seoul 2022] PostgreSQL구조 - 윤성재
 
Advanced backup methods (Postgres@CERN)
Advanced backup methods (Postgres@CERN)Advanced backup methods (Postgres@CERN)
Advanced backup methods (Postgres@CERN)
 
Mastering PostgreSQL Administration
Mastering PostgreSQL AdministrationMastering PostgreSQL Administration
Mastering PostgreSQL Administration
 
How does PostgreSQL work with disks: a DBA's checklist in detail. PGConf.US 2015
How does PostgreSQL work with disks: a DBA's checklist in detail. PGConf.US 2015How does PostgreSQL work with disks: a DBA's checklist in detail. PGConf.US 2015
How does PostgreSQL work with disks: a DBA's checklist in detail. PGConf.US 2015
 
Shipping Data from Postgres to Clickhouse, by Murat Kabilov, Adjust
Shipping Data from Postgres to Clickhouse, by Murat Kabilov, AdjustShipping Data from Postgres to Clickhouse, by Murat Kabilov, Adjust
Shipping Data from Postgres to Clickhouse, by Murat Kabilov, Adjust
 
PostgreSQL Replication Tutorial
PostgreSQL Replication TutorialPostgreSQL Replication Tutorial
PostgreSQL Replication Tutorial
 
Deep dive into PostgreSQL statistics.
Deep dive into PostgreSQL statistics.Deep dive into PostgreSQL statistics.
Deep dive into PostgreSQL statistics.
 
Linux tuning to improve PostgreSQL performance
Linux tuning to improve PostgreSQL performanceLinux tuning to improve PostgreSQL performance
Linux tuning to improve PostgreSQL performance
 
Mvcc in postgreSQL 권건우
Mvcc in postgreSQL 권건우Mvcc in postgreSQL 권건우
Mvcc in postgreSQL 권건우
 
Deploying PostgreSQL on Kubernetes
Deploying PostgreSQL on KubernetesDeploying PostgreSQL on Kubernetes
Deploying PostgreSQL on Kubernetes
 
Container Performance Analysis
Container Performance AnalysisContainer Performance Analysis
Container Performance Analysis
 
Kevin Kempter PostgreSQL Backup and Recovery Methods @ Postgres Open
Kevin Kempter PostgreSQL Backup and Recovery Methods @ Postgres OpenKevin Kempter PostgreSQL Backup and Recovery Methods @ Postgres Open
Kevin Kempter PostgreSQL Backup and Recovery Methods @ Postgres Open
 
Troubleshooting PostgreSQL Streaming Replication
Troubleshooting PostgreSQL Streaming ReplicationTroubleshooting PostgreSQL Streaming Replication
Troubleshooting PostgreSQL Streaming Replication
 
Using JSON/BSON types in your hybrid application environment
Using JSON/BSON types in your hybrid application environmentUsing JSON/BSON types in your hybrid application environment
Using JSON/BSON types in your hybrid application environment
 
What is new in PostgreSQL 14?
What is new in PostgreSQL 14?What is new in PostgreSQL 14?
What is new in PostgreSQL 14?
 
Pgsodium's Features: those not provided by pgcrypto and integration with rem...
 Pgsodium's Features: those not provided by pgcrypto and integration with rem... Pgsodium's Features: those not provided by pgcrypto and integration with rem...
Pgsodium's Features: those not provided by pgcrypto and integration with rem...
 
Postgres Vision 2018: WAL: Everything You Want to Know
Postgres Vision 2018: WAL: Everything You Want to KnowPostgres Vision 2018: WAL: Everything You Want to Know
Postgres Vision 2018: WAL: Everything You Want to Know
 
PostgreSQL Performance Tuning
PostgreSQL Performance TuningPostgreSQL Performance Tuning
PostgreSQL Performance Tuning
 
Vacuum in PostgreSQL
Vacuum in PostgreSQLVacuum in PostgreSQL
Vacuum in PostgreSQL
 

Similaire à PostgreSQL - Haute disponibilité avec Patroni

515_Patroni-training_postgres_high_availability.pdf
515_Patroni-training_postgres_high_availability.pdf515_Patroni-training_postgres_high_availability.pdf
515_Patroni-training_postgres_high_availability.pdfRobertoGiordano16
 
pg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQLpg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQLCommand Prompt., Inc
 
pg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQLpg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQLMark Wong
 
pg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQLpg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQLMark Wong
 
Cloudstack interfaces to EC2 and GCE
Cloudstack interfaces to EC2 and GCECloudstack interfaces to EC2 and GCE
Cloudstack interfaces to EC2 and GCEShapeBlue
 
CoreOS in anger : firing up wordpress across a 3 machine CoreOS cluster
CoreOS in anger : firing up wordpress across a 3 machine CoreOS cluster CoreOS in anger : firing up wordpress across a 3 machine CoreOS cluster
CoreOS in anger : firing up wordpress across a 3 machine CoreOS cluster Shaun Domingo
 
Postgres 12 Cluster Database operations.
Postgres 12 Cluster Database operations.Postgres 12 Cluster Database operations.
Postgres 12 Cluster Database operations.Vijay Kumar N
 
Operating CloudStack: the easy way (automation!)
Operating CloudStack: the easy way (automation!)Operating CloudStack: the easy way (automation!)
Operating CloudStack: the easy way (automation!)Remi Bergsma
 
pg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQLpg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQLCommand Prompt., Inc
 
pg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQLpg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQLMark Wong
 
Oracle to Postgres Migration - part 2
Oracle to Postgres Migration - part 2Oracle to Postgres Migration - part 2
Oracle to Postgres Migration - part 2PgTraining
 
Postgresql 12 streaming replication hol
Postgresql 12 streaming replication holPostgresql 12 streaming replication hol
Postgresql 12 streaming replication holVijay Kumar N
 
Real Time Health Analytics With WebSockets Python 3 and Redis PubSub: Benjami...
Real Time Health Analytics With WebSockets Python 3 and Redis PubSub: Benjami...Real Time Health Analytics With WebSockets Python 3 and Redis PubSub: Benjami...
Real Time Health Analytics With WebSockets Python 3 and Redis PubSub: Benjami...Redis Labs
 
Hvordan sette opp en OAI-PMH metadata-innhøster
Hvordan sette opp en OAI-PMH metadata-innhøsterHvordan sette opp en OAI-PMH metadata-innhøster
Hvordan sette opp en OAI-PMH metadata-innhøsterLibriotech
 
Common schema my sql uc 2012
Common schema   my sql uc 2012Common schema   my sql uc 2012
Common schema my sql uc 2012Roland Bouman
 
Common schema my sql uc 2012
Common schema   my sql uc 2012Common schema   my sql uc 2012
Common schema my sql uc 2012Roland Bouman
 
PGDay.Amsterdam 2018 - Stefan Fercot - Save your data with pgBackRest
PGDay.Amsterdam 2018 - Stefan Fercot - Save your data with pgBackRestPGDay.Amsterdam 2018 - Stefan Fercot - Save your data with pgBackRest
PGDay.Amsterdam 2018 - Stefan Fercot - Save your data with pgBackRestPGDay.Amsterdam
 
Automating Disaster Recovery PostgreSQL
Automating Disaster Recovery PostgreSQLAutomating Disaster Recovery PostgreSQL
Automating Disaster Recovery PostgreSQLNina Kaufman
 

Similaire à PostgreSQL - Haute disponibilité avec Patroni (20)

Puppet Data Mining
Puppet Data MiningPuppet Data Mining
Puppet Data Mining
 
515_Patroni-training_postgres_high_availability.pdf
515_Patroni-training_postgres_high_availability.pdf515_Patroni-training_postgres_high_availability.pdf
515_Patroni-training_postgres_high_availability.pdf
 
pg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQLpg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQL
 
pg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQLpg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQL
 
pg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQLpg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQL
 
Cloudstack interfaces to EC2 and GCE
Cloudstack interfaces to EC2 and GCECloudstack interfaces to EC2 and GCE
Cloudstack interfaces to EC2 and GCE
 
Backups
BackupsBackups
Backups
 
CoreOS in anger : firing up wordpress across a 3 machine CoreOS cluster
CoreOS in anger : firing up wordpress across a 3 machine CoreOS cluster CoreOS in anger : firing up wordpress across a 3 machine CoreOS cluster
CoreOS in anger : firing up wordpress across a 3 machine CoreOS cluster
 
Postgres 12 Cluster Database operations.
Postgres 12 Cluster Database operations.Postgres 12 Cluster Database operations.
Postgres 12 Cluster Database operations.
 
Operating CloudStack: the easy way (automation!)
Operating CloudStack: the easy way (automation!)Operating CloudStack: the easy way (automation!)
Operating CloudStack: the easy way (automation!)
 
pg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQLpg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQL
 
pg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQLpg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQL
 
Oracle to Postgres Migration - part 2
Oracle to Postgres Migration - part 2Oracle to Postgres Migration - part 2
Oracle to Postgres Migration - part 2
 
Postgresql 12 streaming replication hol
Postgresql 12 streaming replication holPostgresql 12 streaming replication hol
Postgresql 12 streaming replication hol
 
Real Time Health Analytics With WebSockets Python 3 and Redis PubSub: Benjami...
Real Time Health Analytics With WebSockets Python 3 and Redis PubSub: Benjami...Real Time Health Analytics With WebSockets Python 3 and Redis PubSub: Benjami...
Real Time Health Analytics With WebSockets Python 3 and Redis PubSub: Benjami...
 
Hvordan sette opp en OAI-PMH metadata-innhøster
Hvordan sette opp en OAI-PMH metadata-innhøsterHvordan sette opp en OAI-PMH metadata-innhøster
Hvordan sette opp en OAI-PMH metadata-innhøster
 
Common schema my sql uc 2012
Common schema   my sql uc 2012Common schema   my sql uc 2012
Common schema my sql uc 2012
 
Common schema my sql uc 2012
Common schema   my sql uc 2012Common schema   my sql uc 2012
Common schema my sql uc 2012
 
PGDay.Amsterdam 2018 - Stefan Fercot - Save your data with pgBackRest
PGDay.Amsterdam 2018 - Stefan Fercot - Save your data with pgBackRestPGDay.Amsterdam 2018 - Stefan Fercot - Save your data with pgBackRest
PGDay.Amsterdam 2018 - Stefan Fercot - Save your data with pgBackRest
 
Automating Disaster Recovery PostgreSQL
Automating Disaster Recovery PostgreSQLAutomating Disaster Recovery PostgreSQL
Automating Disaster Recovery PostgreSQL
 

Plus de slardiere

Nouveautés PostgreSQL 12
Nouveautés PostgreSQL 12Nouveautés PostgreSQL 12
Nouveautés PostgreSQL 12slardiere
 
Nouveautés de PostgreSQL 9.5
Nouveautés de PostgreSQL 9.5Nouveautés de PostgreSQL 9.5
Nouveautés de PostgreSQL 9.5slardiere
 
Meetup PostgreSQL Nantes PG10
Meetup PostgreSQL Nantes PG10Meetup PostgreSQL Nantes PG10
Meetup PostgreSQL Nantes PG10slardiere
 
Structures internes des données sur disque, Mai 2016, Loxodata
Structures internes des données sur disque, Mai 2016, LoxodataStructures internes des données sur disque, Mai 2016, Loxodata
Structures internes des données sur disque, Mai 2016, Loxodataslardiere
 
Historique des bases de données, Mars 2016' Loxodata
Historique des bases de données, Mars 2016' LoxodataHistorique des bases de données, Mars 2016' Loxodata
Historique des bases de données, Mars 2016' Loxodataslardiere
 
PostgreSQL plprofiler - Mars 2017 - Loxodata
PostgreSQL  plprofiler - Mars 2017 - LoxodataPostgreSQL  plprofiler - Mars 2017 - Loxodata
PostgreSQL plprofiler - Mars 2017 - Loxodataslardiere
 

Plus de slardiere (6)

Nouveautés PostgreSQL 12
Nouveautés PostgreSQL 12Nouveautés PostgreSQL 12
Nouveautés PostgreSQL 12
 
Nouveautés de PostgreSQL 9.5
Nouveautés de PostgreSQL 9.5Nouveautés de PostgreSQL 9.5
Nouveautés de PostgreSQL 9.5
 
Meetup PostgreSQL Nantes PG10
Meetup PostgreSQL Nantes PG10Meetup PostgreSQL Nantes PG10
Meetup PostgreSQL Nantes PG10
 
Structures internes des données sur disque, Mai 2016, Loxodata
Structures internes des données sur disque, Mai 2016, LoxodataStructures internes des données sur disque, Mai 2016, Loxodata
Structures internes des données sur disque, Mai 2016, Loxodata
 
Historique des bases de données, Mars 2016' Loxodata
Historique des bases de données, Mars 2016' LoxodataHistorique des bases de données, Mars 2016' Loxodata
Historique des bases de données, Mars 2016' Loxodata
 
PostgreSQL plprofiler - Mars 2017 - Loxodata
PostgreSQL  plprofiler - Mars 2017 - LoxodataPostgreSQL  plprofiler - Mars 2017 - Loxodata
PostgreSQL plprofiler - Mars 2017 - Loxodata
 

Dernier

HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfCionsystems
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 

Dernier (20)

HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdf
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 

PostgreSQL - Haute disponibilité avec Patroni

  • 2. PATRONI slardiere PATR – mars 2019 2 / 28
  • 3. Haute Disponibilité Gestion de la haute disponibilité : PostgreSQL : priorité aux données : pas de bascule automatique si besoin de priorité du service : bascule automatique outils : PAF (Pacemaker et Corosync) Repmgr (ad-hoc) Patroni (DCS Raft) de Zalando slardiere PATR – mars 2019 3 / 28
  • 4. QU’EST-CE QUE C’EST ? slardiere PATR – mars 2019 4 / 28
  • 5. Quoi? Gestion de la haute disponibilité du service PostgreSQL : bascule automatique : failover contrôle de la bascule : switchover s’appuie sur un DCS : etcd, consul, zookeeper et même kubernetes consensus RAFT : http://thesecretlivesofdata.com/raft/ intégration avec les sauvegardes physiques (pgbackrest) Source : https://github.com/zalando/patroni Doc : https://patroni.readthedocs.io/en/latest/ Ansible : https://github.com/IrisNetwork/ansible-patroni slardiere PATR – mars 2019 5 / 28
  • 6. COMMENT ÇA MARCHE ? slardiere PATR – mars 2019 6 / 28
  • 7. Comment? Composants : Cluster de DCS : un nœud par instance PostgreSQL démon (python) contrôlant l’instance PostgreSQL et son merveilleux fichier de configuration en YAML incluant une API REST une commande patronictl un mécanisme de sauvegarde physique, idéalement PgBackRest slardiere PATR – mars 2019 7 / 28
  • 8. Clients HAproxy Backups PG1 PG2 PG3 PG4 PG5 DCS1 DCS2 DCS3 DCS4 DCS5 Patroni 1 Patroni 2 Patroni 3 Patroni 4 Patroni 5 Connect Ask Connect Connect Backup Restore slardiere PATR – mars 2019 8 / 28
  • 9. Comment? Configuration de Patroni : syntaxe YAML bootstrap : création des données de PostgreSQL : initdb restauration depuis PgBackRest configuration de l’instance PostgreSQL bootstrap des replicas copie du primary avec pg_basebackup restauration depuis PgBackRest slardiere PATR – mars 2019 9 / 28
  • 10. YAML Exemple scope: ats name: pg1 restapi: listen: 192.168.122.30:8008 connect_address: 192.168.122.30:8008 etcd: host: 192.168.122.30:2379 slardiere PATR – mars 2019 10 / 28
  • 11. Exemple bootstrap: dcs: ttl: 30 loop_wait: 10 retry_timeout: 10 maximum_lag_on_failover: 1048576 postgresql: use_pg_rewind: false use_slots: true parameters: log_destination: "syslog" log_checkpoints: "on" archive_mode: "on" archive_timeout: 1800s archive_command: /usr/bin/pgbackrest --stanza=ats archive-push %p recovery_conf: restore_command: /usr/bin/pgbackrest --stanza=ats archive-get %f "%p" pg_hba: - host replication postgres 192.168.122.30/24 trust - host all all 192.168.122.30/24 trust slardiere PATR – mars 2019 11 / 28
  • 12. Exemple method: pgbackrest pgbackrest: command: /usr/local/bin/pgbackrest.sh keep_existing_recovery_conf: False recovery_conf: recovery_target_action: promote recovery_target_timeline: latest restore_command: /usr/bin/pgbackrest --stanza=ats archive-get %f "%p" initdb: - encoding: UTF8 - data-checksums slardiere PATR – mars 2019 12 / 28
  • 13. Exemple postgresql: listen: 192.168.122.30:5432 connect_address: 192.168.122.30:5432 data_dir: /var/lib/postgresql/ats bin_dir: /usr/lib/postgresql/11/bin authentication: replication: username: postgres password: azerty superuser: username: postgres password: azerty parameters: work_mem: "16MB" slardiere PATR – mars 2019 13 / 28
  • 14. Exemple create_replica_methods: - pgbackrest - basebackup pgbackrest: command: /usr/bin/pgbackrest --stanza=ats --delta restore no_params: True no_master: 1 keep_data: True basebackup: max-rate: ’100M’ slardiere PATR – mars 2019 14 / 28
  • 15. Exemple tags: nofailover: false noloadbalance: false clonefrom: false nosync: false slardiere PATR – mars 2019 15 / 28
  • 16. COMMENT FAIT-ON ? slardiere PATR – mars 2019 16 / 28
  • 17. Opérations : démarrage du DCS démarrage du démon Patroni contrôle avec patroni list slardiere PATR – mars 2019 17 / 28
  • 18. Opérations avec patronictl : Mode maintenance : pause/resume restart des instances PostgreSQL reinit des instances PostgreSQL switchover, failover des instances autres : dsn, query, show-config slardiere PATR – mars 2019 18 / 28
  • 19. Patronictl Exemple postgres@pg10_03:~$ /usr/bin/patronictl -c /etc/patroni/config.yml list +---------+--------+-----------------+--------+---------+----+-----------+ | Cluster | Member | Host | Role | State | TL | Lag in MB | +---------+--------+-----------------+--------+---------+----+-----------+ | ats | pg1 | 192.168.122.30 | | running | 47 | 0 | | ats | pg2 | 192.168.122.102 | Leader | running | 47 | 0 | | ats | pg3 | 192.168.122.32 | | running | 47 | 0 | | ats | pg4 | 192.168.122.61 | | running | 47 | 0 | | ats | pg5 | 192.168.122.8 | | running | 47 | 0 | +---------+--------+-----------------+--------+---------+----+-----------+ slardiere PATR – mars 2019 19 / 28
  • 20. Patronictl Exemple postgres@pg10_03:~$ /usr/bin/patronictl -c /etc/patroni/config.yml switchover Master [pg2]: Candidate [’pg1’, ’pg3’, ’pg4’, ’pg5’] []: pg1 When should the switchover take place (e.g. 2015-10-01T14:30) [now]: Current cluster topology +---------+--------+-----------------+--------+---------+----+-----------+ | Cluster | Member | Host | Role | State | TL | Lag in MB | +---------+--------+-----------------+--------+---------+----+-----------+ | ats | pg1 | 192.168.122.30 | | running | 47 | 0 | | ats | pg2 | 192.168.122.102 | Leader | running | 47 | 0 | | ats | pg3 | 192.168.122.32 | | running | 47 | 0 | | ats | pg4 | 192.168.122.61 | | running | 47 | 0 | | ats | pg5 | 192.168.122.8 | | running | 47 | 0 | +---------+--------+-----------------+--------+---------+----+-----------+ slardiere PATR – mars 2019 20 / 28
  • 21. Patronictl Exemple Are you sure you want to switchover cluster ats, demoting current master pg2? [y/N]: y 2019-03-19 17:29:45.45659 Successfully switched over to "pg1" +---------+--------+-----------------+--------+---------+----+-----------+ | Cluster | Member | Host | Role | State | TL | Lag in MB | +---------+--------+-----------------+--------+---------+----+-----------+ | ats | pg1 | 192.168.122.30 | Leader | running | 47 | | | ats | pg2 | 192.168.122.102 | | stopped | | unknown | | ats | pg3 | 192.168.122.32 | | running | 47 | 0 | | ats | pg4 | 192.168.122.61 | | running | 47 | 0 | | ats | pg5 | 192.168.122.8 | | running | 47 | 0 | +---------+--------+-----------------+--------+---------+----+-----------+ slardiere PATR – mars 2019 21 / 28
  • 22. Patronictl Exemple postgres@pg10_03:~$ /usr/bin/patronictl -c /etc/patroni/config.yml list +---------+--------+-----------------+--------+---------+----+-----------+ | Cluster | Member | Host | Role | State | TL | Lag in MB | +---------+--------+-----------------+--------+---------+----+-----------+ | ats | pg1 | 192.168.122.30 | Leader | running | 48 | 0 | | ats | pg2 | 192.168.122.102 | | running | 48 | 0 | | ats | pg3 | 192.168.122.32 | | running | 48 | 0 | | ats | pg4 | 192.168.122.61 | | running | 48 | 0 | | ats | pg5 | 192.168.122.8 | | running | 48 | 0 | +---------+--------+-----------------+--------+---------+----+-----------+ slardiere PATR – mars 2019 22 / 28
  • 23. COMMENT S’EN SERT-ON ? slardiere PATR – mars 2019 23 / 28
  • 24. Connexions : Template HAproxy et PgBouncer confd crée les configs en utilisant le DCS HAProxy utilise l’API REST pour trouver le primary l’application se connecte à HAProxy slardiere PATR – mars 2019 24 / 28
  • 25. /etc/haproxy/haproxy.cfg Exemple listen master bind *:5000 option httpchk OPTIONS /master http-check expect status 200 default-server inter 3s fall 3 rise 2 on-marked-down shutdown-sessions server pg1 192.168.122.30:5432 maxconn 100 check port 8008 server pg2 192.168.122.102:5432 maxconn 100 check port 8008 server pg3 192.168.122.32:5432 maxconn 100 check port 8008 server pg4 192.168.122.61:5432 maxconn 100 check port 8008 server pg5 192.168.122.8:5432 maxconn 100 check port 8008 slardiere PATR – mars 2019 25 / 28
  • 26. Sauvegardes : Intégration avec pgBackRest suit automatiquement les bascules sert à l’initialisation slardiere PATR – mars 2019 26 / 28
  • 28. Questions? slardiere PATR – mars 2019 28 / 28