MaxScale终止连接:路由器无法从连接错误中恢复

时间:2018-09-11 10:03:26

标签: java maxscale

请帮助。

我已经使用maxscale一个月了,但是今天发生了一些事情。没用然后,我看到了以下错误:

这是我来自spring boot错误日志的错误日志:

org.springframework.dao.DataAccessResourceFailureException:
### Error querying database.  Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Connection killed by MaxScale: Router could not recover from connection errors
### The error may exist in com/gop/exchange/mapper/MatchResultMapper.xml
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: select max(price)   maxPrice ,min(price) minPrice ,sum(number) amount   ,max(id)   closeid,min(id) openid from match_result_udc_iep where   create_time   >=   ?   and create_time < ?
### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Connection killed by MaxScale: Router could not recover from connection errors
; SQL []; Connection killed by MaxScale: Router could not recover from connection errors; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Connection killed by MaxScale: Router could not recover from connection errors
        at org.springframework.jdbc.support.SQLExceptionSubclassTranslator.doTranslate(SQLExceptionSubclassTranslator.java:79) ~[spring-jdbc-4.3.7.RELEASE.jar!/:4.3.7.RELEASE]
        at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:73) ~[spring-jdbc-4.3.7.RELEASE.jar!/:4.3.7.RELEASE]
        at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81) ~[spring-jdbc-4.3.7.RELEASE.jar!/:4.3.7.RELEASE]

我的maxscale版本:2.2.12 My maxscale version maxscale配置为:

[maxscale]
threads=auto

[server1]
type=server
address=192.168.133.15
port=3306
protocol=MySQLBackend

[server2]
type=server
address=192.168.133.16
port=3306
protocol=MySQLBackend

[MariaDB-Monitor]
type=monitor
module=mariadbmon
servers=server1,server2
user=maxscale_wx
passwd=05166D59D2C9BBB7B5BB77072AA5BF48
monitor_interval=10000 #监控心态10秒
backend_connect_attempts=3


[Read-Write-Service]
type=service
router=readwritesplit
router_options=master_accept_reads=true
servers=server1,server2
user=maxscale_route
passwd=05166D59D2C9BBB7B5BB77072AA5BF43
max_connections=3000


[MaxAdmin-Service]
type=service
router=cli
connection_timeout=300
max_connections=100

[Read-Write-Listener]
type=listener
service=Read-Write-Service
protocol=MySQLClient
port=4006

[MaxAdmin-Listener]
type=listener
service=MaxAdmin-Service
protocol=maxscaled
socket=default

谢谢。     

2 个答案:

答案 0 :(得分:0)

错误消息Connection killed by MaxScale: Router could not recover from connection errors告诉我们,readwritesplit路由器遇到了无法恢复的网络连接错误。大多数情况下,这意味着与主服务器的连接已丢失。

/var/log/maxscale/maxscale.log中查看MaxScale日志文件,查看在发生客户端错误时是否存在与MaxScale中配置的服务器有关的任何错误。如果错误与超时有关,则将backend_connect_timeoutbackend_read_timeout增加到更高的值可能会解决该问题。

答案 1 :(得分:0)

我遇到了同样的问题。但是,我使用python而不是java进行编程,并使用sqlalchemy(ORM工具包)来处理数据库。

我使用连接池进行连接。看来这就是问题的原因。

从该文档中,我们可以看到服务器必须设置poolpool连接的persistpoolmax和persistmaxtime选项。

因此,我为所有服务器添加了这两个选项,例如:

[server1]
type=server
address=slave1
port=3306
protocol=MariaDBBackend
persistpoolmax=100
persistmaxtime=3600

在我的程序中,连接回收时间等于persistmaxtime。

您可以从https://mariadb.com/kb/en/mariadb-maxscale-14/maxscale-administration-tutorial/#persistent获取更多信息,