![](https://csdnimg.cn/release/download_crawler_static/87295187/bg1.jpg)
Nginx+Keepalived实现nginx高可用详细步骤
一.方案规划
二 .操作系统与安装软件如下:
Redhat Linux 7.9 x64
.安装Nginx(两个节点都是同样操作)
1 .安装依赖环境[root@ZZZZ-EBS-SLB02 yum -y install wget gcc-c++ ncurses ncurses-devel
cmake make perl bison openssl openssl-devel gcc* Iibxml2 Iibxml2-devel curl-devel
libjpeg* libpng* freetype* autoconf automake zlib* fiex* libxml* libmcrypt* libtool-
ltdl-devel* libaio libaio-devel bzr libtool
2 .安装 openssl[root@ZZZZ-EBS-SLB02 local)# cd /usr/local/src
[root@ZZZZ-EBS-SLB02 src]# wget
[root@ZZZZ-EBS-SLB02 src]# Is
[root@ZZZZ-EBS-SLB02 openssl-1.0.2s]# make[root@ZZZZ-EBS-SLB02 openssl-1.0.2s]# make install
3 .安装pcre[root@ZZZZ-EBS-SLB02 local]# cd /usr/local/src
[root@ZZZZ-EBS-SLB02 src]# wget s:〃
[root@ZZZZ-EBS-SLB02 src]# Is
[root@ZZZZ-EBS-SLB02 src]# cd pcre-8.43[root@ZZZZ-EBS-SLB02 pcre-8.43]# ./configure -
prefix=/usr/local/pcre-8.43
[root@ZZZZ-EBS-SLB02 pcre-8.43]# make[root@ZZZZ-EBS-SLB02 pcre-8.43]# make install
4 .安装zlibglobal_defs {
router_id zzzz-nginx-slb02
vrrp_version 3)
vrrp_script chk_nginx {
script "/etc/keepalived/nginx_check.sh"
interval 2
weight -20)
vrrpjnstance Vl_l {
state BACKUP
interface ensl92
virtual_router_id 51
priority 90
nopreempt
advertjnt 0.5
authentication {auth_type PASS