From e300d6fd2ce960531e89585bba88e60d57d69391 Mon Sep 17 00:00:00 2001 From: "Corey.Wang" Date: Wed, 17 Jun 2020 16:35:49 +0800 Subject: [PATCH 1/5] Create health-check-cn.md add health-check-cn.md --- doc/health-check-cn.md | 100 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 doc/health-check-cn.md diff --git a/doc/health-check-cn.md b/doc/health-check-cn.md new file mode 100644 index 000000000000..d12888407952 --- /dev/null +++ b/doc/health-check-cn.md @@ -0,0 +1,100 @@ + +## Upstream的健康检查 + +APISIX的健康检查使用[lua-resty-healthcheck](https://github.com/Kong/lua-resty-healthcheck)实现,你可以在upstream中使用它。 + +下面是一个检查检查的例子: + +```shell +curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d ' +{ + "uri": "/index.html", + "plugins": { + "limit-count": { + "count": 2, + "time_window": 60, + "rejected_code": 503, + "key": "remote_addr" + } + }, + "upstream": { + "nodes": { + "127.0.0.1:1980": 1, + "127.0.0.1:1970": 1 + }, + "type": "roundrobin", + "retries": 2, + "checks": { + "active": { + "http_path": "/status", + "host": "foo.com", + "healthy": { + "interval": 2, + "successes": 1 + }, + "unhealthy": { + "interval": 1, + "http_failures": 2 + }, + "req_headers": ["User-Agent: curl/7.29.0"] + }, + "passive": { + "healthy": { + "http_statuses": [200, 201], + "successes": 3 + }, + "unhealthy": { + "http_statuses": [500], + "http_failures": 3, + "tcp_failures": 3 + } + } + } + } +}' +``` + +监控检查的配置内容在`checks`中,`checks`包含两个类型:`active` 和 `passive`。 + +* `active`: 要启动探活健康检查,需要在upstream配置中的 `checks.active` 添加如下配置项。 + + * `active.http_path`: 用于发现upstream节点健康可用的HTTP GET请求路径。 + * `active.host`: 用于发现upstream节点健康可用的HTTP请求主机名。 + + `healthy`的阀值字段: + * `active.healthy.interval`: 健康的目标节点的健康检查间隔时间(以秒为单位),最小值为1。 + * `active.healthy.successes`: 确定目标是否健康的成功次数,最小值为1。 + + `unhealthy`的阀值字段: + * `active.unhealthy.interval`: 针对不健康目标节点的健康检查之间的间隔(以秒为单位),最小值为1。 + * `active.unhealthy.http_failures`: 确定目标节点不健康的http请求失败次数,最小值为1。 + * `active.req_headers`: 其他请求标头。数组格式,可以填写多个标题。 + +* `passive`: 要启用被动健康检查,需要在upstream配置中的 `checks.passive` 添加如下配置项。 + + `healthy`的阀值字段: + * `passive.healthy.http_statuses`: 如果当前HTTP响应状态码是其中任何一个,则将upstream节点设置为 `healthy` 状态。否则,请忽略此请求。 + * `passive.healthy.successes`: 如果upstream节点被检测成功(由 `passive.healthy.http_statuses` 定义)的次数超过 `successes` 次,则将该节点设置为 `healthy` 状态。 + + `unhealthy`的阀值字段: + * `passive.unhealthy.http_statuses`: 如果当前HTTP响应状态码是其中任何一个,则将upstream节点设置为 `unhealthy` 状态。否则,请忽略此请求。 + * `passive.unhealthy.tcp_failures`: 如果TCP通讯失败次数超过 `tcp_failures` 次,则将upstream节点设置为 `unhealthy` 状态。 + * `passive.unhealthy.timeouts`: 如果被动健康检查超时次数超过 `timeouts` 次,则将upstream节点设置为 `unhealthy` 状态。 + * `passive.unhealthy.http_failures`: 如果被动健康检查的HTTP请求失败(由 `passive.unhealthy.http_statuses` 定义)的次数超过 `http_failures`次,则将upstream节点设置为 `unhealthy` 状态。 From 33d93a392f068272364b3c0d61e1d1b0bc3796f1 Mon Sep 17 00:00:00 2001 From: "Corey.Wang" Date: Wed, 17 Jun 2020 22:51:03 +0800 Subject: [PATCH 2/5] Update health-check-cn.md doc update --- doc/health-check-cn.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/health-check-cn.md b/doc/health-check-cn.md index d12888407952..06628ae8c262 100644 --- a/doc/health-check-cn.md +++ b/doc/health-check-cn.md @@ -71,7 +71,7 @@ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f13 }' ``` -监控检查的配置内容在`checks`中,`checks`包含两个类型:`active` 和 `passive`。 +监控检查的配置内容在`checks`中,`checks`包含两个类型:`active` 和 `passive`,详情如下 * `active`: 要启动探活健康检查,需要在upstream配置中的 `checks.active` 添加如下配置项。 From 3eebc6bf9dfd1e82d0edc369a23d248f2a492dc7 Mon Sep 17 00:00:00 2001 From: "Corey.Wang" Date: Thu, 18 Jun 2020 09:17:02 +0800 Subject: [PATCH 3/5] Update health-check-cn.md add empty line after License --- doc/health-check-cn.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/health-check-cn.md b/doc/health-check-cn.md index 06628ae8c262..e8e7d4187a10 100644 --- a/doc/health-check-cn.md +++ b/doc/health-check-cn.md @@ -16,6 +16,9 @@ # limitations under the License. # --> + +# [English](health-check.md) + ## Upstream的健康检查 APISIX的健康检查使用[lua-resty-healthcheck](https://github.com/Kong/lua-resty-healthcheck)实现,你可以在upstream中使用它。 From 838a57f8437f26edc9678605bcbaa974f42d6a2a Mon Sep 17 00:00:00 2001 From: "Corey.Wang" Date: Thu, 18 Jun 2020 09:34:24 +0800 Subject: [PATCH 4/5] Update health-check-cn.md remove trailing whitespace in 87 line --- doc/health-check-cn.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/health-check-cn.md b/doc/health-check-cn.md index e8e7d4187a10..266dae6fb53e 100644 --- a/doc/health-check-cn.md +++ b/doc/health-check-cn.md @@ -84,7 +84,7 @@ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f13 `healthy`的阀值字段: * `active.healthy.interval`: 健康的目标节点的健康检查间隔时间(以秒为单位),最小值为1。 * `active.healthy.successes`: 确定目标是否健康的成功次数,最小值为1。 - + `unhealthy`的阀值字段: * `active.unhealthy.interval`: 针对不健康目标节点的健康检查之间的间隔(以秒为单位),最小值为1。 * `active.unhealthy.http_failures`: 确定目标节点不健康的http请求失败次数,最小值为1。 From 987be65bd1a0ec73087d50f05748c7680996bc77 Mon Sep 17 00:00:00 2001 From: "Corey.Wang" Date: Thu, 18 Jun 2020 10:03:41 +0800 Subject: [PATCH 5/5] Update README_CN.md update health check href to health-check-cn.md --- doc/README_CN.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/README_CN.md b/doc/README_CN.md index 866e0725b788..5c61f1ce321c 100644 --- a/doc/README_CN.md +++ b/doc/README_CN.md @@ -25,7 +25,7 @@ Reference document * [架构设计](architecture-design-cn.md) * [压力测试](benchmark-cn.md) * [如何构建 Apache APISIX](how-to-build-cn.md) -* [健康检查](health-check.md): 支持对上游节点的主动和被动健康检查,在负载均衡时自动过滤掉不健康的节点。 +* [健康检查](health-check-cn.md): 支持对上游节点的主动和被动健康检查,在负载均衡时自动过滤掉不健康的节点。 * Router(路由) * [radixtree](router-radixtree.md) * [r3](router-r3.md)