xinetd 'connection reset by peer'

Posted by ceejayoz on Server Fault See other posts from Server Fault or by ceejayoz
Published on 2013-03-21T17:38:42Z Indexed on 2014/08/18 16:30 UTC
Read the original article Hit count: 1828

I'm using percona-clustercheck (which comes with Percona's XtraDB Cluster packages) with xinetd and I'm getting an error when trying to curl the clustercheck service.

/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
}

When attempting to curl the service, I get a valid response (HTTP 200, text) but a 'connection reset by peer' notice at the end:

HTTP/1.1 200 OK
Content-Type: text/plain

Percona XtraDB Cluster Node is synced.

curl: (56) Recv failure: Connection reset by peer

Unfortunately, Amazon ELB appears to see this as a failed check, not a succeeded one.

How can I get clustercheck to exit gracefully in a manner that curl doesn't see a connection failure?

© Server Fault or respective owner

Related posts about xinetd

Related posts about percona-xtradb-cluster

  • HAProxy + Percona XtraDB Cluster

    as seen on Server Fault - Search for 'Server Fault'
    I am attempting to setup HAproxy in conjunction with Percona XtraDB Cluster on a series of 3 EC2 instances. I have found a few tutorials online dealing with this specific issue, but I am a bit stuck. Both the Percona servers and the HAproxy servers are running ubuntu 12.04. The HAProxy version is… >>> More

  • xinetd 'connection reset by peer'

    as seen on Server Fault - Search for 'Server Fault'
    I'm using percona-clustercheck (which comes with Percona's XtraDB Cluster packages) with xinetd and I'm getting an error when trying to curl the clustercheck service. /usr/bin/clustercheck: #!/bin/bash # # Script to make a proxy (ie HAProxy) capable of monitoring Percona XtraDB Cluster nodes properly # #… >>> More

  • Ubuntu upgrade process failed

    as seen on Server Fault - Search for 'Server Fault'
    I tried to dist-upgrade my ubuntu server on my percona cluster but it failed with this message The following packages have unmet dependencies: libmysqlclient18 : Depends: libmariadbclient18 (= 5.5.33a+maria-1~precise) but it is not installable And here is the package listing # dpkg --list | grep… >>> More

  • MySQL HA and Magento DB

    as seen on Server Fault - Search for 'Server Fault'
    Is it possible to use MySQL cluster for Magento DB? I have Web app developed in Magento E-commerce platform and I want to make DB highly available using the MySQL cluster. Magento supports only InnoDB database engine and MySQL HA uses it's own engine NDB. The Percona XtraDB Cluster, Does it change… >>> More