Creating Resources
You can create a resource by using the pcs resource create command as
shown in the following example that creates a resource for a virtual IP address:
sudo pcs resource create MyVirtualIP ocf:heartbeat:IPaddr2 ip=192.0.2.3 \
cidr_netmask=24 nic=eth1 \
op monitor interval=1s group myapachegroup --futureIn the preceding example:
-
MyVirtualIP is the id, or name of the resource.
-
ocfis the class, or the standard, the resource agent conforms to. -
heartbeatis the provider of the resource. -
IPaddr2is the type of resource that is to be created.The following options are specified for the
IPaddr2resource:-
ip=192.0.2.3 specifies IP address to use for the Virtual IP Address. -
cidr_netmask=24 specifies the netmask for the interface in CIDR format. -
nic=eth1 The base network interface on which the IP address will be brought online.
The following operation is specified for the
IPaddr2resource:-
op monitor interval=1sspecifies that the system checks every second whether the resource is running.
-
-
groupmyapachegroup specifies the resource group to which the resource is to be added. If the group does not exist, it is created. -
--futureis specified to use the command's latest syntax and options.
Note:
The preceding example includes the --future flag in its parameter list and
therefore uses the newer group option (in place of the deprecated
--group). See Oracle Linux 10: Release Notes for Oracle Linux
10 and the
pcs(8) manual page for more information.
Following on from the preceding example, you can create and add a second resource, this
time of type apache, as shown in the following example:
sudo pcs resource create MyApacheWebsite ocf:heartbeat:apache \
configfile="/etc/httpd/conf/httpd.conf" \
statusurl="http://192.0.2.3/server-status" group myapachegroup --futureYou can confirm the status of your resources by running the pcs status
command. Depending upon your configuration, your command output will be similar to the
following sample code block:
sudo pcs status
Cluster name: my_cluster
Cluster Summary:
* Stack: corosync (Pacemaker is running)
* Current DC: node1 (version 2.1.6-9.1.0.1.el8_9-
6fdc9deea29) - partition with quorum
* Last updated: Sat Feb 3 22:35:58 2024 on node1
* Last change: Sat Feb 3 22:33:37 2024 by root via
cibadmin on node1
* 2 nodes configured
* 4 resource instances configured
Node List:
* Online: [ node1 ]
* OFFLINE: [ node2 ]
Full List of Resources:
* Resource Group: myapachegroup:
* MyVirtualIP (ocf::heartbeat:IPaddr2): Started node1
* MyApacheWebsite (ocf::heartbeat:apache): Started node1
...
...
Daemon Status:
corosync: active/disabled
pacemaker: active/enabled
pcsd: active/enabled