k8s部署emqx,使用mysql插件进行认证,连接mysql超时

环境信息

  • EMQX 版本:k8s 环境,容器镜像 emqx/emqx,查看 emqx 版本为 4.3.11
    image

  • 操作系统及版本:宿主机 网易云 centos8

  • 其他:
    1.mysql版本号为 8.0.27;
    2.emqx 为 statefulset,mysql 也为 statefulset

问题描述

k8s 上部署了 emqx 和 mysql8 的有状态服务。其中 mysql 服务地址为:10.233.47.222。
根据 emqx 官网提供的 mysql 认证初始化脚本,创建了数据库 mqtt,两张表 mqtt_user,mqtt_acl。
创建 emqx 需要的 ConfigMap,用来定义环境变量,内容如下:

kind: ConfigMap
apiVersion: v1
metadata:
  name: emqx-config
  namespace: k8s-demo
  annotations:
    kubesphere.io/alias-name: emqx-config
    kubesphere.io/creator: admin
    kubesphere.io/description: emqx-config
data:
  EMQX_ACL_NOMATCH: deny
  EMQX_ALLOW_ANONYMOUS: 'false'
  EMQX_AUTH__MYSQL__DATABASE: mqtt
  EMQX_AUTH__MYSQL__PASSWORD: emqx123
  EMQX_AUTH__MYSQL__PASSWORD_HASH: plain
  EMQX_AUTH__MYSQL__SERVER: '10.233.47.222:3306'
  EMQX_AUTH__MYSQL__USERNAME: mqtt
  EMQX_LOADED_PLUGINS: emqx_auth_mysql
  EMQX_RPC__PORT_DISCOVERY: k8s
  update_etc_resolv.sh: >-
    echo "$(sed 's/options ndots:5/#options ndots:5/g' /etc/resolv.conf)" >
    /etc/resolv.conf

在 emqx pod 上设置了 EMQX_ 开头的环境变量,用以加载 mysql 认证插件,如下所示:

启动容器前,再次检查 emqx 的环境变量,并将环境变量中配置的 mysql 服务地址、数据库、口令等,在除 emqx 之外的其他容器中连接 10.233.47.222 ,都能成功连接。

然后启动 emqx 容器,容器可以启动成功,但是后台日志显示连接 mysql 超时。后台日志如下:

登录 emqx 的 dashboard,在插件管理页面,启动 mysql 认证插件,提示报错,报错信息如下:
{emqx_auth_mysql,{bad_return,{{emqx_auth_mysql_app,start,[normal,[]]},{‘EXIT’,{{badmatch,{error,{shutdown,{failed_to_start_child,emqx_auth_mysql,{shutdown,{failed_to_start_child,worker_sup,{shutdown,{failed_to_start_child,{worker,1},timeout}}}}}}}},[{emqx_auth_mysql_app,start,2,[{file,“emqx_auth_mysql_app.erl”},{line,38}]},{application_master,start_it_old,4,[{file,“application_master.erl”},{line,277}]}]}}}}}

在 emqx 容器终端使用命令 “busybox-extras telnet 10.233.47.222 3306” 去检查 emqx 能否访问到 mysql,也是可以 telnet 通的,如下图:

配置文件及日志

emqx_mysql_auth.conf 配置文件

因为是在 pod 中配置了环境变量,这里只是列出配置文件中数据库连接部分。

auth.mysql.server = 10.233.47.222:3306
auth.mysql.pool = 8
auth.mysql.username = mqtt
auth.mysql.password = emqx123
auth.mysql.database = mqtt
auth.mysql.password_hash = plain

后台日志

EMQX_LOADED_PLUGINS=emqx_auth_mysql

 acl_nomatch = "deny"

 allow_anonymous = "false"

 listener.ssl.external.acceptors = "32"

 listener.ssl.external.max_connections = "102400"

 listener.tcp.external.acceptors = "64"

 listener.tcp.external.max_connections = "1024000"

 listener.ws.external.acceptors = "16"

 listener.ws.external.max_connections = "102400"

 listener.wss.external.acceptors = "16"

 listener.wss.external.max_connections = "102400"

 log.to = "console"

 node.max_ets_tables = "2097152"

 node.max_ports = "1048576"

 node.name = "emqx-0@10.233.113.73"

 node.process_limit = "2097152"

 rpc.port_discovery = "manual"


 Starting emqx on node emqx-0@10.233.113.73

 Start mqtt:tcp:internal listener on 127.0.0.1:11883 successfully.

 Start mqtt:tcp:external listener on 0.0.0.0:1883 successfully.

 Start mqtt:ws:external listener on 0.0.0.0:8083 successfully.

 Start mqtt:ssl:external listener on 0.0.0.0:8883 successfully.

 Start mqtt:wss:external listener on 0.0.0.0:8084 successfully.

 Start http:management listener on 8081 successfully.

 Start http:dashboard listener on 18083 successfully.

 2022-03-22T10:17:29.407988+08:00 [error] crasher: initial call: mysql_conn:init/1, pid: <0.2027.0>, registered_name: [], exit: {timeout,[{gen_server,init_it,6,[{file,"gen_server.erl"},{line,401}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,226}]}]}, ancestors: [<0.2026.0>,<0.2025.0>,<0.2023.0>,emqx_auth_mysql_sup,<0.2021.0>], message_queue_len: 0, messages: [], links: [<0.2026.0>], dictionary: [], trap_exit: false, status: running, heap_size: 376, stack_size: 28, reductions: 382; neighbours:

 2022-03-22T10:17:29.408553+08:00 [error] [MySQL] Can't connect to MySQL server: timeout

 2022-03-22T10:17:29.408798+08:00 [error] Supervisor: {<0.2025.0>,ecpool_worker_sup}. Context: start_error. Reason: timeout. Offender: id={worker,1},pid=undefined.

 2022-03-22T10:17:29.409004+08:00 [error] crasher: initial call: ecpool_worker:init/1, pid: <0.2026.0>, registered_name: [], exit: {timeout,[{gen_server,init_it,6,[{file,"gen_server.erl"},{line,401}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,226}]}]}, ancestors: [<0.2025.0>,<0.2023.0>,emqx_auth_mysql_sup,<0.2021.0>], message_queue_len: 1, messages: [{'EXIT',<0.2027.0>,timeout}], links: [<0.2025.0>], dictionary: [], trap_exit: true, status: running, heap_size: 1598, stack_size: 28, reductions: 4381; neighbours:

 2022-03-22T10:17:29.409484+08:00 [error] Supervisor: {<0.2023.0>,ecpool_pool_sup}. Context: start_error. Reason: {shutdown,{failed_to_start_child,{worker,1},timeout}}. Offender: id=worker_sup,pid=undefined.

 2022-03-22T10:17:29.410735+08:00 [error] Supervisor: {local,emqx_auth_mysql_sup}. Context: start_error. Reason: {shutdown,{failed_to_start_child,worker_sup,{shutdown,{failed_to_start_child,{worker,1},timeout}}}}. Offender: id=emqx_auth_mysql,pid=undefined.

 2022-03-22T10:17:29.411123+08:00 [error] crasher: initial call: application_master:init/4, pid: <0.2020.0>, registered_name: [], exit: {{bad_return,{{emqx_auth_mysql_app,start,[normal,[]]},{'EXIT',{{badmatch,{error,{shutdown,{failed_to_start_child,emqx_auth_mysql,{shutdown,{failed_to_start_child,worker_sup,{shutdown,{failed_to_start_child,{worker,1},timeout}}}}}}}},[{emqx_auth_mysql_app,start,2,[{file,"emqx_auth_mysql_app.erl"},{line,38}]},{application_master,start_it_old,4,[{file,"application_master.erl"},{line,277}]}]}}}},[{application_master,init,4,[{file,"application_master.erl"},{line,138}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,226}]}]}, ancestors: [<0.2019.0>], message_queue_len: 1, messages: [{'EXIT',<0.2021.0>,normal}], links: [<0.2019.0>,<0.1435.0>], dictionary: [], trap_exit: true, status: running, heap_size: 610, stack_size: 28, reductions: 235; neighbours:

 2022-03-22T10:17:29.417045+08:00 [error] [Plugins] Load plugin emqx_auth_mysql failed, cannot start plugin emqx_auth_mysql for {bad_return,{{emqx_auth_mysql_app,start,[normal,[]]},{'EXIT',{{badmatch,{error,{shutdown,{failed_to_start_child,emqx_auth_mysql,{shutdown,{failed_to_start_child,worker_sup,{shutdown,{failed_to_start_child,{worker,1},timeout}}}}}}}},[{emqx_auth_mysql_app,start,2,[{file,"emqx_auth_mysql_app.erl"},{line,38}]},{application_master,start_it_old,4,[{file,"application_master.erl"},{line,277}]}]}}}}

 EMQ X Broker 4.3.11 is running now!

 2022-03-22T10:18:24.139539+08:00 [warning] [Alarm Handler] Alarm high_system_memory_usage is activated, System memory usage is higher than 70%

你的 mysql 开启了远程访问权限么

开启了,用户 mqtt 的权限是 %
我在其他容器中都是可以远程登录mysql的。

你在 EMQX 那台机器上,用配置的帐号 密码 去连接对应的数据库看看是否正常

您的意思是我在 emqx 容器上安装mysql客户端进行测试吗?
其他容器我进行测试连接,使用的是同 emqx 相同的mysql 连接配置。

在 emqx 容器安装了 mysql client,然后连接 mysql8 服务,能够远程访问。

但是在 emqx dashboard 启动插件,还是失败。

使用 emqx_ctl 命令启动,直接就报 not_found 错误。

dashboard 启用插件提示的错误信息主要就是timeout。

load plugin 应该把 .conf 去掉
麻烦你清空下日志, 然后将日志等级设置为 debug, 重试一次,然后把日志贴这里

以下是容器启动后的日志:

EMQX_LOADED_PLUGINS=emqx_auth_mysql

acl_nomatch = “deny”

allow_anonymous = “false”

listener.ssl.external.acceptors = “32”

listener.ssl.external.max_connections = “102400”

listener.tcp.external.acceptors = “64”

listener.tcp.external.max_connections = “1024000”

listener.ws.external.acceptors = “16”

listener.ws.external.max_connections = “102400”

listener.wss.external.acceptors = “16”

listener.wss.external.max_connections = “102400”

log.level = “debug”

log.to = “console”

node.max_ets_tables = “2097152”

node.max_ports = “1048576”

node.name = “emqx-0@10.233.113.108

node.process_limit = “2097152”

rpc.port_discovery = “manual”

2022-03-22T15:29:04.430954+08:00 [info] event=server_setup_successfully driver=tcp socket="#Port<0.11>"

2022-03-22T15:29:04.431227+08:00 [info] event=start

Starting emqx on node emqx-0@10.233.113.108

Start mqtt:tcp:internal listener on 127.0.0.1:11883 successfully.

Start mqtt:tcp:external listener on 0.0.0.0:1883 successfully.

Start mqtt:ws:external listener on 0.0.0.0:8083 successfully.

Start mqtt:ssl:external listener on 0.0.0.0:8883 successfully.

Start mqtt:wss:external listener on 0.0.0.0:8084 successfully.

2022-03-22T15:29:04.611348+08:00 [debug] Adding Defaults

2022-03-22T15:29:04.611465+08:00 [debug] Right Hand Side Substitutions

2022-03-22T15:29:04.611526+08:00 [debug] Applying Datatypes

2022-03-22T15:29:04.612219+08:00 [debug] Validation

2022-03-22T15:29:04.612408+08:00 [debug] Applied 1:1 Mappings

2022-03-22T15:29:04.612453+08:00 [debug] “emqx_management.application” in Translations to drop…

2022-03-22T15:29:04.612622+08:00 [debug] Running translation for emqx_management.listeners

2022-03-22T15:29:04.613351+08:00 [debug] Applied Translations

Start http:management listener on 8081 successfully.

2022-03-22T15:29:04.619673+08:00 [info] [Plugins] Started plugins: [xmerl,jiffy,minirest,emqx_management]

2022-03-22T15:29:04.619758+08:00 [info] [Plugins] Load plugin emqx_management successfully

2022-03-22T15:29:04.641886+08:00 [debug] Adding Defaults

2022-03-22T15:29:04.641984+08:00 [debug] Right Hand Side Substitutions

2022-03-22T15:29:04.642041+08:00 [debug] Applying Datatypes

2022-03-22T15:29:04.642448+08:00 [debug] Validation

2022-03-22T15:29:04.642546+08:00 [debug] Applied 1:1 Mappings

2022-03-22T15:29:04.642636+08:00 [debug] Running translation for emqx_dashboard.listeners

2022-03-22T15:29:04.643248+08:00 [debug] Applied Translations

Start http:dashboard listener on 18083 successfully.

2022-03-22T15:29:04.647973+08:00 [info] [Plugins] Started plugins: [emqx_dashboard]

2022-03-22T15:29:04.648057+08:00 [info] [Plugins] Load plugin emqx_dashboard successfully

2022-03-22T15:29:04.649464+08:00 [debug] Adding Defaults

2022-03-22T15:29:04.649522+08:00 [debug] Right Hand Side Substitutions

2022-03-22T15:29:04.649575+08:00 [debug] Applying Datatypes

2022-03-22T15:29:04.649617+08:00 [debug] Validation

2022-03-22T15:29:04.649659+08:00 [debug] Applied 1:1 Mappings

2022-03-22T15:29:04.649702+08:00 [debug] Applied Translations

2022-03-22T15:29:04.650101+08:00 [info] [Plugins] Started plugins: [recon,emqx_recon]

2022-03-22T15:29:04.650168+08:00 [info] [Plugins] Load plugin emqx_recon successfully

2022-03-22T15:29:04.655887+08:00 [debug] Adding Defaults

2022-03-22T15:29:04.655974+08:00 [debug] Right Hand Side Substitutions

2022-03-22T15:29:04.656032+08:00 [debug] Applying Datatypes

2022-03-22T15:29:04.656225+08:00 [debug] Validation

2022-03-22T15:29:04.656303+08:00 [debug] Applied 1:1 Mappings

2022-03-22T15:29:04.656353+08:00 [debug] Applied Translations

2022-03-22T15:29:04.663300+08:00 [info] [Plugins] Started plugins: [emqx_retainer]

2022-03-22T15:29:04.663382+08:00 [info] [Plugins] Load plugin emqx_retainer successfully

2022-03-22T15:29:04.668279+08:00 [debug] Adding Defaults

2022-03-22T15:29:04.668368+08:00 [debug] Right Hand Side Substitutions

2022-03-22T15:29:04.668460+08:00 [debug] Applying Datatypes

2022-03-22T15:29:04.668751+08:00 [debug] Validation

2022-03-22T15:29:04.668830+08:00 [debug] Applied 1:1 Mappings

2022-03-22T15:29:04.668904+08:00 [debug] Applied Translations

2022-03-22T15:29:04.671963+08:00 [info] [Plugins] Started plugins: [emqx_telemetry]

2022-03-22T15:29:04.672061+08:00 [info] [Plugins] Load plugin emqx_telemetry successfully

2022-03-22T15:29:04.680564+08:00 [debug] Adding Defaults

2022-03-22T15:29:04.680636+08:00 [debug] Right Hand Side Substitutions

2022-03-22T15:29:04.680696+08:00 [debug] Applying Datatypes

2022-03-22T15:29:04.680973+08:00 [debug] Validation

2022-03-22T15:29:04.681017+08:00 [debug] Applied 1:1 Mappings

2022-03-22T15:29:04.681094+08:00 [debug] Running translation for emqx_rule_engine.events

2022-03-22T15:29:04.681574+08:00 [debug] Applied Translations

2022-03-22T15:29:04.686527+08:00 [info] [Plugins] Started plugins: [rulesql,getopt,emqx_rule_engine]

2022-03-22T15:29:04.686595+08:00 [info] [Plugins] Load plugin emqx_rule_engine successfully

2022-03-22T15:29:04.707578+08:00 [info] [Plugins] auth.mysql.database = “mqtt”

2022-03-22T15:29:04.707661+08:00 [info] [Plugins] auth.mysql.password = “emqx123”

2022-03-22T15:29:04.707719+08:00 [info] [Plugins] auth.mysql.password_hash = “plain”

2022-03-22T15:29:04.707769+08:00 [info] [Plugins] auth.mysql.server = “10.233.47.222:3306”

2022-03-22T15:29:04.707831+08:00 [info] [Plugins] auth.mysql.username = “mqtt”

2022-03-22T15:29:04.707887+08:00 [debug] Adding Defaults

2022-03-22T15:29:04.707966+08:00 [debug] Right Hand Side Substitutions

2022-03-22T15:29:04.708019+08:00 [debug] Applying Datatypes

2022-03-22T15:29:04.708386+08:00 [debug] Validation

2022-03-22T15:29:04.708462+08:00 [debug] Applied 1:1 Mappings

2022-03-22T15:29:04.708526+08:00 [debug] Running translation for emqx_auth_mysql.server

2022-03-22T15:29:04.708776+08:00 [debug] Running translation for emqx_auth_mysql.password_hash

2022-03-22T15:29:04.708841+08:00 [debug] Applied Translations

2022-03-22T15:29:09.710495+08:00 [error] crasher: initial call: mysql_conn:init/1, pid: <0.2027.0>, registered_name: [], exit: {timeout,[{gen_server,init_it,6,[{file,“gen_server.erl”},{line,401}]},{proc_lib,init_p_do_apply,3,[{file,“proc_lib.erl”},{line,226}]}]}, ancestors: [<0.2026.0>,<0.2025.0>,<0.2023.0>,emqx_auth_mysql_sup,<0.2021.0>], message_queue_len: 0, messages: [], links: [<0.2026.0>], dictionary: [], trap_exit: false, status: running, heap_size: 376, stack_size: 28, reductions: 382; neighbours:

2022-03-22T15:29:09.711163+08:00 [error] [MySQL] Can’t connect to MySQL server: timeout

2022-03-22T15:29:09.711419+08:00 [error] Supervisor: {<0.2025.0>,ecpool_worker_sup}. Context: start_error. Reason: timeout. Offender: id={worker,1},pid=undefined.

2022-03-22T15:29:09.711644+08:00 [error] crasher: initial call: ecpool_worker:init/1, pid: <0.2026.0>, registered_name: [], exit: {timeout,[{gen_server,init_it,6,[{file,“gen_server.erl”},{line,401}]},{proc_lib,init_p_do_apply,3,[{file,“proc_lib.erl”},{line,226}]}]}, ancestors: [<0.2025.0>,<0.2023.0>,emqx_auth_mysql_sup,<0.2021.0>], message_queue_len: 1, messages: [{‘EXIT’,<0.2027.0>,timeout}], links: [<0.2025.0>], dictionary: [], trap_exit: true, status: running, heap_size: 1598, stack_size: 28, reductions: 4381; neighbours:

2022-03-22T15:29:09.712155+08:00 [error] Supervisor: {<0.2023.0>,ecpool_pool_sup}. Context: start_error. Reason: {shutdown,{failed_to_start_child,{worker,1},timeout}}. Offender: id=worker_sup,pid=undefined.

2022-03-22T15:29:09.713097+08:00 [error] Supervisor: {local,emqx_auth_mysql_sup}. Context: start_error. Reason: {shutdown,{failed_to_start_child,worker_sup,{shutdown,{failed_to_start_child,{worker,1},timeout}}}}. Offender: id=emqx_auth_mysql,pid=undefined.

2022-03-22T15:29:09.713432+08:00 [error] crasher: initial call: application_master:init/4, pid: <0.2020.0>, registered_name: [], exit: {{bad_return,{{emqx_auth_mysql_app,start,[normal,[]]},{‘EXIT’,{{badmatch,{error,{shutdown,{failed_to_start_child,emqx_auth_mysql,{shutdown,{failed_to_start_child,worker_sup,{shutdown,{failed_to_start_child,{worker,1},timeout}}}}}}}},[{emqx_auth_mysql_app,start,2,[{file,“emqx_auth_mysql_app.erl”},{line,38}]},{application_master,start_it_old,4,[{file,“application_master.erl”},{line,277}]}]}}}},[{application_master,init,4,[{file,“application_master.erl”},{line,138}]},{proc_lib,init_p_do_apply,3,[{file,“proc_lib.erl”},{line,226}]}]}, ancestors: [<0.2019.0>], message_queue_len: 1, messages: [{‘EXIT’,<0.2021.0>,normal}], links: [<0.2019.0>,<0.1435.0>], dictionary: [], trap_exit: true, status: running, heap_size: 610, stack_size: 28, reductions: 235; neighbours:

2022-03-22T15:29:09.714254+08:00 [notice] Application: emqx_auth_mysql. Exited: {bad_return,{{emqx_auth_mysql_app,start,[normal,[]]},{‘EXIT’,{{badmatch,{error,{shutdown,{failed_to_start_child,emqx_auth_mysql,{shutdown,{failed_to_start_child,worker_sup,{shutdown,{failed_to_start_child,{worker,1},timeout}}}}}}}},[{emqx_auth_mysql_app,start,2,[{file,“emqx_auth_mysql_app.erl”},{line,38}]},{application_master,start_it_old,4,[{file,“application_master.erl”},{line,277}]}]}}}}. Type: temporary.

2022-03-22T15:29:09.719669+08:00 [notice] Application: ecpool. Exited: stopped. Type: temporary.

2022-03-22T15:29:09.719883+08:00 [notice] Application: mysql. Exited: stopped. Type: temporary.

2022-03-22T15:29:09.720016+08:00 [error] [Plugins] Load plugin emqx_auth_mysql failed, cannot start plugin emqx_auth_mysql for {bad_return,{{emqx_auth_mysql_app,start,[normal,[]]},{‘EXIT’,{{badmatch,{error,{shutdown,{failed_to_start_child,emqx_auth_mysql,{shutdown,{failed_to_start_child,worker_sup,{shutdown,{failed_to_start_child,{worker,1},timeout}}}}}}}},[{emqx_auth_mysql_app,start,2,[{file,“emqx_auth_mysql_app.erl”},{line,38}]},{application_master,start_it_old,4,[{file,“application_master.erl”},{line,277}]}]}}}}

2022-03-22T15:29:09.722098+08:00 [info] [Modules] Load emqx_mod_acl_internal module successfully.

2022-03-22T15:29:09.722322+08:00 [info] [Modules] Load emqx_mod_presence module successfully.

EMQ X Broker 4.3.11 is running now!

2022-03-22T15:29:15.695270+08:00 [debug] file: emqx_telemetry.erl, line: 369, mfa: {emqx_telemetry,report_telemetry,1}, msg: telemetry_data_reported, pid: <0.2003.0>

2022-03-22T15:30:04.442291+08:00 [warning] [Alarm Handler] Alarm high_system_memory_usage is activated, System memory usage is higher than 70%

以下为通过命令启用插件的日志:

@blankalupo 你好。我清理了日志,按照你所说的重新启动了容器,日志已贴出。麻烦看下具体是什么原因导致的timeout吗?不胜感谢。

我看到你的mysql版本是8,那么参考一下常见错误文档

这个都设置了。而且不是4.3版本支持了mysql8的默认认证方式了吗。

我安装了mysql5.7,然后测试,都是同样的问题。
一样的数据库连接,用 mysql-client 连接是能访问成功的。但是一旦启用 emqx_auth_mysql 插件,就会报 timeout。

日志的报错是连接超时了,但是我从日志中看不出你的网络拓扑。可以尝试容器内telnet一下mysql的服务,网络的问题先排查一下。k8s的业务我不是特别熟,但是好像有容器DNS的能力,也就是不通过IP去访问,而是将网络托管给k8s。
以上是思路,如果telnet没有问题,可以贴一下你的网络拓扑,我们会尝试复现debug

看下这个k8s的文档

emqx 容器内 telnet mysql8 是没问题的,这个在最前面的主题内容中贴了截图。
因为我是要做一个平台,所以在 k8s 中部署了好几个服务,有 mysql、mongodb、javaweb、emqx等。在其他应用的容器中直接访问 mysql 数据库都是没问题的。在 emqx 容器中安装了 mysql 客户端去连接 mysql8 也是没问题的,这个前面的回复中贴了图。但就是启用 emqx_auth_mysql 插件失败。
emqx_auth_mysql.conf 中配置的是 ip 地址,这跟其他容器中的应用访问的地址都是一样的。
有个比较有意思的情况是,我在 emqx 的 dashboard 配置了 mysql8 的资源,ip 地址跟 emqx_auth_mysql.conf 中配置的服务地址是一样的,点击页面上的测试,是能连接成功的。
所以我不知道 emqx_auth_mysql 到底出了什么问题。

网络拓扑稍后贴上。

您好。不好意思,拓扑图发出来的晚了。
以下是网络拓扑示意图。
k8s 网络拓扑示意图

除了 emqx 启用 emqx_auth_mysql 会出现timeout之外,在 emqx 容器内部以及其他服务的容器内部直接使用 mysql client 连接 mysql 都是没有问题的。

我们没有复现出来问题。
提供一个思路,如果你的java web能够顺利的访问mysql,那么推荐你使用http 认证,这种做法会更加的灵活。我们也遇到过客户需要转移认证方式的场景,随着业务复杂度变高,单纯的mysql可能会导致一些设备权限不同导致的业务难以分离,但是通过一层服务来控制,灵活度和扩展性都会更强。