Chapter 12. High-Availability Deployment Modes
12.0 Introduction
Fault-tolerant architecture separates systems into identical, independent stacks. Load balancers like NGINX are employed to distribute load, ensuring that what’s provisioned is utilized. The core concepts of high availability are load balancing over multiple active nodes or an active-passive failover. Highly available applications have no single points of failure; every component must use one of these concepts, including the load balancers themselves. For us, that means NGINX. NGINX is designed to work in either configuration: multiple active or active-passive failover. This chapter details techniques on how to run multiple NGINX servers to ensure high availability in your load-balancing tier.
12.1 NGINX Plus HA Mode
Problem
You need a highly available (HA) load-balancing solution in an on-premises deployment.
Solution
Use NGINX Plus’s HA mode with keepalived by installing the nginx-ha-keepalived
package from the NGINX Plus repository on two or more systems:
$
sudo
apt
update
$
sudo
apt
install
-
y
nginx
-
ha
-
keepalived
Use the nginx-ha-setup
script to bootstrap a keepalived configuration file on each system, and follow through the prompts:
$
sudo
nginx
-
ha
-
setup
Review the configuration file generated by the nginx-ha-setup
command:
$
sudo
cat
/
etc
/
keepalived
/
keepalived
.
conf
global_defs
{
vrrp_version
3
}
vrrp_script
chk_manual_failover
{
script
"/usr/lib/keepalived/nginx-ha-manual-failover"
interval
Get NGINX Cookbook, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.