我有一个主系统日志服务器,它从多个来源接收系统日志,我想将这些日志发送到 Graylog 集群。为了帮助集群跟上(在一些慢速 VM 上),我需要能够将消息负载平衡到 Graylog,因为有时它们来自端点的大量 block (有些每 10 秒突发发送 5k 日志)。
我正在尝试使用 nginx 作为 syslog 消息的负载平衡器,但我似乎无法让它工作,这似乎是因为 nginx 正在寻找来自 Graylog 服务器的响应。使用 UDP,它不会得到响应。至少这是我认为正在发生的事情。
我得到的错误是这样的:
2016/12/01 11:27:59 [error] 2816#2816: *210325 no live upstreams while connecting
to upstream, udp client: 10.0.1.1, server: 0.0.0.0:11016,
upstream: "juniper_close_stream_backend", bytes from/to client:932/0,
bytes from/to upstream:0/0
作为我的 nginx.conf 中此规则的示例,它看起来像:
stream {
server {
listen 11016 udp;
proxy_pass juniper_close_stream_backend;
}
upstream juniper_close_stream_backend {
server 10.0.1.2:11016;
server 10.0.1.3:11016;
server 10.0.1.4:11016;
}
}
在这种情况下,我的系统日志框是 10.0.1.1,我的下游 Graylog 框是 10.0.1.[2-4]。我看到了所有这些错误消息。
关于正在发生的事情有什么线索吗?当我在 Graylog 框上运行 tcpdump 时,我看到来自负载均衡器的流量,这意味着它正在工作。但我认为 nginx 正在等待响应并给我一个错误。
最佳答案
所以这似乎确实是解决方案(在我上面的注释中)。
如果使用上面的示例,您希望它看起来像:
stream {
server {
listen 11016 udp;
proxy_pass juniper_close_stream_backend;
proxy_responses 0;
}
}
这告诉 nginx 不要期望响应,它不需要来自 UDP 的响应。我不知道为什么他们的 examples在讨论 DNS 时不要显示这一点,它可以完全由 UDP 驱动。
关于linux - 使用 nginx 进行 UDP 转发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40917372/