{"id":20491710,"url":"https://github.com/dalibo/pgsql-resource-agent","last_synced_at":"2025-04-13T16:55:04.330Z","repository":{"id":6578121,"uuid":"7820283","full_name":"dalibo/pgsql-resource-agent","owner":"dalibo","description":"Simple Pacemaker OCF Agent for two PostgreSQL servers in streaming replication","archived":false,"fork":false,"pushed_at":"2016-03-16T08:24:42.000Z","size":183,"stargazers_count":11,"open_issues_count":0,"forks_count":5,"subscribers_count":27,"default_branch":"master","last_synced_at":"2025-03-27T07:51:31.610Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dalibo.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}},"created_at":"2013-01-25T13:06:03.000Z","updated_at":"2023-10-30T23:29:18.000Z","dependencies_parsed_at":"2022-09-14T04:50:15.738Z","dependency_job_id":null,"html_url":"https://github.com/dalibo/pgsql-resource-agent","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dalibo%2Fpgsql-resource-agent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dalibo%2Fpgsql-resource-agent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dalibo%2Fpgsql-resource-agent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dalibo%2Fpgsql-resource-agent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dalibo","download_url":"https://codeload.github.com/dalibo/pgsql-resource-agent/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248750011,"owners_count":21155682,"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":[],"created_at":"2024-11-15T17:25:38.864Z","updated_at":"2025-04-13T16:55:04.307Z","avatar_url":"https://github.com/dalibo.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"__WARNING__\n\nAfter leaving in this repository for some time, the multistate agent ``pgsqlms``\nhas acquired its own identity! See: https://github.com/dalibo/PAF\n\nThe development effort is currently geared towards PAF and activity on\n``pgsql-resource-agent`` is reduced to the minimum. We recommend you to use PAF\nin priority.\n\n# pgsql-resource-agent\n\nSimple Pacemaker OCF Agent for PostgreSQL servers in streaming replication.\n\nThis resource agent is stateless (do not know what is a master or slave\nresource) from the Pacemaker point of view. It is very limited, simple,\nallowing only one failover then wait for an administrator action. It only shows\nPacemaker where the master instance is located. Should a failover occurs, it\nwill promote the slave on the designated node.\n\nSupports PostgreSQL 9.0 and more.\n\n\n\n## Description\n\nThis agent, called ``pgsqlsr``, suppose PostgreSQL instances are already set up\nfor replication: one master and N standby. \n\nIt has been designed to forbid more than **one** failover, so only one failover\ncould be automated. After a failover, an administrator action is required to \ncleanup the situation.\n\nBecause this agent is stateless, Pacemaker does not monitor slaves and has no\nclue about their situation. There is no logic whatsoever in case of\nfailover. Should a failover occurs, the agent is not able to hint Pacemaker\nabout the best standby to promote. The comportment is unpredictable.\n\nThat is why this resource agent is best used in two nodes clusters. With more\nthan 1 standby, the administrator is in charge to make sure the best standby\nwill be elected (using location constraints, synchronous replication,\ncascading, ...).\n\nTo forbid more than one failover, the resource parameter ``startable`` is set to \nthe hostname of the promoted standby. As soon as this parameter is created and \nset, the only instance able to start will be the one designated there.\n\nAfter a failover, you will have to:\n\n  * rebuild your standby(s) if needed (eg. rebuild the old master as a slave)\n  * start PostgreSQL on standby(s)i\n  * cleanup your Pacemaker ressources, eg.: ``crm resource cleanup pgsqld``, \n    ``crm resource cleanup pgsql-ip``\n  * check that everything works fine\n  * Allow a new automated failover: ``crm_resource --resource pgsqld --delete-parameter startable``\n\n## Installation\n\nJust copy the file ``pgsqlsr`` to your OCF_ROOT folder (usually\n``/usr/lib/ocf/resource.d/heartbeat/``). Make sure the file has the executable\nright and its owner is the same than the other scripts there.\n\n## Configuration\n\nThis agent has been written to give to the administrator the maximum control\nover their PostgreSQL configuration and architecture. Thus, you are 100%\nresponsible for the master/slave creations and their configuration. The agent\nwill NOT edit your setup. You just have to follow these pre-requisites:\n\n  * you __must__ give the location of your master during your cluster setup \n  * the cluster resource manager is responsible to start and stop your\n    PostgreSQL instances.\n\nWhen setting up the resource in Pacemaker, here are the available parameters you\ncan set:\n\n  * ``bindir``: location of the PostgreSQL binaries (default: ``/usr/bin``)\n  * ``pgdata``: location of the PGDATA of your instance (default:\n    ``/var/lib/pgsql/data``)\n  * ``system_user``: the system owner of your instance's processus (default:\n    postgres)\n  * ``trigger_file``: the trigger file to use to promote the slave instance.\n    This one is useful only for PostgreSQL 9.0, where ``pg_ctl promote`` does\n    not exists.\n\n## Cluster setup example\n\nHere is a cluster setup example, based on CentOS 5.x, using the ``crm`` command:\n\n```\ncrm \u003c\u003cEOF\nconfigure erase\nconfigure\n  # Step 1\n  rsc_defaults resource-stickiness=\"INFINITY\"\n  rsc_defaults migration-threshold=5\n\n  # Step 2\n  property stonith-enabled=\"true\"\n  property no-quorum-policy=\"ignore\"\n\n  # Step 3\n  primitive pgsql-ip ocf:heartbeat:IPaddr2    \\\n    params ip=\"172.16.4.80\" cidr_netmask=\"24\" \\\n    op monitor interval=\"20s\"\n\n  # Step 4\n  primitive pgsqld ocf:heartbeat:pgsqlsr                                \\\n    params bindir=\"/usr/pgsql-9.0/bin\" pgdata=\"/var/lib/pgsql/9.0/data\" \\\n    trigger_file=\"/var/lib/pgsql/9.0/data/promote\"                      \\\n    op start timeout=\"120\"                                              \\\n    op stop timeout=\"120\"                                               \\\n    op monitor interval=\"5s\"\n  location prefer-pgsqld-on-srv1 pgsqld 10: srv1\n\n  # Step 5\n  colocation pgsqld_with_pgsql-ip inf: pgsql-ip pgsqld\n  order ip-after-pgsqld inf: pgsqld pgsql-ip\n\n  # Step 6\n  primitive stonith_meatware stonith:meatware params hostlist=\"srv1 srv2\"\n  clone fencing stonith_meatware\n\n  # Step 7\n  commit\n  show\nbye\nEOF\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdalibo%2Fpgsql-resource-agent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdalibo%2Fpgsql-resource-agent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdalibo%2Fpgsql-resource-agent/lists"}