让 collector 高可用

agent
ai
java

#1

让 collector 高可用

问题场景

某运营商现场部署了多个探针,采用分布式部署 collector 的方案,但网络部门不能完全接受打开 agent 到 collector 直接所需的多个端口,因这样面对大量探针时,后期的维护工作量要大一些。

采用方案

一个 collector 理论上(与服务器配置有关)可支撑 20 左右探针,因现场部署探针数量较大,使用多个 collector 来接收处理 agent 的数据,同时考虑尽量减少对网络运维的影响,采用在 agent 与 collector 之间部署 nginx 的方式进行均衡负载。

nginx 配置举例

worker_processes  1;

events {
  worker_connections  1024;
}

http {
  include       mime.types;
  default_type  application/octet-stream;

  sendfile        on;

  keepalive_timeout  65;

  upstream agent_collector {
    server 192.168.0.1:19876;
    server 192.168.0.2:19876;
    server 192.168.0.3:19876;
    ip_hash;
  }

  server {
    listen 19876;
    charset utf-8;

    location / {
      proxy_pass http://agent_collector;
      proxy_set_header Host $host;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
      root   html;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    #location ~ \.php$ {
    #    root           html;
    #    fastcgi_pass   127.0.0.1:9000;
    #    fastcgi_index  index.php;
    #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
    #    include        fastcgi_params;
    #}

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny  all;
    #}
  }

}