yum update\r\nyum upgrade<\/pre>\nEdit \/etc\/hosts file on both server with any terminal text editor of your liking<\/p>\n
nano \/etc\/hosts<\/pre>\nAdd the following lines to \/etc\/hosts file<\/p>\n
192.168.0.22\u00a0 \u00a0 webserver-01\r\n192.168.0.23\u00a0 \u00a0 webserver-02<\/pre>\n<\/span>3. Install Epel Repository and Nginx<\/span><\/h2>\nExtra Packages for Enterprise Linux (EPEL) repository is needed in order to install Nginx. Run the following commands on both servers.<\/p>\n
yum install epel-release -y\r\n\r\nyum install nginx -y<\/pre>\nsystemctl enable nginx\r\nsystemctl start nginx<\/pre>\n<\/span>4. Change\u00a0default Nginx index page<\/span><\/h2>\nOnce finished, we need to make changes to the default Nginx index page on both server.<\/p>\n
Run the following command on server one<\/p>\n
echo \u2018<\/pre>\n<\/span>webserver-01<\/span><\/h2>\n\u2019 > \/usr\/share\/nginx\/html\/index.html<\/pre>\nRun the following command on server two<\/p>\n
echo \u2018<\/pre>\n<\/span>webserver-02<\/span><\/h2>\n\u2019 > \/usr\/share\/nginx\/html\/index.html<\/pre>\n<\/span>5. Install and configure Pacemaker<\/span><\/h2>\nIn this section, we will install the Pacemaker stack. You have to complete this step on both servers.<\/p>\n
yum install corosync pacemaker pcs -y<\/pre>\nAfter the installation has been completed, enable all services to launch automatically at system boot using the systemctl commands below.<\/p>\n
systemctl enable pacemaker\r\nsystemctl enable corosync\r\nsystemctl enable pcsd<\/pre>\n<\/span>6.\u00a0\u00a0Synchronize the configuration<\/span><\/h2>\nThe installation will create a \u2018hacluster\u2019 system user. We also need to run pcsd in order to synchronize the configuration<\/p>\n
systemctl start pcsd<\/pre>\n<\/span>7. Create a password<\/span><\/h2>\nNext, create a new password for \u2018hacluster\u2019 user that had been automatically created during the previous installation, we need to use the same password for all servers<\/p>\n
passwd hacluster<\/pre>\n<\/span>8. Create Clusters<\/span><\/h2>\nNext, run this command below<\/p>\n
pcs cluster auth webserver-01 webserver-02<\/pre>\n<\/p>\n
At this point, we are ready to set up the cluster.<\/p>\n
pcs cluster setup \u2013name rosecluster webserver-01 webserver-02<\/pre>\n<\/p>\n
rosecluster is the cluster name, while webserver-01 and webserver-02 are the servers that will be the parts of rosecluster.<\/p>\n
Enable it on boot and start it now.<\/p>\n
pcs cluster enable \u2013all\r\npcs cluster start \u2013all<\/pre>\n<\/p>\n
We can check the cluster status with this command:<\/p>\n
pcs status<\/pre>\n<\/p>\n
<\/span>9. Disable STONITH<\/span><\/h2>\nSTONITH or Shoot The Other Node In The Head is the fencing implementation on Pacemaker. If you\u2019re in production, it\u2019s better to enable STONITH. Since we\u2019re not using the fencing device, we will disable the STONITH.<\/p>\n
When running pcs status command, you will see a warning in the output saying that no STONITH devices are configured and STONITH is not disabled:
\nWARNING: no stonith devices and stonith-enabled is not false<\/p>\n
Disable STONITH with the following pcs command.<\/p>\n
pcs property set stonith-enabled=false<\/pre>\n