tengine健康检查节点自动删除并添加节点

来源:互联网 发布:图森未来 知乎 编辑:程序博客网 时间:2024/05/17 22:27
配置实例:
[root@jumpserver conf]# more nginx.conf
user www www;
worker_processes  2;
error_log logs/error.log error;
worker_rlimit_nofile 65535;
events {
    use epoll;
    worker_connections  4096;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    server_tokens   off;
    keepalive_timeout  65;
    access_log off;
    server_names_hash_bucket_size 128;
    client_header_buffer_size 32k;
    large_client_header_buffers 4 32k;
    client_max_body_size 300m;
    tcp_nopush     on;
    tcp_nodelay on;

    client_body_buffer_size  512k;
    proxy_connect_timeout    5;
    proxy_read_timeout       60;
    proxy_send_timeout       5;
    proxy_buffer_size        16k;
    proxy_buffers            4 64k;
    proxy_busy_buffers_size 128k;
    proxy_temp_file_write_size 128k;

    proxy_next_upstream error timeout http_503 http_502 http_504 invalid_header;
    gzip on;
    gzip_min_length  1k;
    gzip_buffers     4 16k;
    gzip_http_version 1.1;
    gzip_comp_level 2;
    gzip_types       text/plain application/x-javascript text/css application/xml;
    gzip_vary on;
    log_format main '$remote_addr - $remote_user [$time_local] '
                   '"$request" $status $body_bytes_sent '
                   '"$http_referer" "$http_user_agent"'
                  '"addr:$upstream_addr-status:$upstream_status -cachestatus:$upstream_cache_status"'
                   '"$host$uri" "$is_args" "$args"';

    upstream default_server_pools {
    server 127.0.0.1:8080;
    server 192.168.199.8:8080;
    check interval=2000 rise=3 fall=2 timeout=1000 type=http;       #连续失败2次就认为节点down,连续成功3次就认为节点up
    check_http_send "HEAD /tomcat.html HTTP/1.0\r\n\r\n";      #发送健康检查包,访问tomcat.html文件,如http状态码200为正常
    }
server {
        listen       80;
        server_name  www.test.org;
        location / {
            proxy_pass http://default_server_pools;
            proxy_set_header Host       $host;
            proxy_set_header X-Forwarded-For $remote_addr;
        }
        location /status {
             check_status;
             access_log off;
        }

        location /nginx_status {
             stub_status on;
             access_log off;
        }
    }
}


节点测试:
1、kill -9强制杀掉tomcat实例进程
2、stop停掉tomcat实例进程
3、删除tomcat实例进程站点下tomcat.html文件
4、重启tomcat节点系统

以上情况都会自动删除节点


0 0