成人国产在线小视频_日韩寡妇人妻调教在线播放_色成人www永久在线观看_2018国产精品久久_亚洲欧美高清在线30p_亚洲少妇综合一区_黄色在线播放国产_亚洲另类技巧小说校园_国产主播xx日韩_a级毛片在线免费

資訊專欄INFORMATION COLUMN

ngx_healthcheck_module intro

wenshi11019 / 594人閱讀

摘要:相比之下,這個(gè)第三方模塊可以對(duì)后端服務(wù)器提供主動(dòng)式的健康狀態(tài)檢測(cè)。向后端發(fā)送的健康檢查包的間隔。如果連續(xù)成功次數(shù)達(dá)到,服務(wù)器就被認(rèn)為是。只有配置塊中支持類型檢查發(fā)送請(qǐng)求,通過(guò)后端的回復(fù)包的狀態(tài)來(lái)判斷后端是否存活。指定后端服務(wù)器的檢查端口。

ngx-healthcheck-module

Health-checker for Nginx upstream servers (support http upstream && stream upstream)

該模塊可以為Nginx提供主動(dòng)式后端服務(wù)器健康檢查的功能(同時(shí)支持四層和七層后端服務(wù)器的健康檢測(cè))。

Table of Contents

Status

Description

Installation

Usage

Synopsis && Directive

healthcheck

check

Bugs and Patches

Author

Copyright and License

See Also

Status

This nginx module is still under development, you can help improve and it.

這個(gè)項(xiàng)目還在開(kāi)發(fā)中完善中,歡迎貢獻(xiàn)代碼,或報(bào)告bug。一起使它變得更好。

Description

當(dāng)你使用nginx作為負(fù)載均衡器時(shí),nginx原生只提供了基本的重試方式來(lái)保證訪問(wèn)到正常的后端服務(wù)器。

相比之下,這個(gè)nginx第三方模塊可以對(duì)后端服務(wù)器提供主動(dòng)式的健康狀態(tài)檢測(cè)。
它維護(hù)了一個(gè)后端服務(wù)器列表,保證新的請(qǐng)求直接發(fā)送到一個(gè)健康的后端服務(wù)器。

主要特性:

同時(shí)支持四層和七層后端服務(wù)器的健康檢測(cè)

四層支持的檢測(cè)類型:tcp / udp / http

七層支持的檢測(cè)類型:http / fastcgi

提供一個(gè)統(tǒng)一的http狀態(tài)查詢接口,輸出格式:html / json / csv

Installation
git clone https://github.com/nginx/nginx/nginx.git
git clone https://github.com/zhouchangxun/ngx_healthcheck_module.git

cd nginx/; 
git apply ../ngx_healthcheck_module/nginx-stable-1.12+.patch

./auto/configure --with-stream --add-module=../ngx_healthcheck_module/
make && make install

Back to TOC

Usage nginx.conf example
user  root;
worker_processes  1;
error_log  logs/error.log  info;
#pid        logs/nginx.pid;

events {
    worker_connections  1024;
}

http {
    server {
        listen 80;
        # status interface
        location /status {
            healthcheck_status;
        }
        # http front
        location / { 
          proxy_pass http://http-cluster;
        }   
    }
    # as a backend server.
    server {
        listen 8080;
        location / {
          root html;
        }
    }
    
    upstream http-cluster {
        # simple round-robin
        server 127.0.0.1:8080;
        server 127.0.0.2:81;

        check interval=3000 rise=2 fall=5 timeout=5000 type=http;
        check_http_send "GET / HTTP/1.0

";
        check_http_expect_alive http_2xx http_3xx;
    }
}

stream {
    upstream tcp-cluster {
        # simple round-robin
        server 127.0.0.1:22;
        server 192.168.0.2:22;
        check interval=3000 rise=2 fall=5 timeout=5000 default_down=true type=tcp;
    }
    server {
        listen 522;
        proxy_pass tcp-cluster;
    }
    
    upstream udp-cluster {
        # simple round-robin
        server 127.0.0.1:53;
        server 8.8.8.8:53;
        check interval=3000 rise=2 fall=5 timeout=5000 default_down=true type=udp;
    }
    server {
        listen 53;
        proxy_pass udp-cluster;
    }
    
}
status interface

One typical output is

root@changxun-PC:~/nginx-dev/ngx_healthcheck_module# curl localhost/status
{"servers": {
  "total": 6,
  "generation": 3,
  "http": [
    {"index": 0, "upstream": "http-cluster", "name": "127.0.0.1:8080", "status": "up", "rise": 119, "fall": 0, "type": "http", "port": 0},
    {"index": 1, "upstream": "http-cluster", "name": "127.0.0.2:81", "status": "down", "rise": 0, "fall": 120, "type": "http", "port": 0}
  ],
  "stream": [
    {"index": 0, "upstream": "tcp-cluster", "name": "127.0.0.1:22", "status": "up", "rise": 22, "fall": 0, "type": "tcp", "port": 0},
    {"index": 1, "upstream": "tcp-cluster", "name": "192.168.0.2:22", "status": "down", "rise": 0, "fall": 7, "type": "tcp", "port": 0},
    {"index": 2, "upstream": "udp-cluster", "name": "127.0.0.1:53", "status": "down", "rise": 0, "fall": 120, "type": "udp", "port": 0},
    {"index": 3, "upstream": "udp-cluster", "name": "8.8.8.8:53", "status": "up", "rise": 3, "fall": 0, "type": "udp", "port": 0}
  ]
}}
root@changxun-PC:~/nginx-dev/ngx_healthcheck_module# 

Back to TOC

Synopsis check

Syntax:

check interval=milliseconds  
[fall=count] [rise=count] [timeout=milliseconds]
[default_down=true|false] [type=tcp|udp|http] [port=check_port]

Default: interval=30000 fall=5 rise=2 timeout=1000 default_down=true type=tcp

Context: http/upstream || stream/upstream

該指令可以打開(kāi)后端服務(wù)器的健康檢查功能。

Detail:

interval:向后端發(fā)送的健康檢查包的間隔。

fall(fall_count): 如果連續(xù)失敗次數(shù)達(dá)到fall_count,服務(wù)器就被認(rèn)為是down。

rise(rise_count): 如果連續(xù)成功次數(shù)達(dá)到rise_count,服務(wù)器就被認(rèn)為是up。

timeout: 后端健康請(qǐng)求的超時(shí)時(shí)間。

default_down: 設(shè)定初始時(shí)服務(wù)器的狀態(tài),如果是true,就說(shuō)明默認(rèn)是down的,如果是false,就是up的。
默認(rèn)值是true,也就是一開(kāi)始服務(wù)器認(rèn)為是不可用,要等健康檢查包達(dá)到一定成功次數(shù)以后才會(huì)被認(rèn)為是健康的。

type:健康檢查包的類型,現(xiàn)在支持以下多種類型

tcp:簡(jiǎn)單的tcp連接,如果連接成功,就說(shuō)明后端正常。

udp:簡(jiǎn)單的發(fā)送udp報(bào)文,如果收到icmp error(主機(jī)或端口不可達(dá)),就說(shuō)明后端異常。(只有stream配置塊中支持udp類型檢查)

http:發(fā)送HTTP請(qǐng)求,通過(guò)后端的回復(fù)包的狀態(tài)來(lái)判斷后端是否存活。

port: 指定后端服務(wù)器的檢查端口。你可以指定不同于真實(shí)服務(wù)的后端服務(wù)器的端口,

比如后端提供的是443端口的應(yīng)用,你可以去檢查80端口的狀態(tài)來(lái)判斷后端健康狀況。默認(rèn)是0,表示跟后端server提供真實(shí)服務(wù)的端口一樣。

A example as followed:

stream {
    upstream tcp-cluster {
        # simple round-robin
        server 127.0.0.1:22;
        server 192.168.0.2:22;
        check interval=3000 rise=2 fall=5 timeout=5000 default_down=true type=tcp;
    }
    server {
        listen 522;
        proxy_pass tcp-cluster;
    }
    ...
}
healthcheck

Syntax: healthcheck_status [html|csv|json]

Default: healthcheck_status html

Context: http/server/location

A example as followed:

http {
    server {
        listen 80;
        
        # status interface
        location /status {
            healthcheck_status;
        }
     ...
}

Back to TOC

Todo List

增加測(cè)試用例

整理、優(yōu)化代碼

規(guī)范代碼中的log輸出

Back to TOC

Bugs and Patches

Please report bugs

create GitHub Issue,

or submit patches by

new Pull request

Back to TOC

Author

Chance Chou (周長(zhǎng)勛) .

Back to TOC

Copyright and License

The health check part is based on Yaoweibin"s

healthcheck module nginx_upstream_check_module
();

This module is licensed under the BSD license.

Copyright (C) 2017-, by Changxun Zhou

Copyright (C) 2014 by Weibin Yao

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Back to TOC

See Also

nginx: http://nginx.org

Back to TOC

文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。

轉(zhuǎn)載請(qǐng)注明本文地址:http://systransis.cn/yun/39889.html

相關(guān)文章

  • Linkedin Intro的釣魚(yú)研究

    摘要:年月日,我聯(lián)系了的安全團(tuán)隊(duì),并會(huì)在近期發(fā)布修復(fù)補(bǔ)丁來(lái)解決下面的問(wèn)題。有關(guān)月日,推出一個(gè)名為的應(yīng)用程序。會(huì)對(duì)你的做些什么為了更好地觀察的行為,目前我正對(duì)其進(jìn)行更深入的分析研究,并很快就會(huì)發(fā)布。釣魚(yú)去啦為達(dá)教學(xué)目的,我已經(jīng)建立了一個(gè)基本的模板。 2013年10月28日,我聯(lián)系了Linkedin的安全團(tuán)隊(duì),并會(huì)在近期發(fā)布修復(fù)補(bǔ)丁來(lái)解決下面的問(wèn)題。這個(gè)修復(fù)程序適用于隨機(jī)生成ID的styling...

    lykops 評(píng)論0 收藏0
  • Linkedin Intro的釣魚(yú)研究

    摘要:年月日,我聯(lián)系了的安全團(tuán)隊(duì),并會(huì)在近期發(fā)布修復(fù)補(bǔ)丁來(lái)解決下面的問(wèn)題。有關(guān)月日,推出一個(gè)名為的應(yīng)用程序。會(huì)對(duì)你的做些什么為了更好地觀察的行為,目前我正對(duì)其進(jìn)行更深入的分析研究,并很快就會(huì)發(fā)布。釣魚(yú)去啦為達(dá)教學(xué)目的,我已經(jīng)建立了一個(gè)基本的模板。 2013年10月28日,我聯(lián)系了Linkedin的安全團(tuán)隊(duì),并會(huì)在近期發(fā)布修復(fù)補(bǔ)丁來(lái)解決下面的問(wèn)題。這個(gè)修復(fù)程序適用于隨機(jī)生成ID的styling...

    wenshi11019 評(píng)論0 收藏0
  • 由一道題圖解JavaScript的作用域

    摘要:當(dāng)我將此題的作用域鏈畫(huà)出來(lái)之后,終于感覺(jué)作用域入門(mén)了。創(chuàng)建函數(shù)的作用域鏈,并初始化為函數(shù)的所包含的對(duì)象,即包含了的作用域鏈。 作用域 為了理解作用域,跪看了好幾篇大神的博文,終于略知一二。 1.題目 其中,看到這樣一道題(稍作修改): function factory() { var name = laruence; var intro = function(){...

    nevermind 評(píng)論0 收藏0
  • JQuery基礎(chǔ)——選擇器

    摘要:通過(guò),可以選取查詢,元素,并對(duì)它們執(zhí)行操作可以簡(jiǎn)寫(xiě)成元素選擇器使用選擇器來(lái)選取元素。屬性選擇器使用表達(dá)式來(lái)選擇帶有給定屬性的元素。選擇器選擇器可用于改變?cè)氐膶傩浴? 通過(guò) jQuery,可以選取(查詢,query) HTML 元素,并對(duì)它們執(zhí)行操作(actions) $(document).ready(function(){})可以簡(jiǎn)寫(xiě)成$(funtion(){}) jQuery 元...

    taowen 評(píng)論0 收藏0
  • JQuery基礎(chǔ)——選擇器

    摘要:通過(guò),可以選取查詢,元素,并對(duì)它們執(zhí)行操作可以簡(jiǎn)寫(xiě)成元素選擇器使用選擇器來(lái)選取元素。屬性選擇器使用表達(dá)式來(lái)選擇帶有給定屬性的元素。選擇器選擇器可用于改變?cè)氐膶傩浴? 通過(guò) jQuery,可以選取(查詢,query) HTML 元素,并對(duì)它們執(zhí)行操作(actions) $(document).ready(function(){})可以簡(jiǎn)寫(xiě)成$(funtion(){}) jQuery 元...

    GraphQuery 評(píng)論0 收藏0

發(fā)表評(píng)論

0條評(píng)論

最新活動(dòng)
閱讀需要支付1元查看
<