{"id":28834721,"url":"https://github.com/worthant/rpi-psql-cluster","last_synced_at":"2026-04-28T16:06:28.913Z","repository":{"id":298971815,"uuid":"985644005","full_name":"worthant/rpi-psql-cluster","owner":"worthant","description":"Portable highly available PostgreSQL cluster, built with Raspberry Pi 5 boards, pgpool2, and ESP32-based monitoring dashboard","archived":false,"fork":false,"pushed_at":"2025-06-13T21:55:06.000Z","size":27,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-13T22:37:17.906Z","etag":null,"topics":["esp32","pgpool-cluster","pgpool-ii","postgresql","raspberry-pi","spi","uart"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/worthant.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-05-18T08:04:59.000Z","updated_at":"2025-06-13T21:55:10.000Z","dependencies_parsed_at":"2025-06-13T22:37:25.350Z","dependency_job_id":"6c49588b-43f2-4a97-9da9-f2b23909d00e","html_url":"https://github.com/worthant/rpi-psql-cluster","commit_stats":null,"previous_names":["worthant/rpi-psql-cluster"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/worthant/rpi-psql-cluster","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/worthant%2Frpi-psql-cluster","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/worthant%2Frpi-psql-cluster/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/worthant%2Frpi-psql-cluster/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/worthant%2Frpi-psql-cluster/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/worthant","download_url":"https://codeload.github.com/worthant/rpi-psql-cluster/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/worthant%2Frpi-psql-cluster/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260726757,"owners_count":23053232,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["esp32","pgpool-cluster","pgpool-ii","postgresql","raspberry-pi","spi","uart"],"created_at":"2025-06-19T09:41:52.730Z","updated_at":"2026-04-28T16:06:28.907Z","avatar_url":"https://github.com/worthant.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"This project helped me winning **Selectel Career Wave**!\n\nWIP: Add award photo, enhance readme quality, add monitoring services code, and a pgpool2 setup\n\n## Demo\n\nhttps://github.com/user-attachments/assets/0a9c1fa0-1200-4319-828b-c59e3ecd1ecc\n\n\u003e [!NOTE]\n\u003e **Why?**\n\u003e 1. For FUN (not everything needs to be built for profit!)\n\u003e 2. To demonstrate my skills in multiple fields\n\u003e 3. Don't you want a relatively small production ready database cluster that you can **CARRY AROUND** ? Cmon now.\n\u003e 4. To drain my wallet. I work for a reason, right?\n\n## What is it?\n\n```mermaid\ngraph BT\n    %% Power Infrastructure\n    PowerBank[⚡ 20,000mAh Power Bank\u003cbr/\u003e~50W Power Delivery]\n    \n    %% Network Infrastructure  \n    Switch[🔌 1 Gbps Network Switch]\n    \n    %% Computing Nodes\n    Laptop[💻 Laptop\u003cbr/\u003eFedora Workstation 41\u003cbr/\u003eOptional Main Node]\n    RPi1[🔴 Raspberry Pi 5 #1\u003cbr/\u003eUbuntu Server LTS 42\u003cbr/\u003e512GB PCIe SSD]\n    RPi2[🔴 Raspberry Pi 5 #2\u003cbr/\u003eUbuntu Server LTS 42\u003cbr/\u003e512GB PCIe SSD]\n    RPi3[🔴 Raspberry Pi 5 #3\u003cbr/\u003eUbuntu Server LTS 42\u003cbr/\u003e512GB PCIe SSD]\n    \n    %% Monitoring Hardware\n    ESP32[📡 ESP32 Board\u003cbr/\u003ePlatformIO + Arduino/ESP-IDF]\n    Screen[📺 240x240 IPS Display\u003cbr/\u003eReal-time Monitoring]\n    \n    %% Database Layer\n    subgraph DB [\" 🗄️ PostgreSQL Cluster Layer\"]\n        PG1[PostgreSQL\u003cbr/\u003ePrimary/Replica]\n        PG2[PostgreSQL\u003cbr/\u003ePrimary/Replica] \n        PG3[PostgreSQL\u003cbr/\u003ePrimary/Replica]\n        PGLaptop[PostgreSQL\u003cbr/\u003ePrimary/Replica]\n        PGPool[pgpool2\u003cbr/\u003eLoad Balancer \u0026 Failover]\n    end\n    \n    %% Monitoring Layer\n    subgraph MON [\" 📊 Monitoring Layer\"]\n        MonScript1[Python Monitoring\u003cbr/\u003eSystem Stats]\n        MonScript2[Python Monitoring\u003cbr/\u003eSystem Stats]\n        MonScript3[Python Monitoring\u003cbr/\u003eSystem Stats]\n        MonDisplay[Real-time Display\u003cbr/\u003eCluster Status]\n    end\n    \n    %% Power Connections\n    PowerBank -.-\u003e|Power| Switch\n    PowerBank -.-\u003e|Power| RPi1\n    PowerBank -.-\u003e|Power| RPi2  \n    PowerBank -.-\u003e|Power| RPi3\n    PowerBank -.-\u003e|Power| ESP32\n    \n    %% Network Connections\n    Switch \u003c--\u003e|Ethernet| Laptop\n    Switch \u003c--\u003e|Ethernet| RPi1\n    Switch \u003c--\u003e|Ethernet| RPi2\n    Switch \u003c--\u003e|Ethernet| RPi3\n    \n    %% Physical Monitoring Connections\n    ESP32 \u003c--\u003e|SPI| Screen\n    RPi1 \u003c--\u003e|UART| ESP32\n    RPi2 -.-\u003e|UDP Socket| RPi1\n    RPi3 -.-\u003e|UDP Socket| RPi1\n    \n    %% Database Logical Connections\n    Laptop --\u003e PGLaptop\n    RPi1 --\u003e PG1\n    RPi2 --\u003e PG2\n    RPi3 --\u003e PG3\n    \n    PGPool \u003c--\u003e PG1\n    PGPool \u003c--\u003e PG2\n    PGPool \u003c--\u003e PG3\n    PGPool \u003c--\u003e PGLaptop\n    \n    PG1 \u003c-.-\u003e|Async/Sync\u003cbr/\u003eReplication| PG2\n    PG2 \u003c-.-\u003e|Async/Sync\u003cbr/\u003eReplication| PG3\n    PG3 \u003c-.-\u003e|Async/Sync\u003cbr/\u003eReplication| PGLaptop\n    PG1 \u003c-.-\u003e|Async/Sync\u003cbr/\u003eReplication| PGLaptop\n    \n    %% Monitoring Logical Connections\n    RPi1 --\u003e MonScript1\n    RPi2 --\u003e MonScript2\n    RPi3 --\u003e MonScript3\n    \n    MonScript1 -.-\u003e|Stats| ESP32\n    MonScript2 -.-\u003e|Stats| ESP32\n    MonScript3 -.-\u003e|Stats| ESP32\n    \n    ESP32 --\u003e MonDisplay\n    Screen --\u003e MonDisplay\n    \n    %% Styling\n    classDef powerStyle fill:#ff6b6b,stroke:#d63447,stroke-width:2px,color:#fff\n    classDef networkStyle fill:#4ecdc4,stroke:#26a69a,stroke-width:2px,color:#fff  \n    classDef computeStyle fill:#45b7d1,stroke:#2980b9,stroke-width:2px,color:#fff\n    classDef monitorStyle fill:#f9ca24,stroke:#f0932b,stroke-width:2px,color:#000\n    classDef dbStyle fill:#6c5ce7,stroke:#5f3dc4,stroke-width:2px,color:#fff\n    \n    class PowerBank powerStyle\n    class Switch networkStyle\n    class Laptop,RPi1,RPi2,RPi3 computeStyle\n    class ESP32,Screen monitorStyle\n    class PG1,PG2,PG3,PGLaptop,PGPool dbStyle\n```\n\n\n### Components\n\n0. My laptop (optional, as a main node)\n1. 2/3x raspberry pi 5 boards + 512gb pcie gen3 ssd\n2. 1 Gbps switch\n3. 20.000 mah power bank with Power Delivery (~50w for 3 pi boards and switch)\n4. esp32 board and a 240x240 IPS screen (simple monitoring)\n\n### Interconnection\n\n1. esp32 \u003c-- SPI --\u003e IPS screen\n2. main rpi5 \u003c-- UART --\u003e esp32\n3. adjacent rpi5's \u003c-- UDP socket --\u003e main rpi5\n4. laptop \u003c-- network switch (postgres networking) --\u003e rpi5 boards cluster\n\n### Software Used\n\n1. It's a PostgreSQL cluster with configured async and sync replication on different nodes. Any node can be a main one - can be my laptop, can be any other node.\n2. pgpoolII - for load balancing and a failover script to search and promote other nodes when the main one fails\n3. Ubuntu Server LTS 42 as an OS on rpi5 boards, and Fedora Workstation 41 as an OS on my laptop\n4. PlatformIO with arduino/esp-idf frameworks to program esp32 board.\n5. Python with some libs to write monitoring scripts for rpi5's\n\n\u003e also some docker action, bash scripting, a lot of UNIX administration like networking, privileges e.t.c. (not important)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fworthant%2Frpi-psql-cluster","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fworthant%2Frpi-psql-cluster","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fworthant%2Frpi-psql-cluster/lists"}