![Nginx在UDP负载均衡中持续发送到不可达的上游服务器](https://linux22.com/image/196405/Nginx%E5%9C%A8UDP%E8%B4%9F%E8%BD%BD%E5%9D%87%E8%A1%A1%E4%B8%AD%E6%8C%81%E7%BB%AD%E5%8F%91%E9%80%81%E5%88%B0%E4%B8%8D%E5%8F%AF%E8%BE%BE%E7%9A%84%E4%B8%8A%E6%B8%B8%E6%9C%8D%E5%8A%A1%E5%99%A8.png)
我使用 Nginx 来负载平衡来自 udp syslog 源到logstash 的流量
配置 :
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
worker_rlimit_nofile 1000000;
# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
include /etc/nginx/conf.d/*.conf;
#UDP syslog load balancing
stream {
server {
listen 514 udp;
proxy_pass logstash_servers;
proxy_timeout 1s;
proxy_responses 0;
proxy_bind $remote_addr transparent;
}
upstream logstash_servers {
server 192.168.2.90:514 fail_timeout=10s;
server 192.168.2.95:514 fail_timeout=10s;
}
}
它工作正常,但如果我的上游 Logstash 服务器之一关闭,Nginx 不会考虑它,我会在剩余的上游 Logstash 服务器上收到一半的消息。
如果一台 Logstash 服务器出现故障,我如何告诉 Nginx 仅使用剩余的 Logstash 服务器?