The first thing to do after installation of cluster components such as
pcs is to create a cluster. This then enables us to create and assign resources such as shared IP address or server services such as
MySQL to our cluster.
A typical cluster consist of at least 3 nodes, though it is still possible to create a cluster from just 2 nodes. This is to avoid a condition called
split-brain where each node in a cluster thinks that it is the only active node and cause unexpected behaviour in a cluster system. The condition is a lot less likely the more nodes there are in a cluster.
Pacemaker cluster could be created from the terminal using the
pcs (Pacemaker/Corosync Configuration System) tool.
Steps to create a Pacemaker cluster using pcs:
pcson all of your cluster nodes.
DNSby adding node's
IPand host name information to
/etc/hostsfile on all cluster nodes using your preferred text editor.
$ sudo vi /etc/hosts 192.168.111.11 node-01 192.168.111.12 node-02
Cluster nodes are to communicate using assigned name, and it is crucial for each nodes to use static
IP address to prevent communication error between the nodes.
pinging each nodes from each other using the configured host name.
$ ping -c3 node-01 && ping -c3 node-01 PING node-01 (192.168.111.11) 56(84) bytes of data. 64 bytes from node-01 (192.168.111.11): icmp_seq=1 ttl=64 time=0.061 ms 64 bytes from node-01 (192.168.111.11): icmp_seq=2 ttl=64 time=0.062 ms 64 bytes from node-01 (192.168.111.11): icmp_seq=3 ttl=64 time=0.133 ms --- node-01 ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2001ms rtt min/avg/max/mdev = 0.061/0.085/0.133/0.034 ms PING node-01 (192.168.111.11) 56(84) bytes of data. 64 bytes from node-01 (192.168.111.11): icmp_seq=1 ttl=64 time=0.050 ms 64 bytes from node-01 (192.168.111.11): icmp_seq=2 ttl=64 time=0.073 ms 64 bytes from node-01 (192.168.111.11): icmp_seq=3 ttl=64 time=0.070 ms --- node-01 ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2002ms rtt min/avg/max/mdev = 0.050/0.064/0.073/0.012 ms
$ sudo pcs cluster auth node-01 node-02 Username: hacluster Password: node-02: Authorized node-01: Authorized
$ sudo pcs cluster setup --name clustername node-01 node-02 Destroying cluster on nodes: node-01, node-02... node-02: Stopping Cluster (pacemaker)... node-01: Stopping Cluster (pacemaker)... node-01: Successfully destroyed cluster node-02: Successfully destroyed cluster Sending 'pacemaker_remote authkey' to 'node-01', 'node-02' node-01: successful distribution of the file 'pacemaker_remote authkey' node-02: successful distribution of the file 'pacemaker_remote authkey' Sending cluster config files to the nodes... node-01: Succeeded node-02: Succeeded Synchronizing pcsd certificates on nodes node-01, node-02... node-02: Success node-01: Success Restarting pcsd on the nodes in order to reload the certificates... node-02: Success node-01: Success
$ sudo pcs cluster start --name clustername --all node-01: Starting Cluster (corosync)... node-02: Starting Cluster (corosync)... node-01: Starting Cluster (pacemaker)... node-02: Starting Cluster (pacemaker)...
$ sudo pcs property set stonith-enabled=false $ sudo pcs property set no-quorum-policy=ignore
$ sudo pcs cluster status Cluster Status: Stack: corosync Current DC: node-02 (version 1.1.20-5.el7_7.1-3c4c782f70) - partition with quorum Last updated: Mon Sep 30 04:40:20 2019 Last change: Mon Sep 30 04:39:46 2019 by root via cibadmin on node-01 2 nodes configured 0 resources configured PCSD Status: node-02: Online node-01: Online
Comment anonymously. Login not required.