当前位置 : 主页 > 手机开发 > harmonyos >

keepalived配置服务高可用

来源:互联网 收集:自由互联 发布时间:2023-08-26
keepalived配置 global_defs { router_id master-1}vrrp_instance VI_1 { state MASTER interface bond0 virtual_router_id 50 priority 100 advert_int 1 authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 10.30.92.243 }} 主vip节点

keepalived配置

global_defs {
   router_id master-1
}
vrrp_instance VI_1 {
    state MASTER
    interface bond0
    virtual_router_id 50
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        10.30.92.243
    }
}

主vip节点配置

global_defs {
   router_id master-2
}
vrrp_instance VI_1 {
    state BACKUP
    interface bond0
    virtual_router_id 50
    priority 90
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
      10.30.92.243
    }
}

备vip节点配置      

keepalived配置服务高可用_服务器

      

keepalived配置服务高可用_html_02

 Nginx配置

      两台服务器上都安装nginx服务,并且两台服务器上的nginx配置都保持一致。这样即使有一台nginx主机挂掉,我们依然可以通过备vip主机访问服务

server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        #location / {
          #  root   html;
           # index  index.html index.htm;
        #}


          location / {
             proxy_pass http://10.30.92.72:38100;
             proxy_set_header X-Real-IP $remote_addr;
             proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
        }
}

nginx.conf

 

 隧道访问VIP

          vip上的nginx:80转发到后端服务

          

keepalived配置服务高可用_html_03

         

keepalived配置服务高可用_服务器_04

 

上一篇:k8s服务调用和卷挂载
下一篇:没有了
网友评论