Resource Groups
Pacemaker resources represent the services, IP addresses, or filesystems that your cluster manages to ensure high availability. Defining and managing these resources is critical to configuring a resilient cluster. This section provides step-by-step guidance for creating and managing resources using the pcs (Pacemaker Cluster Suite) command-line tool.
Creating Resources¶
Service Resources¶
To define a service resource, use the pcs resource create command with the service name and the underlying systemd unit. For example, to create a resource for Apache:
This creates a resource named apache that starts the apache2 service. You can verify its existence with:
IP Address Resources¶
IP address resources ensure a consistent IP address is available across cluster nodes. Use the IPaddr2 resource agent:
This creates a resource named virtual_ip that manages the IP address 192.168.1.100 on the eth0 interface. Adjust the IP and interface as needed.
Filesystem Resources¶
Filesystems are managed using the Filesystem resource agent. Define a resource to mount a shared filesystem:
pcs resource create shared_fs ocf:heartbeat:Filesystem device=/dev/sdb1 directory=/mnt/shared options=rw
This mounts the /dev/sdb1 device to /mnt/shared with read-write permissions. Ensure the device and mount point match your storage configuration.
Managing Resources¶
Starting and Stopping Resources¶
Use pcs resource start and pcs resource stop to control individual resources:
To stop all resources on a node, use:
Migrating Resources¶
Move a resource to a specific node with:
This ensures the apache service runs on node2. To force a migration, add the --force flag:
Checking Resource Status¶
Use pcs status to view the current state of all resources and their locations:
This output shows which node hosts each resource and whether they are online or offline.
Key Takeaways¶
- Use
pcs resource createto define services, IP addresses, and filesystems with appropriate resource agents. - Manage resources with
pcs resource start,stop,move, anddisablecommands. - Always verify resource status with
pcs statusto ensure proper cluster behavior. - Test migrations and failover scenarios to validate resource resilience.