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
In the preceding example:
-
MyVirtualIP is the id, or name of the resource.
-
ocf
is the class, or the standard, the resource agent conforms to. -
heartbeat
is the provider of the resource. -
IPaddr2
is the type of resource that is to be created.The following options are specified for the
IPaddr2
resource:-
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
IPaddr2
resource:-
op monitor interval=1s
specifies that the system checks every second whether the resource is running.
-
-
--group
myapachegroup specifies the resource group to which the resource is to be added. If the group does not exist, it is created.
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
You can confirm the status of your resources by running the pcs status
command. Depending upon your configuration, you r 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