我使用 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 服务器?