【发布时间】:2018-11-13 00:13:35
【问题描述】:
我在连接运行 haproxy 的虚拟机和集群时遇到问题。让我解释一下这个问题。 我用 MariaDB(IP 192.168.0.1 和 192.168.0.2)和 haproxy 主机(IP 192.168.0.3)设置了 2 台 galera 集群机器。我几乎遵循了我在互联网上找到的所有教程,但我总是遇到同样的问题:我无法连接并从 haproxy 执行任何查询
实际状态:
-
galera 工作正常
root@db1:# mysql -u root -pPASSWORD -e 'SELECT VARIABLE_VALUE as "cluster size" FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME="wsrep_cluster_size"' +--------------+ | cluster size | +--------------+ | 2 | +--------------+ -
haproxy 安装良好,并且数据库中存在具有所有权限的用户。 haproxy 的配置文件如下:
global log 127.0.0.1 local0 log 127.0.0.1 local1 notice maxconn 1024 user haproxy group haproxy daemon stats socket /var/lib/haproxy/stats.sock mode 600 level admin stats timeout 2m defaults log global mode http option tcplog option dontlognull retries 3 option redispatch maxconn 1024 timeout connect 5000ms timeout client 50000ms timeout server 50000ms listen haproxy-monitoring bind *:80 mode http stats enable stats show-legends stats refresh 5s stats uri / stats realm Statistics stats auth User:Password stats admin if TRUE frontend lb1db bind *:3306 default_backend galera-cluster backend galera-cluster balance roundrobin server db1 192.168.0.1:3306 check weight 1 server db2 192.168.0.2:3306 check weight 1 -
my.cnf 如下:
[galera] wsrep_on=ON wsrep_provider=/usr/lib/galera/libgalera_smm.so wsrep_cluster_address=gcomm://192.168.0.94,192.168.0.93 wsrep_node_addres=192.168.0.1. #vm1 IP; in the other config is present the vm2 IP wsrep_node_name=db1 binlog_format=row default_storage_engine=InnoDB innodb_autoinc_lock_mode=2 wsrep_cluster_name="Cluster_name" wsrep_sst_method=rsync bind-address=192.168.0.1 #vm1 IP; in the other config is present the vm2 IP
当我尝试在 haproxy 中执行查询时,我得到以下结果:
mysql -u root -pPASSWORD --host=192.168.0.3 --port=3306
ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.0.3' (111 "Connection refused")
正如我写的那样,我遵循了几个教程,问题总是一样的。谁能帮帮我?
【问题讨论】:
-
系统日志中是否有任何来自 HAProxy 的内容?
-
@Michael-sqlbot 当前日志文件为空,其他 3 个文件(压缩)中只有这一行:haproxy-systemd-wrapper[4414]: haproxy-systemd-wrapper: exit, haproxy RC=0