nginx高可用配置

参考:

https://www.cnblogs.com/yaboya/p/9107442.html

1. 准备工作

(1)两台服务器

(2)都安装nginx

(3)都安装keepalived

yum install keepalived -y

2.配置keepalived配置文件

修改/etc/keepalived/keepalived.conf

! Configuration File for keepalived

global_defs {
   notification_email {
     [email protected]
     [email protected]
     [email protected]
   }
   notification_email_from [email protected]
   smtp_server 192.168.200.1
   smtp_connect_timeout 30
   router_id LVS_DEVEL
   vrrp_skip_check_adv_addr
   vrrp_strict
   vrrp_garp_interval 0
   vrrp_gna_interval 0
}

vrrp_instance VI_1 {
    state MASTER        #主服务其为MASTER,备用服务器为BACKUP
    interface enp0s8
    virtual_router_id 51
    priority 100        #主服务优先级必须大于备用服务器
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        192.168.56.16
        192.168.56.17
        192.168.56.18
    }
}

 3. 启动

(1)启动ngnix

(2)启动keepalived

systemctl start keepalived

4. 访问虚拟IP地址

        192.168.56.16
        192.168.56.17
        192.168.56.18

5. 关闭主服务器(直接关机)

访问虚拟IP地址,仍然可以访问到nginx

发布了21 篇原创文章 · 获赞 6 · 访问量 813

猜你喜欢

转载自blog.csdn.net/BOOM_haha/article/details/103815466