emqx.conf authentication redis设置错误

环境

  • EMQX 版本:5.1.6
  • 操作系统版本:

重现此问题的步骤

  1. 在 emqx.conf authentication块中添加配置
    {
    type = redis
    enable = true

     redis_type = single 
     
     pool_size = 8
     password_hash_algorithm {name = "plain", salt_position = "disable"}
     
     cmd = "HMGET DH:WEB_MQTT:${username} password_hash"
     database = 0
     password = password
     server = "127.0.0.1:6379"
    

}
启动报错
2024-04-26 16:57:12 EMQX_API_KEY__BOOTSTRAP_FILE [api_key.bootstrap_file]: /opt/emqx/data/api
2024-04-26 16:57:12 EMQX_RPC__PORT_DISCOVERY [rpc.port_discovery]: manual
2024-04-26 16:57:12 EMQX_NODE__NAME [node.name]: emqx@127.0.0.1
2024-04-26 16:57:12 2024-04-26T08:57:12.177192+00:00 [error] failed_to_check_schema: emqx_conf_schema
2024-04-26 16:57:12 2024-04-26T08:57:12.180588+00:00 [error] #{kind => validation_error,path => “authentication.1”,reason => “missing_mechanism_field”}
2024-04-26 16:57:13 ERROR: call_hocon_failed: -v -t 2024.04.26.08.57.11 -s emqx_conf_schema -c /opt/emqx/etc/emqx.conf -d /opt/emqx/data/configs generate
2024-04-26 16:57:17 WARNING: Default (insecure) Erlang cookie is in use.
2024-04-26 16:57:17 WARNING: Configure node.cookie in /opt/emqx/etc/emqx.conf or override from environment variable EMQX_NODE__COOKIE
2024-04-26 16:57:17 WARNING: NOTE: Use the same cookie for all nodes in the cluster.
2024-04-26 16:57:18 EMQX_API_KEY__BOOTSTRAP_FILE [api_key.bootstrap_file]: /opt/emqx/data/api
2024-04-26 16:57:18 EMQX_RPC__PORT_DISCOVERY [rpc.port_discovery]: manual
2024-04-26 16:57:18 EMQX_NODE__NAME [node.name]: emqx@127.0.0.1
2024-04-26 16:57:18 2024-04-26T08:57:18.681553+00:00 [error] failed_to_check_schema: emqx_conf_schema
2024-04-26 16:57:18 2024-04-26T08:57:18.683611+00:00 [error] #{kind => validation_error,path => “authentication.1”,reason => “missing_mechanism_field”}
2024-04-26 16:57:20 ERROR: call_hocon_failed: -v -t 2024.04.26.08.57.17 -s emqx_conf_schema -c /opt/emqx/etc/emqx.conf -d /opt/emqx/data/configs generate

authentication = [
  {
    backend = built_in_database
    enable = false
    mechanism = password_based
    password_hash_algorithm {name = sha256, salt_position = suffix}
    user_id_type = username
  },
  {
    backend = redis
    cmd = "HMGET mqtt_user:${username} password_hash salt"
    database = 0
    enable = true
    mechanism = password_based
    password = adfasd
    password_hash_algorithm {name = sha256, salt_position = suffix}
    pool_size = 8
    redis_type = single
    server = "127.0.0.1:6379"
    ssl {
      ciphers = []
      depth = 10
      enable = false
      hibernate_after = 5s
      log_level = notice
      reuse_sessions = true
      secure_renegotiate = true
      verify = verify_peer
      versions = [tlsv1.3, tlsv1.2]
    }
  }
]

TIP: 如果是复杂的配置不好配置。但是想固化在 emqx.conf中启动
可以在 dashbaord 配置好后
把配置从data/configs/cluster.hocon里面copy 出来。
最新版本,还可以使用:

 ./bin/emqx ctl conf
conf reload --replace|--merge              # reload etc/emqx.conf on local node
                                           # The new configuration values will be overlaid on the existing values by default.
                                           # use the --replace flag to replace existing values with the new ones instead.
----------------------------------         # ------------
conf show_keys                             # print all the currently used configuration keys.
conf show [<key>]                          # Print in-use configs (including default values) under the given key.
                                           # Print ALL keys if key is not provided
conf load --replace|--merge <path>         # Load a HOCON format config file.
                                           # The new configuration values will be overlaid on the existing values by default.
                                           # use the --replace flag to replace existing values with the new ones instead.
                                           # The current node will initiate a cluster wide config change
                                           # transaction to sync the changes to other nodes in the cluster.
                                           # NOTE: do not make runtime config changes during rolling upgrade.
----------------------------------         # ------------
conf cluster_sync status                   # Show cluster config sync status summary for all nodes.
conf cluster_sync inspect <ID>             # Inspect detailed information of the config change transaction at the given commit ID
conf cluster_sync skip [node]              # Increment the (currently failing) commit on the given node.
                                           # WARNING: This results in inconsistent configs among the clustered nodes.
conf cluster_sync fast_forward [node] <ID> # Fast-forward config change to the given commit ID on the given node.
                                           # WARNING: This results in inconsistent configs among the clustered nodes.

来操作配置。

好的谢谢