<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Arch on PIGSTY</title>
    <link>https://v27.pgsty.pro/categories/arch/</link>
    <description>Recent content in Arch on PIGSTY</description>
    <generator>Hugo</generator>
    <language>en-US</language>
    
    
    
      <lastBuildDate>Mon, 01 Jan 0001 00:00:00 +0000</lastBuildDate>
    
    
      <atom:link href="https://v27.pgsty.pro/categories/arch/index.xml" rel="self" type="application/rss+xml" />
    
    <item>
        <title>Architecture</title>
        <link>https://v27.pgsty.pro/docs/concept/arch/</link>
        <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
        
        <guid>https://v27.pgsty.pro/docs/concept/arch/</guid>
        <description>&lt;blockquote&gt;&#xA;&lt;p&gt;Modular Architecture and Declarative Interface!&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Pigsty deployment is described by config inventory and materialized with ansible playbooks.&lt;/li&gt;&#xA;&lt;li&gt;Pigsty works on &lt;a href=&#34;https://v27.pgsty.pro/docs/reference/compatibility/&#34;&gt;Linux&lt;/a&gt; x86_64 common nodes, i.e., bare metals or virtual machines.&lt;/li&gt;&#xA;&lt;li&gt;Pigsty uses a modular design that can be freely composed for different scenarios.&lt;/li&gt;&#xA;&lt;li&gt;The config controls &lt;strong&gt;where&lt;/strong&gt; &amp;amp; &lt;strong&gt;how&lt;/strong&gt; to install modules with &lt;strong&gt;parameters&lt;/strong&gt;&lt;/li&gt;&#xA;&lt;li&gt;The playbooks will adjust nodes into the desired status in an idempotent manner.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;hr&gt;&#xA;&lt;h2 id=&#34;modules&#34;&gt;Modules&#xA;&lt;/h2&gt;&#xA;&lt;p&gt;Pigsty uses a modular design, and there are six default modules: &lt;a href=&#34;https://v27.pgsty.pro/docs/pgsql/&#34;&gt;&lt;code&gt;PGSQL&lt;/code&gt;&lt;/a&gt;, &lt;a href=&#34;https://v27.pgsty.pro/docs/infra/&#34;&gt;&lt;code&gt;INFRA&lt;/code&gt;&lt;/a&gt;, &lt;a href=&#34;https://v27.pgsty.pro/docs/node/&#34;&gt;&lt;code&gt;NODE&lt;/code&gt;&lt;/a&gt;, &lt;a href=&#34;https://v27.pgsty.pro/docs/etcd/&#34;&gt;&lt;code&gt;ETCD&lt;/code&gt;&lt;/a&gt;, &lt;a href=&#34;https://v27.pgsty.pro/docs/redis/&#34;&gt;&lt;code&gt;REDIS&lt;/code&gt;&lt;/a&gt;, and &lt;a href=&#34;https://v27.pgsty.pro/docs/minio/&#34;&gt;&lt;code&gt;MINIO&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;</description>
      </item>
    <item>
        <title>Architecture</title>
        <link>https://v27.pgsty.pro/docs/pgsql/arch/</link>
        <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
        
        <guid>https://v27.pgsty.pro/docs/pgsql/arch/</guid>
        <description>&lt;h2 id=&#34;component-overview&#34;&gt;Component Overview&#xA;&lt;/h2&gt;&#xA;&lt;p&gt;Here is how PostgreSQL module components and their interactions. From top to bottom:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Cluster DNS is resolved by DNSMASQ on infra nodes&lt;/li&gt;&#xA;&lt;li&gt;Cluster VIP is manged by &lt;code&gt;vip-manager&lt;/code&gt;, which will bind to cluster primary.&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;vip-manager&lt;/code&gt; will acquire cluster leader info written by &lt;code&gt;patroni&lt;/code&gt; from &lt;code&gt;etcd&lt;/code&gt; cluster directly&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;Cluster services are exposed by Haproxy on nodes, services are distinguished by node ports (543x).&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Haproxy port 9101: monitoring metrics &amp;amp; stats &amp;amp; admin page&lt;/li&gt;&#xA;&lt;li&gt;Haproxy port 5433: default service that routes to primary pgbouncer: &lt;a href=&#34;https://v27.pgsty.pro/docs/pgsql/svc/#primary-service&#34;&gt;primary&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Haproxy port 5434: default service that routes to replica pgbouncer: &lt;a href=&#34;https://v27.pgsty.pro/docs/pgsql/svc/#replica-service&#34;&gt;replica&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Haproxy port 5436: default service that routes to primary postgres: &lt;a href=&#34;https://v27.pgsty.pro/docs/pgsql/svc/#default-service&#34;&gt;default&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Haproxy port 5438: default service that routeroutesto offline postgres: &lt;a href=&#34;https://v27.pgsty.pro/docs/pgsql/svc/#offline-service&#34;&gt;offline&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;HAProxy will route traffic based on health check information provided by &lt;code&gt;patroni&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;Pgbouncer is a connection pool middleware that buffers connections, exposes extra metrics, and brings extra flexibility @ port 6432&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Pgbouncer is stateless and deployed with the Postgres server in a 1:1 manner through a local unix socket.&lt;/li&gt;&#xA;&lt;li&gt;Production traffic (Primary/Replica) will go through pgbouncer by default (can be skipped by &lt;a href=&#34;https://v27.pgsty.pro/docs/reference/param/#pg_default_service_dest&#34;&gt;&lt;code&gt;pg_default_service_dest&lt;/code&gt;&lt;/a&gt; )&lt;/li&gt;&#xA;&lt;li&gt;Default/Offline service will always bypass pgbouncer and connect to target Postgres directly.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;Postgres provides relational database services @ port 5432&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Install PGSQL module on multiple nodes will automatically form a HA cluster based on streaming replication&lt;/li&gt;&#xA;&lt;li&gt;PostgreSQL is supervised by &lt;code&gt;patroni&lt;/code&gt; by default.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;Patroni will &lt;strong&gt;supervise&lt;/strong&gt; PostgreSQL server @ port 8008 by default&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Patroni spawn postgres servers as the child process&lt;/li&gt;&#xA;&lt;li&gt;Patroni uses &lt;code&gt;etcd&lt;/code&gt; as DCS: config storage, failure detection, and leader election.&lt;/li&gt;&#xA;&lt;li&gt;Patroni will provide Postgres information through a health check. Which is used by HAProxy&lt;/li&gt;&#xA;&lt;li&gt;Patroni metrics will be scraped by prometheus on infra nodes&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;PG Exporter will expose postgres metrics @ port 9630&#xA;&lt;ul&gt;&#xA;&lt;li&gt;PostgreSQL&amp;rsquo;s metrics will be scraped by prometheus on infra nodes&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;Pgbouncer Exporter will expose pgbouncer metrics @ port 9631&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Pgbouncer&amp;rsquo;s metrics will be scraped by prometheus on infra nodes&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;pgBackRest will work on the local repo by default (&lt;a href=&#34;https://v27.pgsty.pro/docs/reference/param/#pgbackrest_method&#34;&gt;&lt;code&gt;pgbackrest_method&lt;/code&gt;&lt;/a&gt;)&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If &lt;code&gt;local&lt;/code&gt; (default) is used as the backup repo, pgBackRest will create local repo under the primary&amp;rsquo;s &lt;a href=&#34;https://v27.pgsty.pro/docs/reference/param/#pg_fs_bkup&#34;&gt;&lt;code&gt;pg_fs_bkup&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;If &lt;code&gt;minio&lt;/code&gt; is used as the backup repo, pgBackRest will create the repo on the dedicated MinIO cluster in &lt;a href=&#34;https://v27.pgsty.pro/docs/reference/param/#pgbackrest_repo&#34;&gt;&lt;code&gt;pgbackrest_repo&lt;/code&gt;.&lt;code&gt;minio&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;Postgres-related logs (postgres,pgbouncer,patroni,pgbackrest) are exposed by promtail @ port 9080&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Promtail will send logs to Loki on infra nodes&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;a href=&#34;https://v27.pgsty.pro/docs/infra/&#34;&gt;&lt;img class=&#34;td-image&#34; src=&#34;https://v27.pgsty.pro/img/pigsty/arch.jpg&#34; alt=&#34;pigsty-arch.jpg&#34; loading=&#34;lazy&#34; decoding=&#34;async&#34;&gt;&lt;/a&gt;&lt;/p&gt;</description>
      </item>
    <item>
        <title>Cluster Model</title>
        <link>https://v27.pgsty.pro/docs/concept/model/</link>
        <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
        
        <guid>https://v27.pgsty.pro/docs/concept/model/</guid>
        <description>&lt;p&gt;PGSQL for production environments is organized in &lt;strong&gt;clusters&lt;/strong&gt;, which &lt;strong&gt;clusters&lt;/strong&gt; are &lt;strong&gt;logical entities&lt;/strong&gt; consisting of a set of database &lt;strong&gt;instances&lt;/strong&gt; associated by &lt;strong&gt;primary-replica&lt;/strong&gt;.&#xA;Each &lt;strong&gt;database cluster&lt;/strong&gt; is an autonomous serving unit consisting of at least one  &lt;strong&gt;database instance&lt;/strong&gt; (primary).&lt;/p&gt;&#xA;&lt;hr&gt;&#xA;&lt;h2 id=&#34;er-diagram&#34;&gt;ER Diagram&#xA;&lt;/h2&gt;&#xA;&lt;p&gt;Let&amp;rsquo;s get started with ER diagram. There are four types of core entities in Pigsty&amp;rsquo;s PGSQL module:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;PGSQL Cluster&lt;/strong&gt;: An autonomous PostgreSQL business unit, used as the top-level namespace for other entities.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;PGSQL Service&lt;/strong&gt;: A named abstraction of cluster ability, route traffics, and expose postgres services with node ports.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;PGSQL Instance&lt;/strong&gt;: A single postgres server which is a group of running processes &amp;amp; database files on a single node.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;PGSQL Node&lt;/strong&gt;: An abstraction of hardware resources, which can be bare metal, virtual machine, or even k8s pods.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;img class=&#34;td-image&#34; src=&#34;https://v27.pgsty.pro/img/pigsty/er.jpg&#34; alt=&#34;pigsty-er.jpg&#34; loading=&#34;lazy&#34; decoding=&#34;async&#34;&gt;&lt;p&gt;&lt;strong&gt;Naming Convention&lt;/strong&gt;&lt;/p&gt;</description>
      </item>
    
  </channel>
</rss>
