{"id":25940492,"url":"https://github.com/pgsuite/pgvip","last_synced_at":"2026-05-13T02:05:23.684Z","repository":{"id":278930598,"uuid":"937203306","full_name":"PGSuite/PGVIP","owner":"PGSuite","description":"Auto failover to standby PostgreSQL using virtual IP","archived":false,"fork":false,"pushed_at":"2025-05-17T17:21:50.000Z","size":318,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-17T18:26:53.830Z","etag":null,"topics":["autofailover","master","postgres","postgresql","standby","switch"],"latest_commit_sha":null,"homepage":"https://pgvip.org","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PGSuite.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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-02-22T15:27:50.000Z","updated_at":"2025-05-17T17:21:53.000Z","dependencies_parsed_at":"2025-02-22T16:32:22.405Z","dependency_job_id":"2b627a7e-1f66-448d-9d7d-007ec9c2ecc4","html_url":"https://github.com/PGSuite/PGVIP","commit_stats":null,"previous_names":["pgsuite/pgvip"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/PGSuite/PGVIP","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PGSuite%2FPGVIP","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PGSuite%2FPGVIP/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PGSuite%2FPGVIP/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PGSuite%2FPGVIP/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PGSuite","download_url":"https://codeload.github.com/PGSuite/PGVIP/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PGSuite%2FPGVIP/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32964445,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-12T23:30:32.555Z","status":"online","status_checked_at":"2026-05-13T02:00:07.132Z","response_time":115,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["autofailover","master","postgres","postgresql","standby","switch"],"created_at":"2025-03-04T05:16:52.992Z","updated_at":"2026-05-13T02:05:23.678Z","avatar_url":"https://github.com/PGSuite.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"## PGVIP | Auto failover to standby PostgreSQL using virtual IP\n\nPGVIP - auto failover service from master to standby PostgreSQL database using virtual (floating) IP address\n\nThe service is installed on one server, which is a [single point of failure](https://en.wikipedia.org/wiki/Single_point_of_failure) (example, nginx proxy), or on any two servers (hereinafter referred to as web servers).\nThere is no need to install anything on the database servers; the web server connects to them via ssh and executes commands from the configuration file.\nAdministrator performs initial setup of the standby database and reverse switch manually.\n\n\u003cb\u003eFailover schemas\u003c/b\u003e\n\n![Failover schema for one web server](doc/failover-schema-single.png)\n\n![Failover schema for multiple web servers](doc/failover-schema-multiple.png)\n\nTechnically, the PGVIP service is implemented as a wrapper that executes operating system commands from a configuration file.\nIt was originally developed as a bash script, then rewritten in C language.\n\n  \n**Main actions** performed by the pgvip service:\n\n*   checking the availability of the master database and the lag of the standby database, the status of the virtual IP address (up/down)\n*   managing a virtual IP address, running a script to automatically turn it off (necessary if the connection is lost)\n*   activation (promotion) of a standby database and transfer of a virtual IP address\n\nAll actions in the documentation file [doc/documentation.html](https://htmlpreview.github.io/?https://github.com/PGSuite/PGVIP/blob/main/doc/documentation.html#actions)  \n\nOverview on site [pgvip.pgsuite.org](https://pgvip.pgsuite.org/)\n\n### Installation ### \n\nPGVIP is installed only on web servers, not on database servers.\n\n0\\. Preparation  \n    reserve a virtual IP address (for example, in the DHCP server)  \n    set up ssh connection via key from web server to database servers  \n\n1\\. Clone repository  \n```git clone https://github.com/PGSuite/PGVIP.git```  \n```cd PGVIP```  \n\n2\\. Make  \n```make```\n\n3\\. Install  \n```make install ip_master=[ip_master] ip_standby=[ip_standby] ip_virtual=[ip_virtual] subnet_mask=[subnet_mask] ```  \nexample:  \n```make install ip_master=192.168.56.1 ip_standby=192.168.56.2 ip_virtual=192.168.56.10 subnet_mask=24 ```\n\n4\\. Start service  \n```systemctl --now enable pgvip ```\n\n5\\. Check status and system log  \n```systemctl status pgvip ```  \n```pgvip status ```  \n```journalctl -fu pgvip (or tail -f /var/log/pgsuite/pgvip.log)```  \n\n### Configuration ### \n\n/etc/pgsuite/pgvip.conf - configuration file, copied by the \u003cem\u003emake install\u003c/em\u003e command, which writes IP addresses into it.\nTo change the parameters, need to edit the file and restart the service by executing \u003cem\u003esystemctl restart pgvip\u003c/em\u003e\n\nThe run-time configuration with the final OS commands can be viewed using the command  \n```pgvip show config ```  \nexample:  \n```pgvip show config | grep command_master_db_state ```  \nto check, the printed command can be executed in the command line\n\n### Failover example ### \n\n```bash\n[root@web-server ~]# pgvip status\nstatus: SUCCESS (duration: 0 00:00:32)\n\n+---------+--------------+-------------------------+---------------+---------------+\n| Role    | IP address   | Database state          | 192.168.56.10 | VIP auto down |\n+---------+--------------+-------------------------+---------------+---------------+\n| master  | 192.168.56.1 | read-write              | up on enp0s3  | executing     |\n| standby | 192.168.56.2 | in recovery, lag 0 min. | down          | executing     |\n+---------+--------------+-------------------------+---------------+---------------+\n\n\n[root@web-server ~]# pgvip status\nstatus: ERROR (duration: 0 00:00:14, cause: master db is not read-write)\n\n+---------+--------------+-------------------------+---------------+---------------+\n| Role    | IP address   | Database state          | 192.168.56.10 | VIP auto down |\n+---------+--------------+-------------------------+---------------+---------------+\n| master  | 192.168.56.1 | not available           | not available | not available |\n| standby | 192.168.56.2 | in recovery, lag 0 min. | down          | executing     |\n+---------+--------------+-------------------------+---------------+---------------+\n\n\n[root@web-server ~]# pgvip status\nstatus: STANDBY_PROMOTED (duration: 0 00:00:06)\n\n+---------+--------------+----------------+---------------+---------------+\n| Role    | IP address   | Database state | 192.168.56.10 | VIP auto down |\n+---------+--------------+----------------+---------------+---------------+\n| master  | 192.168.56.1 | not available  | not available | not available |\n| standby | 192.168.56.2 | read-write     | up on enp0s3  | executing     |\n+---------+--------------+----------------+---------------+---------------+\n```\n\n### Important qualities ### \n\n*   **Any standby database** - there are no requirements for a standby database. The standby database may have a lag (recovery\\_min\\_apply\\_delay parameter), using WAL segment files from backup (restore\\_command parameter) without creating a replication slot\n*   **Direct connection** - the virtual IP address is activated (up) on the network interface with the physical address, connection to the database occurs without intermediate layers\n*   **No DBA required** - installation and configuration can be performed by a system administrator at the junior level, modification - by a system administrator at the middle level\n*   **Easy installation** - installation consists of two operations: setting up ssh keys and executing the _make install_ command\n*   **Making is optional** - making has already been completed, because does not depend on Linux versions and does not require additional libraries. If necessary, executed with one _gcc_ command\n*   **All commands are customizable** - pgvip service only executes operating system commands from the configuration file. To check, the administrator can execute any in command line\n*   **Obvious action log** - When an action is executed, printed to log: action name, condition, status (_pgvip status_), OS command with output. The action name and condition are actual C code snippets from the action.c file, obtained by the macro #define #\\[name\\]\n*   **Actions without history** - actions are performed only depending on the current status, it is possible not to save information about the state of databases and do not synchronize web servers\n\n### Support ### \n\nOf course you can create an issue, I will answer all requests.  \nAlso I will help to install and use the tool.  \nWelcome to discussion !  \n\nWhatsApp: [PGSuite (+7-936-1397626)](https://wa.me/79361397626)  \nemail: [support\\@pgsuite.org](mailto:support@pgsuite.org?subject=PGXLS)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpgsuite%2Fpgvip","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpgsuite%2Fpgvip","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpgsuite%2Fpgvip/lists"}