SlideShare a Scribd company logo
Patroni-based citus high availability
environment deployment
( 基于Patroni的Citus高可用环境部署 )
PGDay.Seoul & PGConf.Asia 2021
Daniel Lee
2021-11-24 PGDay.Seoul & PGConf.Asia 2021 1
About Me
2021-11-24 PGDay.Seoul & PGConf.Asia 2021 2
• Dainel lee ( 李炯彩 )
• Community
• MySQL Korea User Group
• facebook.com/groups/mysqlko
• PostgreSQL Korea
• facebook.com/groups/130019777169719
• Github
• github.com/dbdbdeep-git/pgday-seoul-2021-demo
Agenda
1. Service Discovery ( *Service Mesh )
• CoreOS’s ETCD
• Hashicorp’s Consul
2. Dynamic Configuration Management
• ConfD
• Hashicorp’s Consul-Template
3. High-Availability
• Zalando’s Patroni
4. Distributed PostgreSQL as an extension
• Citusdata’s Citus
5. Demo
2021-11-24 PGDay.Seoul & PGConf.Asia 2021 3
2021-11-24 PGDay.Seoul & PGConf.Asia 2021 4
1. Service Discovery
2021-11-24 PGDay.Seoul & PGConf.Asia 2021 5
What is …
2021-11-24 PGDay.Seoul & PGConf.Asia 2021 6
Lock
Service
(chubby)
Coordination
Service
(zookeeper,eureka,etcd)
Service Discovery
(surf,skydns,consul)
Service Mesh
(lstio,linkerd2)
What can you do with Consul?
2021-11-24 PGDay.Seoul & PGConf.Asia 2021 7
Service Discovery
for connectivity
Service Registry enables services to
register and discover each other.
Service Segmentation
for security
Secure service-to-service communication
with automatic TLS encryption and
identity-based authorization.
Service Configuration
for runtime configuration
Feature rich Key/Value store to easily
configure services.
What can you do with Consul?
2021-11-24 PGDay.Seoul & PGConf.Asia 2021 8
Consul-Kubernetes Deployments
Use Consul service discovery and
service mesh features with Kubernetes.
Secure Service Communication
Secure and observe communication between
your services without modifying their code.
Dynamic Load Balancing
Automate load balancer configuration with
Consul and HAProxy, Nginx, or F5.
3 Marine Admirals
2021-11-24 PGDay.Seoul & PGConf.Asia 2021 9
Properties Consul Etcd Zookeeper
User Interface Available X X
RPC Available Available
Health Check HTTP API HTTP API TCP
Key Value
3 Consistency modes
(sync)
Good Consistency
(semi)
Strong Consistency
Token System Available X X
Language Golang Golang Java
Security ACL / HTTPS HTTPS ACL
Spring Cloud O O O
Multi
Datacenter(gossip)
O X X
2. Dynamic Configuration
2021-11-24 PGDay.Seoul & PGConf.Asia 2021 10
ConfD
• http://www.confd.io
• Manage local application configuration files using templates and
data from etcd or consul
• A lightweight configuration management tool focused on:
• keeping local configuration files up-to-date using data stored in etcd,
consul, dynamodb, redis, vault, zookeeper, aws ssm parameter store or
env vars and processing template resources.
• reloading applications to pick up new config file changes
2021-11-24 PGDay.Seoul & PGConf.Asia 2021 11
ConfD or Consul-template Architecture
2021-11-24 PGDay.Seoul & PGConf.Asia 2021 12
ETCD or Consul
Server
Confd or
Consul-template
Service
Application
(HAproxy, PostgreSQL)
Configuration
Template
File
Application
Configuration
File
listen
generate
haproxy.cfg.tmpl haproxy.cfg
reload
check
reload
update
PostgreSQL Client authentication
2021-11-24 PGDay.Seoul & PGConf.Asia 2021 13
Consul Server
Consul-template
Service
Postgres Server
Configuration
Template
File
Application
Configuration
File
listen
generate
pg_hba.conf.tmpl pg_hba.conf
reload
check
reload
update
$ consul kv put
service/database/primary/auth/client
“host all haproxy 10.0.1.0/24 reject”
3. Zalando’s Patroni
2021-11-24 PGDay.Seoul & PGConf.Asia 2021 14
Zalando Company
2021-11-24 PGDay.Seoul & PGConf.Asia 2021 15
’s Patroni
• Patroni is a template for you to create your own customized, high-availability solution using
Python and - for maximum accessibility - a DCS (Distributed Configuration Store)
like ZooKeeper, etcd, Consul or Kubernetes.
• Currently supported PostgreSQL versions: 9.3 to 14.
• Release lastest 2.1.1 ( 09.11.21 )
2021-11-24 PGDay.Seoul & PGConf.Asia 2021 16
’s Spilo
• Spilo is a Docker image that provides PostgreSQL and Patroni bundled
together. Patroni is a template for PostgreSQL HA. Multiple Spilos can create
a resilient High Available PostgreSQL cluster. For this, you'll need to start all
participating Spilos with identical etcd addresses and cluster names.
• https://github.com/zalando/spilo
2021-11-24 PGDay.Seoul & PGConf.Asia 2021 17
2021-11-24 PGDay.Seoul & PGConf.Asia 2021 18
Raft : DC to DC
2021-11-24 PGDay.Seoul & PGConf.Asia 2021 19
HA : Patroni vs pg_auto_failover
2021-11-24 PGDay.Seoul & PGConf.Asia 2021 20
4. Citusdata’s Citus
2021-11-24 PGDay.Seoul & PGConf.Asia 2021 21
Hyperscale (Citus) on Azure Database for PostgreSQL
2021-11-24 PGDay.Seoul & PGConf.Asia 2021 22
Citusとは? by Noriyoshi Shinoda
• PostgreSQL でスケールアウト環境を実現
• 複数ノードにまたがったパラレル・クエリーとパーティショニング機能
• スループット拡大を目指す
• PostgreSQL の拡張(EXTENSION)として実装
• PostgreSQL 本体の変更なし
• Citus Data (https://www.citusdata.com/)が開発
• 2019年1月 Microsoft による買収
• Azure Database for PostgreSQL - Hyperscale (Citus) の中核技術となっている
• オープンソース版も提供(https://github.com/citusdata/citus)
• 以下の機能は含まない
• 自動フェイルオーバー
• 自動データ・リバランス
• バックアップ等の運用機能
2021-11-24 PGDay.Seoul & PGConf.Asia 2021 23
https://www.slideshare.net/noriyoshishinoda/postgresql-conference-japan-2021-b2-citus-10
Citus 란?
• PostgreSQL로 스케일 아웃 환경 실현
• 다중 노드에 걸친 병렬 쿼리 및 파티셔닝 기능
• 처리량 확대를 목표로
• PostgreSQL 확장(EXTENSION)으로 구현
• PostgreSQL 본체 변경 없음
• Citus Data (https://www.citusdata.com/) 개발
• 2019년 1월 Microsoft에서 인수
• Azure Database for PostgreSQL - Hyperscale (Citus)의 핵심 기술입니다.
• 오픈 소스 버전도 제공 (https://github.com/citusdata/citus)
• 다음 기능은 포함되지 않음
• 자동 장애 조치
• 자동 데이터 재조정
• 백업 등의 운용 기능
2021-11-24 PGDay.Seoul & PGConf.Asia 2021 24
What is Citus ?
• Achieve a scale-out environment with PostgreSQL
• Parallel query and partitioning capabilities across multiple nodes
• Aim to increase throughput
• Implemented as an extension of PostgreSQL (EXTENSION)
• No changes to PostgreSQL itself
• Developed by Citus Data (https://www.citusdata.com/)
• Acquired by Microsoft in January 2019
• Azure Database for PostgreSQL-is the core technology of Hyperscale (Citus)
• Open source version is also available (https://github.com/citusdata/citus)
• The following functions are not included
• Automatic failover
• Automatic data rebalancing
• Operational functions such as backup
2021-11-24 PGDay.Seoul & PGConf.Asia 2021 25
What is Citus ? by Noriyoshi Shinoda
Instance configuration
• Coordinator Node
• A PostgreSQL instance that accepts connections from clients
• Manage metadata
• Worker Node
• PostgreSQL instance that actually stores the data
• No communication between Worker Nodes
• Install citus EXTENSION on all nodes
2021-11-24 PGDay.Seoul & PGConf.Asia 2021 26
What is Citus ? by Noriyoshi Shinoda
Instance configuration
• Processing performed by Coordinator Node
• Accepting connections from clients
• Final sort (ORDER BY)
• Sequence processing (including SERIAL column and GENERATED AS
IDENTITY column)
• Handling objects other than tables and indexes
• Processing executed by Worker Node
• Processing SQL statements requested by Coordinator Node
• Execution of ANALYZE statement
• Execution of VACUUM statement
• Retaining table data
2021-11-24 PGDay.Seoul & PGConf.Asia 2021 27
CREATE EXTENSION citus;
• Add nodes:
postgres=> SELECT master_add_node(‘worker-01_ip_or_dns’, 5432);
Postgres=> SELECT master_add_node(’worker-02_ip_or_dns’, 5432);
• Create distributed table:
postgres=> CREATE TABLE events ( orders_id int, ... );
postgres=> SELECT create_distributed_table( ‘orders', ‘orders_id’ );
• Events is now distributed across shards on the nodes
2021-11-24 PGDay.Seoul & PGConf.Asia 2021 28
if(kakao) 2021
2021-11-24 PGDay.Seoul & PGConf.Asia 2021 29
https://if.kakao.com/session/59
Table structure by Noriyoshi Shinoda
Distributed table
• A table that distributes and stores data
• Suitable for fact tables
• Specify a column as the distribution key
(default determines the distribution destination table by the hash value range)
• The number of divisions can be specified
• citus.shard_count (default value 32)
• Replicas can be created on different Worker Nodes
• citus.shard_replication_factor (default value 1 = no replica)
2021-11-24 PGDay.Seoul & PGConf.Asia 2021 30
Table structure by Noriyoshi Shinoda
Distributed table
• Table created in worker Node
• For the table name, ShardID is added to the original table name.
• If a replica is specified, a table with the same name will be created in a different Worker Node.
• Same data is stored in the table with the same name
• Search the citus_shards catalog to see the table names created by the Worker Node
postgres=> SET citus.shard_count = 6 ;
postgres=> SET citus.shard_replication_factor = 2 ;
2021-11-24 PGDay.Seoul & PGConf.Asia 2021 31
Coordinator Worker#1 Worker#2 Worker#3
Dist1
dist1_102046 dist1_102046
dist1_102047 dist1_102047
dist1_102048 dist1_102048
dist1_102049 dist1_102049
dist1_102050 dist1_102050
dist1_102051 dist1_102051
Demo | Skip
2021-11-24 PGDay.Seoul & PGConf.Asia 2021 32
if(kakao) 2021
2021-11-24 PGDay.Seoul & PGConf.Asia 2021 33
Q?!A
2021-11-24 PGDay.Seoul & PGConf.Asia 2021 34

More Related Content

PDF
Patroni: Kubernetes-native PostgreSQL companion
Alexander Kukushkin
 
PDF
PostgreSQL Deep Internal
EXEM
 
PDF
ClickHouse Keeper
Altinity Ltd
 
PDF
Data Warehouse on Kubernetes: lessons from Clickhouse Operator
Altinity Ltd
 
PDF
Deep Dive on ClickHouse Sharding and Replication-2202-09-22.pdf
Altinity Ltd
 
PDF
How to Extend Apache Spark with Customized Optimizations
Databricks
 
PDF
Data Warehouses in Kubernetes Visualized: the ClickHouse Kubernetes Operator UI
Altinity Ltd
 
PDF
PostgreSQL: Advanced indexing
Hans-Jürgen Schönig
 
Patroni: Kubernetes-native PostgreSQL companion
Alexander Kukushkin
 
PostgreSQL Deep Internal
EXEM
 
ClickHouse Keeper
Altinity Ltd
 
Data Warehouse on Kubernetes: lessons from Clickhouse Operator
Altinity Ltd
 
Deep Dive on ClickHouse Sharding and Replication-2202-09-22.pdf
Altinity Ltd
 
How to Extend Apache Spark with Customized Optimizations
Databricks
 
Data Warehouses in Kubernetes Visualized: the ClickHouse Kubernetes Operator UI
Altinity Ltd
 
PostgreSQL: Advanced indexing
Hans-Jürgen Schönig
 

What's hot (20)

PPTX
Migration to ClickHouse. Practical guide, by Alexander Zaitsev
Altinity Ltd
 
PDF
MySQL Server Settings Tuning
guest5ca94b
 
PPTX
PostgreSQL 14 モニタリング新機能紹介(PostgreSQL カンファレンス #24、2021/06/08)
NTT DATA Technology & Innovation
 
PDF
PostgreSQL Performance Tuning
elliando dias
 
PDF
Top 5 Mistakes When Writing Spark Applications
Spark Summit
 
PDF
Mastering PostgreSQL Administration
EDB
 
PDF
Everyday I'm Shuffling - Tips for Writing Better Spark Programs, Strata San J...
Databricks
 
PPTX
Apache Ranger Hive Metastore Security
DataWorks Summit/Hadoop Summit
 
PDF
Orchestrating workflows Apache Airflow on GCP & AWS
Derrick Qin
 
PDF
Dependency Injection in Apache Spark Applications
Databricks
 
PDF
Postgresql database administration volume 1
Federico Campoli
 
PDF
ClickHouse on Kubernetes, by Alexander Zaitsev, Altinity CTO
Altinity Ltd
 
PDF
ClickHouse Query Performance Tips and Tricks, by Robert Hodges, Altinity CEO
Altinity Ltd
 
PDF
Deep dive into PostgreSQL statistics.
Alexey Lesovsky
 
PDF
[오픈소스컨설팅] 쿠버네티스와 쿠버네티스 on 오픈스택 비교 및 구축 방법
Open Source Consulting
 
PDF
[Pgday.Seoul 2019] Citus를 이용한 분산 데이터베이스
PgDay.Seoul
 
PDF
How I learned to time travel, or, data pipelining and scheduling with Airflow
PyData
 
PDF
Solving PostgreSQL wicked problems
Alexander Korotkov
 
PDF
PostgreSQL Extensions: A deeper look
Jignesh Shah
 
PDF
Apache Airflow
Sumit Maheshwari
 
Migration to ClickHouse. Practical guide, by Alexander Zaitsev
Altinity Ltd
 
MySQL Server Settings Tuning
guest5ca94b
 
PostgreSQL 14 モニタリング新機能紹介(PostgreSQL カンファレンス #24、2021/06/08)
NTT DATA Technology & Innovation
 
PostgreSQL Performance Tuning
elliando dias
 
Top 5 Mistakes When Writing Spark Applications
Spark Summit
 
Mastering PostgreSQL Administration
EDB
 
Everyday I'm Shuffling - Tips for Writing Better Spark Programs, Strata San J...
Databricks
 
Apache Ranger Hive Metastore Security
DataWorks Summit/Hadoop Summit
 
Orchestrating workflows Apache Airflow on GCP & AWS
Derrick Qin
 
Dependency Injection in Apache Spark Applications
Databricks
 
Postgresql database administration volume 1
Federico Campoli
 
ClickHouse on Kubernetes, by Alexander Zaitsev, Altinity CTO
Altinity Ltd
 
ClickHouse Query Performance Tips and Tricks, by Robert Hodges, Altinity CEO
Altinity Ltd
 
Deep dive into PostgreSQL statistics.
Alexey Lesovsky
 
[오픈소스컨설팅] 쿠버네티스와 쿠버네티스 on 오픈스택 비교 및 구축 방법
Open Source Consulting
 
[Pgday.Seoul 2019] Citus를 이용한 분산 데이터베이스
PgDay.Seoul
 
How I learned to time travel, or, data pipelining and scheduling with Airflow
PyData
 
Solving PostgreSQL wicked problems
Alexander Korotkov
 
PostgreSQL Extensions: A deeper look
Jignesh Shah
 
Apache Airflow
Sumit Maheshwari
 
Ad

Similar to patroni-based citrus high availability environment deployment (20)

PDF
Let's scale-out PostgreSQL using Citus (English)
Noriyoshi Shinoda
 
PDF
Architecting peta-byte-scale analytics by scaling out Postgres on Azure with ...
Citus Data
 
PDF
Before vs After: Redesigning a Website to be Useful and Informative for Devel...
Teresa Giacomini
 
PDF
Distributed Computing on PostgreSQL | PGConf EU 2017 | Marco Slot
Citus Data
 
PDF
PostgreSQL High Availability in a Containerized World
Jignesh Shah
 
PDF
Building the Enterprise infrastructure with PostgreSQL as the basis for stori...
PavelKonotopov
 
PDF
Postgres-XC Write Scalable PostgreSQL Cluster
Mason Sharp
 
PDF
Creating customized openSUSE versions with SUSE Studio
elliando dias
 
PDF
PostgreSQL Sharding and HA: Theory and Practice (PGConf.ASIA 2017)
Aleksander Alekseev
 
PDF
PostgreSQL on Kubernetes: Realizing High Availability with PGO (Postgres Ibiz...
NTT DATA Technology & Innovation
 
PDF
Introduction to Postrges-XC
Ashutosh Bapat
 
PDF
Beyond Postgres: Interesting Projects, Tools and forks
Sameer Kumar
 
PDF
Postgres clusters
Stas Kelvich
 
PDF
Understanding Presto - Presto meetup @ Tokyo #1
Sadayuki Furuhashi
 
PDF
Azure Databases for PostgreSQL, MySQL and MariaDB
rockplace
 
PDF
Presto+MySQLで分散SQL
Sadayuki Furuhashi
 
PDF
Distributing Queries the Citus Way | PostgresConf US 2018 | Marco Slot
Citus Data
 
PDF
Prestogres internals
Sadayuki Furuhashi
 
PDF
Real time analytics at any scale | PostgreSQL User Group NL | Marco Slot
Citus Data
 
PDF
Elephants in the Cloud
Mike Fowler
 
Let's scale-out PostgreSQL using Citus (English)
Noriyoshi Shinoda
 
Architecting peta-byte-scale analytics by scaling out Postgres on Azure with ...
Citus Data
 
Before vs After: Redesigning a Website to be Useful and Informative for Devel...
Teresa Giacomini
 
Distributed Computing on PostgreSQL | PGConf EU 2017 | Marco Slot
Citus Data
 
PostgreSQL High Availability in a Containerized World
Jignesh Shah
 
Building the Enterprise infrastructure with PostgreSQL as the basis for stori...
PavelKonotopov
 
Postgres-XC Write Scalable PostgreSQL Cluster
Mason Sharp
 
Creating customized openSUSE versions with SUSE Studio
elliando dias
 
PostgreSQL Sharding and HA: Theory and Practice (PGConf.ASIA 2017)
Aleksander Alekseev
 
PostgreSQL on Kubernetes: Realizing High Availability with PGO (Postgres Ibiz...
NTT DATA Technology & Innovation
 
Introduction to Postrges-XC
Ashutosh Bapat
 
Beyond Postgres: Interesting Projects, Tools and forks
Sameer Kumar
 
Postgres clusters
Stas Kelvich
 
Understanding Presto - Presto meetup @ Tokyo #1
Sadayuki Furuhashi
 
Azure Databases for PostgreSQL, MySQL and MariaDB
rockplace
 
Presto+MySQLで分散SQL
Sadayuki Furuhashi
 
Distributing Queries the Citus Way | PostgresConf US 2018 | Marco Slot
Citus Data
 
Prestogres internals
Sadayuki Furuhashi
 
Real time analytics at any scale | PostgreSQL User Group NL | Marco Slot
Citus Data
 
Elephants in the Cloud
Mike Fowler
 
Ad

More from hyeongchae lee (12)

PDF
[PGDay.Seoul 2020] PostgreSQL 13 New Features
hyeongchae lee
 
PDF
[HashiTalk Korea] OCP with Super Tengen Toppa
hyeongchae lee
 
PDF
Securing Databases with Dynamic Credentials and HashiCorp’s Vault
hyeongchae lee
 
PDF
OCP with super tengen toppa
hyeongchae lee
 
PDF
PostgreSQL 정기 기술 세미나 22회
hyeongchae lee
 
PDF
PGDay.Seoul 2016 lightingtalk
hyeongchae lee
 
PDF
20141206 4 q14_dataconference_i_am_your_db
hyeongchae lee
 
PDF
osscon_mysql_redis_plugin
hyeongchae lee
 
PDF
Oracle2DBMS Notes and Comments
hyeongchae lee
 
PPTX
NewSQL
hyeongchae lee
 
PPTX
eXtremeDB FE
hyeongchae lee
 
PPTX
in-memory database system and low latency
hyeongchae lee
 
[PGDay.Seoul 2020] PostgreSQL 13 New Features
hyeongchae lee
 
[HashiTalk Korea] OCP with Super Tengen Toppa
hyeongchae lee
 
Securing Databases with Dynamic Credentials and HashiCorp’s Vault
hyeongchae lee
 
OCP with super tengen toppa
hyeongchae lee
 
PostgreSQL 정기 기술 세미나 22회
hyeongchae lee
 
PGDay.Seoul 2016 lightingtalk
hyeongchae lee
 
20141206 4 q14_dataconference_i_am_your_db
hyeongchae lee
 
osscon_mysql_redis_plugin
hyeongchae lee
 
Oracle2DBMS Notes and Comments
hyeongchae lee
 
eXtremeDB FE
hyeongchae lee
 
in-memory database system and low latency
hyeongchae lee
 

Recently uploaded (20)

PPTX
Role Of Python In Programing Language.pptx
jaykoshti048
 
PPTX
ConcordeApp: Engineering Global Impact & Unlocking Billions in Event ROI with AI
chastechaste14
 
PDF
Adobe Illustrator Crack Full Download (Latest Version 2025) Pre-Activated
imang66g
 
PDF
Applitools Platform Pulse: What's New and What's Coming - July 2025
Applitools
 
PPTX
classification of computer and basic part of digital computer
ravisinghrajpurohit3
 
PPTX
Presentation about variables and constant.pptx
safalsingh810
 
PPTX
Odoo Integration Services by Candidroot Solutions
CandidRoot Solutions Private Limited
 
PPTX
The-Dawn-of-AI-Reshaping-Our-World.pptxx
parthbhanushali307
 
PDF
WatchTraderHub - Watch Dealer software with inventory management and multi-ch...
WatchDealer Pavel
 
DOCX
Can You Build Dashboards Using Open Source Visualization Tool.docx
Varsha Nayak
 
PDF
Key Features to Look for in Arizona App Development Services
Net-Craft.com
 
PPTX
slidesgo-unlocking-the-code-the-dynamic-dance-of-variables-and-constants-2024...
kr2589474
 
PPT
Why Reliable Server Maintenance Service in New York is Crucial for Your Business
Sam Vohra
 
PDF
lesson-2-rules-of-netiquette.pdf.bshhsjdj
jasmenrojas249
 
PDF
Bandai Playdia The Book - David Glotz
BluePanther6
 
PDF
Generating Union types w/ Static Analysis
K. Matthew Dupree
 
PPTX
Explanation about Structures in C language.pptx
Veeral Rathod
 
PPTX
Presentation about Database and Database Administrator
abhishekchauhan86963
 
PDF
advancepresentationskillshdhdhhdhdhdhhfhf
jasmenrojas249
 
PDF
What to consider before purchasing Microsoft 365 Business Premium_PDF.pdf
Q-Advise
 
Role Of Python In Programing Language.pptx
jaykoshti048
 
ConcordeApp: Engineering Global Impact & Unlocking Billions in Event ROI with AI
chastechaste14
 
Adobe Illustrator Crack Full Download (Latest Version 2025) Pre-Activated
imang66g
 
Applitools Platform Pulse: What's New and What's Coming - July 2025
Applitools
 
classification of computer and basic part of digital computer
ravisinghrajpurohit3
 
Presentation about variables and constant.pptx
safalsingh810
 
Odoo Integration Services by Candidroot Solutions
CandidRoot Solutions Private Limited
 
The-Dawn-of-AI-Reshaping-Our-World.pptxx
parthbhanushali307
 
WatchTraderHub - Watch Dealer software with inventory management and multi-ch...
WatchDealer Pavel
 
Can You Build Dashboards Using Open Source Visualization Tool.docx
Varsha Nayak
 
Key Features to Look for in Arizona App Development Services
Net-Craft.com
 
slidesgo-unlocking-the-code-the-dynamic-dance-of-variables-and-constants-2024...
kr2589474
 
Why Reliable Server Maintenance Service in New York is Crucial for Your Business
Sam Vohra
 
lesson-2-rules-of-netiquette.pdf.bshhsjdj
jasmenrojas249
 
Bandai Playdia The Book - David Glotz
BluePanther6
 
Generating Union types w/ Static Analysis
K. Matthew Dupree
 
Explanation about Structures in C language.pptx
Veeral Rathod
 
Presentation about Database and Database Administrator
abhishekchauhan86963
 
advancepresentationskillshdhdhhdhdhdhhfhf
jasmenrojas249
 
What to consider before purchasing Microsoft 365 Business Premium_PDF.pdf
Q-Advise
 

patroni-based citrus high availability environment deployment

  • 1. Patroni-based citus high availability environment deployment ( 基于Patroni的Citus高可用环境部署 ) PGDay.Seoul & PGConf.Asia 2021 Daniel Lee 2021-11-24 PGDay.Seoul & PGConf.Asia 2021 1
  • 2. About Me 2021-11-24 PGDay.Seoul & PGConf.Asia 2021 2 • Dainel lee ( 李炯彩 ) • Community • MySQL Korea User Group • facebook.com/groups/mysqlko • PostgreSQL Korea • facebook.com/groups/130019777169719 • Github • github.com/dbdbdeep-git/pgday-seoul-2021-demo
  • 3. Agenda 1. Service Discovery ( *Service Mesh ) • CoreOS’s ETCD • Hashicorp’s Consul 2. Dynamic Configuration Management • ConfD • Hashicorp’s Consul-Template 3. High-Availability • Zalando’s Patroni 4. Distributed PostgreSQL as an extension • Citusdata’s Citus 5. Demo 2021-11-24 PGDay.Seoul & PGConf.Asia 2021 3
  • 4. 2021-11-24 PGDay.Seoul & PGConf.Asia 2021 4
  • 5. 1. Service Discovery 2021-11-24 PGDay.Seoul & PGConf.Asia 2021 5
  • 6. What is … 2021-11-24 PGDay.Seoul & PGConf.Asia 2021 6 Lock Service (chubby) Coordination Service (zookeeper,eureka,etcd) Service Discovery (surf,skydns,consul) Service Mesh (lstio,linkerd2)
  • 7. What can you do with Consul? 2021-11-24 PGDay.Seoul & PGConf.Asia 2021 7 Service Discovery for connectivity Service Registry enables services to register and discover each other. Service Segmentation for security Secure service-to-service communication with automatic TLS encryption and identity-based authorization. Service Configuration for runtime configuration Feature rich Key/Value store to easily configure services.
  • 8. What can you do with Consul? 2021-11-24 PGDay.Seoul & PGConf.Asia 2021 8 Consul-Kubernetes Deployments Use Consul service discovery and service mesh features with Kubernetes. Secure Service Communication Secure and observe communication between your services without modifying their code. Dynamic Load Balancing Automate load balancer configuration with Consul and HAProxy, Nginx, or F5.
  • 9. 3 Marine Admirals 2021-11-24 PGDay.Seoul & PGConf.Asia 2021 9 Properties Consul Etcd Zookeeper User Interface Available X X RPC Available Available Health Check HTTP API HTTP API TCP Key Value 3 Consistency modes (sync) Good Consistency (semi) Strong Consistency Token System Available X X Language Golang Golang Java Security ACL / HTTPS HTTPS ACL Spring Cloud O O O Multi Datacenter(gossip) O X X
  • 10. 2. Dynamic Configuration 2021-11-24 PGDay.Seoul & PGConf.Asia 2021 10
  • 11. ConfD • http://www.confd.io • Manage local application configuration files using templates and data from etcd or consul • A lightweight configuration management tool focused on: • keeping local configuration files up-to-date using data stored in etcd, consul, dynamodb, redis, vault, zookeeper, aws ssm parameter store or env vars and processing template resources. • reloading applications to pick up new config file changes 2021-11-24 PGDay.Seoul & PGConf.Asia 2021 11
  • 12. ConfD or Consul-template Architecture 2021-11-24 PGDay.Seoul & PGConf.Asia 2021 12 ETCD or Consul Server Confd or Consul-template Service Application (HAproxy, PostgreSQL) Configuration Template File Application Configuration File listen generate haproxy.cfg.tmpl haproxy.cfg reload check reload update
  • 13. PostgreSQL Client authentication 2021-11-24 PGDay.Seoul & PGConf.Asia 2021 13 Consul Server Consul-template Service Postgres Server Configuration Template File Application Configuration File listen generate pg_hba.conf.tmpl pg_hba.conf reload check reload update $ consul kv put service/database/primary/auth/client “host all haproxy 10.0.1.0/24 reject”
  • 14. 3. Zalando’s Patroni 2021-11-24 PGDay.Seoul & PGConf.Asia 2021 14
  • 15. Zalando Company 2021-11-24 PGDay.Seoul & PGConf.Asia 2021 15
  • 16. ’s Patroni • Patroni is a template for you to create your own customized, high-availability solution using Python and - for maximum accessibility - a DCS (Distributed Configuration Store) like ZooKeeper, etcd, Consul or Kubernetes. • Currently supported PostgreSQL versions: 9.3 to 14. • Release lastest 2.1.1 ( 09.11.21 ) 2021-11-24 PGDay.Seoul & PGConf.Asia 2021 16
  • 17. ’s Spilo • Spilo is a Docker image that provides PostgreSQL and Patroni bundled together. Patroni is a template for PostgreSQL HA. Multiple Spilos can create a resilient High Available PostgreSQL cluster. For this, you'll need to start all participating Spilos with identical etcd addresses and cluster names. • https://github.com/zalando/spilo 2021-11-24 PGDay.Seoul & PGConf.Asia 2021 17
  • 18. 2021-11-24 PGDay.Seoul & PGConf.Asia 2021 18
  • 19. Raft : DC to DC 2021-11-24 PGDay.Seoul & PGConf.Asia 2021 19
  • 20. HA : Patroni vs pg_auto_failover 2021-11-24 PGDay.Seoul & PGConf.Asia 2021 20
  • 21. 4. Citusdata’s Citus 2021-11-24 PGDay.Seoul & PGConf.Asia 2021 21
  • 22. Hyperscale (Citus) on Azure Database for PostgreSQL 2021-11-24 PGDay.Seoul & PGConf.Asia 2021 22
  • 23. Citusとは? by Noriyoshi Shinoda • PostgreSQL でスケールアウト環境を実現 • 複数ノードにまたがったパラレル・クエリーとパーティショニング機能 • スループット拡大を目指す • PostgreSQL の拡張(EXTENSION)として実装 • PostgreSQL 本体の変更なし • Citus Data (https://www.citusdata.com/)が開発 • 2019年1月 Microsoft による買収 • Azure Database for PostgreSQL - Hyperscale (Citus) の中核技術となっている • オープンソース版も提供(https://github.com/citusdata/citus) • 以下の機能は含まない • 自動フェイルオーバー • 自動データ・リバランス • バックアップ等の運用機能 2021-11-24 PGDay.Seoul & PGConf.Asia 2021 23 https://www.slideshare.net/noriyoshishinoda/postgresql-conference-japan-2021-b2-citus-10
  • 24. Citus 란? • PostgreSQL로 스케일 아웃 환경 실현 • 다중 노드에 걸친 병렬 쿼리 및 파티셔닝 기능 • 처리량 확대를 목표로 • PostgreSQL 확장(EXTENSION)으로 구현 • PostgreSQL 본체 변경 없음 • Citus Data (https://www.citusdata.com/) 개발 • 2019년 1월 Microsoft에서 인수 • Azure Database for PostgreSQL - Hyperscale (Citus)의 핵심 기술입니다. • 오픈 소스 버전도 제공 (https://github.com/citusdata/citus) • 다음 기능은 포함되지 않음 • 자동 장애 조치 • 자동 데이터 재조정 • 백업 등의 운용 기능 2021-11-24 PGDay.Seoul & PGConf.Asia 2021 24
  • 25. What is Citus ? • Achieve a scale-out environment with PostgreSQL • Parallel query and partitioning capabilities across multiple nodes • Aim to increase throughput • Implemented as an extension of PostgreSQL (EXTENSION) • No changes to PostgreSQL itself • Developed by Citus Data (https://www.citusdata.com/) • Acquired by Microsoft in January 2019 • Azure Database for PostgreSQL-is the core technology of Hyperscale (Citus) • Open source version is also available (https://github.com/citusdata/citus) • The following functions are not included • Automatic failover • Automatic data rebalancing • Operational functions such as backup 2021-11-24 PGDay.Seoul & PGConf.Asia 2021 25
  • 26. What is Citus ? by Noriyoshi Shinoda Instance configuration • Coordinator Node • A PostgreSQL instance that accepts connections from clients • Manage metadata • Worker Node • PostgreSQL instance that actually stores the data • No communication between Worker Nodes • Install citus EXTENSION on all nodes 2021-11-24 PGDay.Seoul & PGConf.Asia 2021 26
  • 27. What is Citus ? by Noriyoshi Shinoda Instance configuration • Processing performed by Coordinator Node • Accepting connections from clients • Final sort (ORDER BY) • Sequence processing (including SERIAL column and GENERATED AS IDENTITY column) • Handling objects other than tables and indexes • Processing executed by Worker Node • Processing SQL statements requested by Coordinator Node • Execution of ANALYZE statement • Execution of VACUUM statement • Retaining table data 2021-11-24 PGDay.Seoul & PGConf.Asia 2021 27
  • 28. CREATE EXTENSION citus; • Add nodes: postgres=> SELECT master_add_node(‘worker-01_ip_or_dns’, 5432); Postgres=> SELECT master_add_node(’worker-02_ip_or_dns’, 5432); • Create distributed table: postgres=> CREATE TABLE events ( orders_id int, ... ); postgres=> SELECT create_distributed_table( ‘orders', ‘orders_id’ ); • Events is now distributed across shards on the nodes 2021-11-24 PGDay.Seoul & PGConf.Asia 2021 28
  • 29. if(kakao) 2021 2021-11-24 PGDay.Seoul & PGConf.Asia 2021 29 https://if.kakao.com/session/59
  • 30. Table structure by Noriyoshi Shinoda Distributed table • A table that distributes and stores data • Suitable for fact tables • Specify a column as the distribution key (default determines the distribution destination table by the hash value range) • The number of divisions can be specified • citus.shard_count (default value 32) • Replicas can be created on different Worker Nodes • citus.shard_replication_factor (default value 1 = no replica) 2021-11-24 PGDay.Seoul & PGConf.Asia 2021 30
  • 31. Table structure by Noriyoshi Shinoda Distributed table • Table created in worker Node • For the table name, ShardID is added to the original table name. • If a replica is specified, a table with the same name will be created in a different Worker Node. • Same data is stored in the table with the same name • Search the citus_shards catalog to see the table names created by the Worker Node postgres=> SET citus.shard_count = 6 ; postgres=> SET citus.shard_replication_factor = 2 ; 2021-11-24 PGDay.Seoul & PGConf.Asia 2021 31 Coordinator Worker#1 Worker#2 Worker#3 Dist1 dist1_102046 dist1_102046 dist1_102047 dist1_102047 dist1_102048 dist1_102048 dist1_102049 dist1_102049 dist1_102050 dist1_102050 dist1_102051 dist1_102051
  • 32. Demo | Skip 2021-11-24 PGDay.Seoul & PGConf.Asia 2021 32
  • 33. if(kakao) 2021 2021-11-24 PGDay.Seoul & PGConf.Asia 2021 33
  • 34. Q?!A 2021-11-24 PGDay.Seoul & PGConf.Asia 2021 34