LinuxLV · Pacemaker and CorosyncPacemaker
Pacemaker architecture - the resource manager
What you'll learn
- Describe Pacemaker's role
- Explain resource agents and constraints
- Read cluster status and understand state
- Configure a simple resource
Prerequisites
Verified against Ubuntu 24.04 LTS · Debian 12 (Bookworm) · RHEL 9.x · Rocky Linux 9.x · AlmaLinux 9.x · Linux kernel 6.1 LTS / 6.6 LTS · systemd 255+ · OpenSSH 8.7p1 (RHEL 9) / 9.6p1 (Ubuntu 24.04) · nftables 1.0.x · chrony 4.x · Pacemaker 2.1.x · Corosync 3.1.x · 2026-08-09
Pacemaker is the resource manager for a Corosync cluster. It decides which node runs which resource, monitors the resources, and triggers failover when needed.
What Pacemaker does
Pacemaker sits on top of Corosync:
- Decides which node runs which resource.
- Monitors resource health.
- Fails over when a resource fails.
- Enforces constraints (e.g. “DB must be on a different node than the application”).
Pacemaker does not know how to manage a specific service (e.g. PostgreSQL). It uses resource agents (RAs) for that.
Resource agents
An RA is a script (or compiled binary) that knows how to manage a service:
start: start the service.stop: stop the service.monitor: check if the service is running.promote/demote: for master/slave resources.migrate: for live migration.
Standard RAs are shipped with the resource-agents package
and cover most services (PostgreSQL, MySQL, nginx, etc.).
For custom services, write a custom RA.
Configure a resource
# Apache
pcs resource create web apache \
configfile=/etc/apache2/apache2.conf \
statusurl=http://localhost/server-status
# PostgreSQL
pcs resource create db pgsql \
pgctl=/usr/bin/pg_ctl \
psql=/usr/bin/psql \
pgdata=/var/lib/pgsql/data \
op monitor interval=30s
# IP address
pcs resource create vip ocf:heartbeat:IPaddr2 \
ip=10.0.0.100 \
op monitor interval=30s
Pacemaker creates the resource, monitors it, and starts it on a node.
Constraints
Constraints tell Pacemaker where resources can run:
# Location: web must run on node1 or node2
pcs constraint location web prefers node1
pcs constraint location web prefers node2
# Colocation: db must run on the same node as web
pcs constraint colocation add web with db
# Order: db starts before web
pcs constraint order db then web
Three types:
- Location: where a resource can run.
- Colocation: which resources run together.
- Order: which resources start/stop first.
Cluster status
pcs status
Output:
Cluster name: mycluster
Stack: corosync
Current DC: node2 (version 2.x) - partition with quorum
Last updated: ...
3 nodes configured
3 resources configured
Online: [ node1 node2 node3 ]
Full list of resources:
* web (ocf::heartbeat:apache): Started node2
* db (ocf::heartbeat:pgsql): Master node2
* vip (ocf::heartbeat:IPaddr2): Started node2
The output shows:
- Cluster name and stack.
- Current DC (designated coordinator).
- Quorum status.
- Nodes online.
- Resources and their state.
Failover
When a resource fails:
- Pacemaker detects via the monitor operation.
- Pacemaker applies constraints and decides the new node.
- Pacemaker stops the resource on the failed node.
- Pacemaker starts the resource on the new node.
If the new node is unreachable, fencing kicks in.
Knowledge check
Knowledge check · 3 questions
Q1. What is Pacemaker's role in a Corosync cluster?
Q2. Pacemaker knows how to manage every service.
Q3. Which of the following are valid types of Pacemaker constraints? Select all that apply.
Passing score: 75%. Answers are checked in this browser.