Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2809539
  • 博文数量: 587
  • 博客积分: 6356
  • 博客等级: 准将
  • 技术积分: 6410
  • 用 户 组: 普通用户
  • 注册时间: 2008-10-23 10:54
个人简介

器量大者,福泽必厚

文章分类

全部博文(587)

文章存档

2019年(3)

2018年(1)

2017年(29)

2016年(39)

2015年(66)

2014年(117)

2013年(136)

2012年(58)

2011年(34)

2010年(50)

2009年(38)

2008年(16)

分类: LINUX

2014-11-29 16:29:41

在配置keepalived+haproxy+xtradbcluster时遇到一个问题,9200端口已经启动了,通过lsof -i:9200 有输出,但curl -I  始终提示503 错误:我在percona论坛发帖提问,后来自己解决了!我的提问如下:

  1. Hi,
  2. I want to establish a cluster with 5 nodes (haproxy+keepalived and 3 nodes)
  3. I occured a problem in health check for the cluster
  4. I have configured as follows in three nodes:
  5. [root@localhost init.d]# cd /etc/xinetd.d/
  6. [root@localhost xinetd.d]# pwd
  7. /etc/xinetd.d
  8. [root@localhost xinetd.d]# ll mysqlchk
  9. -rw-r--r-- 1 root root 1090 Nov 14 17:49 mysqlchk
  10. [root@localhost xinetd.d]# ll /etc/xinetd.d/mysqlchk
  11. -rw-r--r-- 1 root root 1090 Nov 14 17:49 /etc/xinetd.d/mysqlchk
  12. [root@localhost xinetd.d]# cat mysqlchk
  13. # default: on
  14. # description: mysqlchk
  15. service mysqlchk
  16. {
  17. # this is a config for xinetd, place it in /etc/xinetd.d/
  18. disable = no
  19. flags = REUSE
  20. socket_type = stream
  21. port = 9200
  22. wait = no
  23. user = nobody
  24. server = /usr/bin/clustercheck
  25. server_args = sstuser s3cret 1 /var/log/clusterlog 1 /etc/my.cnf
  26. log_on_failure += USERID
  27. only_from = 0.0.0.0/0
  28. #
  29. # Passing arguments to clustercheck
  30. # <user> <pass> <available_when_donor=0|1> <log_file> <available_when_readonly=0|1> <defaults_extra_file>"
  31. # Recommended: server_args = user pass 1 /var/log/log-file 0 /etc/my.cnf.local"
  32. # Compatibility: server_args = user pass 1 /var/log/log-file 1 /etc/my.cnf.local"
  33. # 55-to-56 upgrade: server_args = user pass 1 /var/log/log-file 0 /etc/my.cnf.extra"
  34. #
  35. # recommended to put the IPs that need
  36. # to connect exclusively (security purposes)
  37. per_source = UNLIMITED
  38. }
  39. [root@localhost xinetd.d]# lsof -i:9200
  40. COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
  41. xinetd 2446 root 5u IPv4 7047 0t0 TCP *:mysqlchk (LISTEN)
  42. [root@localhost xinetd.d]# /usr/bin/clustercheck
  43. HTTP/1.1 200 OK
  44. Content-Type: text/plain
  45. Connection: close
  46. Content-Length: 42

  47. Percona XtraDB Cluster Node is synced.

  48. [root@localhost xinetd.d]# curl -I localhost:9200
  49. HTTP/1.1 503 Service Unavailable
  50. Content-Type: text/plain
  51. Connection: close
  52. Content-Length: 44

  53. [root@localhost xinetd.d]# curl localhost:9200 ##here It does not
  54. Percona XtraDB Cluster Node is not synced.


  55. [root@localhost xinetd.d]# iptables -L -n
  56. Chain INPUT (policy ACCEPT)
  57. target prot opt source destination

  58. Chain FORWARD (policy ACCEPT)
  59. target prot opt source destination

  60. Chain OUTPUT (policy ACCEPT)
  61. target prot opt source destination
  62. [root@localhost xinetd.d]# getenforce
  63. Disabled


  64. I get 200 response with /usr/bin/clustercheck
  65. But I get 503 response with curl localhost:9200

  66. Could you tell me why ?
  67. many

  1. I am sure ,the three nodes are synced as follows:
  2. node1:
  3. mysql> show status like 'wsrep%';
  4. .....
  5. | wsrep_local_state_comment | Synced
  6. ......
  7. node2:
  8. mysql> show status like 'wsrep%';
  9. .....
  10. | wsrep_local_state_comment | Synced
  11. ......

  12. node3:
  13. mysql> show status like 'wsrep%';
  14. .....
  15. | wsrep_local_state_comment | Synced
  16. ......

  1. I have fix the problem. I modified the script clustercheck.
  2. I replace mysql with /usr/local/mysql/bin/mysql in /usr/bin/clustercheck script.
  3. then It works

  4. as follows:
  5. if [[ -r $DEFAULTS_EXTRA_FILE ]];then
  6. MYSQL_CMDLINE="/usr/local/mysql/bin/mysql --defaults-extra-file=$DEFAULTS_EXTRA_FILE -nNE --connect-timeout=$TIMEOUT \
  7. ${EXTRA_ARGS}"
  8. else
  9. MYSQL_CMDLINE="/usr/local/mysql/bin/mysql -nNE --connect-timeout=$TIMEOUT ${EXTRA_ARGS}"
  10. fi
  11. although it I am confused about it .Because I have add mysql bin into the PATH
  12. as follows:
  13. [root@db132 bin]# echo $PATH
  14. /usr/local/xtrabackup/bin:/usr/local/mysql/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
  15. [root@db132 bin]#


  16. Could anyone tell me why? 
  17. many
问题虽然解决了,但还是有点不明白,但无论怎么说,问题总是解决了!
处理问题思路如下:
打开haproxy的web界面会发现,所有的机器都是down的状态,
这是因为percona xtradbcluster通过9200端口来检测集群的工作状态,还需要配置9200 端口,
配置过程如下:
yum -y install xinetd
cp /usr/local/mysql/bin/clustercheck    /usr/bin
cp  /usr/local/mysql/xinetd.d/mysqlchk  /etc/xinnetd.d
vi /etc/xinnetd.d/mysqlchk

 server          = /usr/bin/clustercheck
行下面添加如下:
server_args = sstuser s3cret 1 /var/log/clusterlog 1 /etc/my.cnf   ##sstuser我已经添加了
然后重启xinetd服务,查看9200端口是否已经启动
将mysqlchk        9200/tcp                # mysqlchk行,添加到/etc/services文件中


在这里遇到一个奇怪的问题,
我能将9200端口给启动起来,通过lsof -i:9200 输出是正常的 
但是curl -I 却提示503 , 在网上也没有找到解决方法,后来我仔细查看了clustercheck脚本,
发现curl -I 直接执行的是
else 
    # Percona XtraDB Cluster node local state is not 'Synced' => return HTTP 503
    # Shell return-code is 1
    echo -en "HTTP/1.1 503 Service Unavailable\r\n" 
    echo -en "Content-Type: text/plain\r\n" 
    echo -en "Connection: close\r\n" 
    echo -en "Content-Length: 44\r\n" 
    echo -en "\r\n" 
    echo -en "Percona XtraDB Cluster Node is not synced.\r\n" 
    sleep 0.1
    exit 1
fi 
根本没有执行clusterworker中的if上半部分,但是我用mysql 命令执行,在机器上执行的时候是执行的if上半部分
而且
[root@db131 ~]# /usr/bin/clustercheck
HTTP/1.1 200 OK
Content-Type: text/plain
Connection: close
Content-Length: 42


Percona XtraDB Cluster Node is synced.
 我怀疑是mysql的路径问题,mysql 有两个,一个是我安装的mysql,另外一个是系统自带的mysql,
其实我已经配置PATH了,而且将我配置的mysql放到PATH的前面了,理论上将应该没有问题,
[root@db143 tmp]# which -a mysql
/usr/local/mysql/bin/mysql
/usr/bin/mysql
[root@db143 tmp
这个问题困扰了我大概一上午的时间,我将mysql修改为/usr/local/mysql/bin/mysql 就正常了
然后下面就一切就顺水顺风了! 


阅读(1154) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~