keepalived配置服务高可用
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 } }
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 } }
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; } }
隧道访问VIP
vip上的nginx:80转发到后端服务
本文来自博客园,作者:不懂123,转载请注明原文链接:https://www.cnblogs.com/yxh168/p/17310495.html