xinetd'连接重置对等'

我正在用xinetd使用percona-clustercheck (随Percona的XtraDB集群软件包一起提供),并且在尝试使用clustercheck服务时遇到错误。

/usr/bin/clustercheck

 #!/bin/bash # # Script to make a proxy (ie HAProxy) capable of monitoring Percona XtraDB Cluster nodes properly # # Author: Olaf van Zandwijk <[email protected]> # Documentation and download: https://github.com/olafz/percona-clustercheck # # Based on the original script from Unai Rodriguez # MYSQL_USERNAME="clustercheckuser" MYSQL_PASSWORD="clustercheckpassword!" ERR_FILE="/dev/null" AVAILABLE_WHEN_DONOR=0 # # Perform the query to check the wsrep_local_state # WSREP_STATUS=`mysql --user=${MYSQL_USERNAME} --password=${MYSQL_PASSWORD} -e "SHOW STATUS LIKE 'wsrep_local_state';" 2>${ERR_FILE} | awk '{if (NR!=1){print $2}}' 2>${ERR_FILE}` if [[ "${WSREP_STATUS}" == "4" ]] || [[ "${WSREP_STATUS}" == "2" && ${AVAILABLE_WHEN_DONOR} == 1 ]] then # Percona XtraDB Cluster node local state is 'Synced' => return HTTP 200 /bin/echo -en "HTTP/1.1 200 OK\r\n" /bin/echo -en "Content-Type: text/plain\r\n" /bin/echo -en "\r\n" /bin/echo -en "Percona XtraDB Cluster Node is synced.\r\n" /bin/echo -en "\r\n" exit 0 else # Percona XtraDB Cluster node local state is not 'Synced' => return HTTP 503 /bin/echo -en "HTTP/1.1 503 Service Unavailable\r\n" /bin/echo -en "Content-Type: text/plain\r\n" /bin/echo -en "\r\n" /bin/echo -en "Percona XtraDB Cluster Node is not synced.\r\n" /bin/echo -en "\r\n" exit 1 fi 

/etc/xinetd.mysqlchk

 # default: on # description: mysqlchk service mysqlchk { # this is a config for xinetd, place it in /etc/xinetd.d/ disable = no flags = REUSE socket_type = stream port = 9200 wait = no user = nobody server = /usr/bin/clustercheck log_on_failure += USERID only_from = 10.0.0.0/8 127.0.0.1 # recommended to put the IPs that need # to connect exclusively (security purposes) per_source = UNLIMITED } 

当试图蜷缩服务时,我得到一个有效的响应(HTTP 200,文本)

 HTTP/1.1 200 OK Content-Type: text/plain Percona XtraDB Cluster Node is synced. curl: (56) Recv failure: Connection reset by peer 

不幸的是,Amazon ELB似乎认为这是一个失败的检查,而不是一个成功的检查。

如何让clustercheck以一种curl没有看到连接失败的方式正常退出?

添加Content-Length: 0使得客户端忽略内容,即使有这样的内容。 所以这可能会打破其他检查软件。 在你的情况下,内容的长度是42个字节(所以添加Content-Length: 42 ),同步节点的情况下,46个字节的情况下,一个未同步的节点。

 # curl localhost:9200 Percona XtraDB Cluster Node is synced. 

我将推送更新后的脚本,以便在新版本的Percona XtraDB集群软件包中修复。

我向clustercheck响应中添加了一个Content-Length: 0头,这似乎是为了进行亚马逊的健康检查。 如果有人有更好的做法,请让我知道

我解决了类似的问题使用

 echo -en "HTTP/1.1 200 OK\r\n" | cat 

代替

 echo -en "HTTP/1.1 200 OK\r\n" 

我也注意到你在本地使用脚本。 您也可以在命令行上执行clustercheck并检查返回值。

在同步节点的情况下:

 # /usr/bin/clustercheck > /dev/null # echo $? 0 

在未同步节点的情况下:

 # /usr/bin/clustercheck > /dev/null # echo $? 1