-
Notifications
You must be signed in to change notification settings - Fork 2
集群容错(HA)
mangotomato edited this page Jan 15, 2019
·
1 revision
生产部署时,Guardian推荐为3~5台WEB容器部署,形成小集群。
公司内部为apache+tomcat,apache和tomcat通过ajp长连接通信,此时apache是可以感知tomcat状态的,如tomcat某个实例down机后,apache可以感知upstream状态变更,实现了容错。
这里,nginx集成了nginx_upstream_check模块,实现了upstream的健康检查。
Nginx
nginx 安装nginx_upstream_check模块指引
存量Nginx热升级,加入nginx_upstream_check模块
upstream guardian
{
server 127.0.0.1:9700;
server 127.0.0.1:9800;
server 127.0.0.1:9900;
check interval=2000 rise=2 fall=2 timeout=1000 type=http;
check_http_send "GET /healthcheck HTTP/1.0\r\n\r\n";
check_http_expect_alive http_2xx http_3xx http_4xx;
}
location / {
root html;
index index.html index.htm;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://guardian;
}
location /status {
check_status;
access_log off;
}
reload nginx, 重新载入配置。
如上图显示,我这里开启了一台Guardian, 尝试在Postman,尝试多次调用,都可以正常返回请求。
-
文档
-
User Guide(API调用)
-
User Guide(API开放)
-
Deploy (生产部署最佳实践)