# 使用redis sentinel模式启动emqx\_auth\_redis插件报错

**URL:** <https://askemq.com/t/topic/3231>\
**Category:** EMQX\
**Tags:** 技术支持\
**Created:** [2022 年10 月 26 日 07:28 UTC](https://askemq.com/t/topic/3231 "2022-10-26T07:28:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

作者： ![1070842701](https://askemq.com/letter_avatar/1070842701/32/6_449c533f586939b6e5f246632a46421f.png) [@1070842701](https://askemq.com/u/1070842701)\
发布日期： [2022 年10 月 26 日 07:28 UTC](https://askemq.com/t/topic/3231/1 "2022-10-26T07:28:38Z")

</div>

### 环境信息

- EMQX 版本：4.4.8
- 操作系统及版本：centos 7
- 其他

### 问题描述

用redis sentinel模式启动插件报错，redis cluster模式可以正常启动

### 配置文件及日志

报错日志  
2022-10-26T15:15:48.557819+08:00 [error] [Redis] Can’t connect to Redis server: {timeout,{gen\_server,call,[eredis\_sentinel,{get\_master\_req,mymaster,true}]}}  
2022-10-26T15:15:48.559302+08:00 [error] Supervisor: {\<0.28355.111\>,ecpool\_worker\_sup}. Context: start\_error. Reason: {timeout,{gen\_server,call,[eredis\_sentinel,{get\_master\_req,mymaster,true}]}}. Offender: id={worker,1},pid=undefined.  
2022-10-26T15:15:48.558884+08:00 [error] Sentinel error getting master mymaster : exit:{timeout,{gen\_server,call,[\<0.28359.111\>,{request,[[\<\<“_“\>\>,“3”,\<\<”\r\n"\>\>],[[\<\<“$”\>\>,“8”,\<\<“\r\n”\>\>,\<\<“SENTINEL”\>\>,\<\<“\r\n”\>\>],[\<\<“$”\>\>,“23”,\<\<“\r\n”\>\>,\<\<“get-master-addr-by-name”\>\>,\<\<“\r\n”\>\>],[\<\<“$”\>\>,“8”,\<\<“\r\n”\>\>,\<\<“mymaster”\>\>,\<\<“\r\n”\>\>]]]},5000]}}  
2022-10-26T15:15:48.558206+08:00 [error] crasher: initial call: eredis\_client:init/1, pid: \<0.28358.111\>, registered\_name: [], exit: {{timeout,{gen\_server,call,[eredis\_sentinel,{get\_master\_req,mymaster,true}]}},[{gen\_server,call,2,[{file,“gen\_server.erl”},{line,238}]},{eredis\_client,connect,2,[{file,“eredis\_client.erl”},{line,353}]},{eredis\_client,init,1,[{file,“eredis\_client.erl”},{line,98}]},{gen\_server,init\_it,2,[{file,“gen\_server.erl”},{line,417}]},{gen\_server,init\_it,6,[{file,“gen\_server.erl”},{line,385}]},{proc\_lib,init\_p\_do\_apply,3,[{file,“proc\_lib.erl”},{line,226}]}]}, ancestors: [\<0.28356.111\>,\<0.28355.111\>,\<0.28353.111\>,emqx\_auth\_redis\_sup,\<0.28351.111\>], message\_queue\_len: 0, messages: [], links: [\<0.28356.111\>], dictionary: [{options,[]}], trap\_exit: false, status: running, heap\_size: 610, stack\_size: 28, reductions: 257; neighbours:  
2022-10-26T15:15:48.559666+08:00 [error] crasher: initial call: ecpool\_worker:init/1, pid: \<0.28356.111\>, registered\_name: [], exit: {{timeout,{gen\_server,call,[eredis\_sentinel,{get\_master\_req,mymaster,true}]}},[{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.28355.111\>,\<0.28353.111\>,emqx\_auth\_redis\_sup,\<0.28351.111\>], message\_queue\_len: 0, messages: [], links: [\<0.28357.111\>,\<0.28358.111\>,\<0.28355.111\>], dictionary: [], trap\_exit: true, status: running, heap\_size: 987, stack\_size: 28, reductions: 4441; neighbours:  
2022-10-26T15:15:48.559588+08:00 [error] Master request for mymaster to sentinel “10.187.4.139”:26379 failed with sentinel\_unreachable  
2022-10-26T15:15:48.559904+08:00 [error] Supervisor: {\<0.28353.111\>,ecpool\_pool\_sup}. Context: start\_error. Reason: {shutdown,{failed\_to\_start\_child,{worker,1},{timeout,{gen\_server,call,[eredis\_sentinel,{get\_master\_req,mymaster,true}]}}}}. Offender: id=worker\_sup,pid=undefined.  
2022-10-26T15:15:48.561483+08:00 [error] Supervisor: {local,emqx\_auth\_redis\_sup}. Context: start\_error. Reason: {shutdown,{failed\_to\_start\_child,worker\_sup,{shutdown,{failed\_to\_start\_child,{worker,1},{timeout,{gen\_server,call,[eredis\_sentinel,{get\_master\_req,mymaster,true}]}}}}}}. Offender: id=emqx\_auth\_redis,pid=undefined.  
2022-10-26T15:15:48.562037+08:00 [error] crasher: initial call: application\_master:init/4, pid: \<0.28350.111\>, registered\_name: [], exit: {{bad\_return,{{emqx\_auth\_redis\_app,start,[normal,[]]},{‘EXIT’,{{badmatch,{error,{shutdown,{failed\_to\_start\_child,emqx\_auth\_redis,{shutdown,{failed\_to\_start\_child,worker\_sup,{shutdown,{failed\_to\_start\_child,{worker,1},{timeout,{gen\_server,call,[eredis\_sentinel,{get\_master\_req,mymaster,true}]}}}}}}}}}},[{emqx\_auth\_redis\_app,start,2,[{file,“emqx\_auth\_redis\_app.erl”},{line,30}]},{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.28349.111\>], message\_queue\_len: 1, messages: [{‘EXIT’,\<0.28351.111\>,normal}], links: [\<0.28349.111\>,\<0.1435.0\>], dictionary: [], trap\_exit: true, status: running, heap\_size: 610, stack\_size: 28, reductions: 236; neighbours:  
2022-10-26T15:15:48.563240+08:00 [error] [Plugins] Load plugin emqx\_auth\_redis failed, cannot start plugin emqx\_auth\_redis for {bad\_return,{{emqx\_auth\_redis\_app,start,[normal,[]]},{‘EXIT’,{{badmatch,{error,{shutdown,{failed\_to\_start\_child,emqx\_auth\_redis,{shutdown,{failed\_to\_start\_child,worker\_sup,{shutdown,{failed\_to\_start\_child,{worker,1},{timeout,{gen\_server,call,[eredis\_sentinel,{get\_master\_req,mymaster,true}]}}}}}}}}}},[{emqx\_auth\_redis\_app,start,2,[{file,“emqx\_auth\_redis\_app.erl”},{line,30}]},{application\_master,start\_it\_old,4,[{file,“application\_master.erl”},{line,277}]}]}}}}  
2022-10-26T15:15:48.563499+08:00 [error] [Plugins] Load plugin emqx\_auth\_redis failed, cannot start plugin emqx\_auth\_redis for {bad\_return,{{emqx\_auth\_redis\_app,start,[normal,[]]},{‘EXIT’,{{badmatch,{error,{shutdown,{failed\_to\_start\_child,emqx\_auth\_redis,{shutdown,{failed\_to\_start\_child,worker\_sup,{shutdown,{failed\_to\_start\_child,{worker,1},{timeout,{gen\_server,call,[eredis\_sentinel,{get\_master\_req,mymaster,true}]}}}}}}}}}},[{emqx\_auth\_redis\_app,start,2,[{file,“emqx\_auth\_redis\_app.erl”},{line,30}]},{application\_master,start\_it\_old,4,[{file,“application\_master.erl”},{line,277}]}]}}}}  
2022-10-26T15:15:48.563728+08:00 [error] [Plugins] Load plugin emqx\_auth\_redis failed, cannot start plugin emqx\_auth\_redis for {bad\_return,{{emqx\_auth\_redis\_app,start,[normal,[]]},{‘EXIT’,{{badmatch,{error,{shutdown,{failed\_to\_start\_child,emqx\_auth\_redis,{shutdown,{failed\_to\_start\_child,worker\_sup,{shutdown,{failed\_to\_start\_child,{worker,1},{timeout,{gen\_server,call,[eredis\_sentinel,{get\_master\_req,mymaster,true}]}}}}}}}}}},[{emqx\_auth\_redis\_app,start,2,[{file,“emqx\_auth\_redis\_app.erl”},{line,30}]},{application\_master,start\_it\_old,4,[{file,“application\_master.erl”},{line,277}]}]}}}}  
2022-10-26T15:15:53.561723+08:00 [error] Sentinel error getting master mymaster : exit:{timeout,{gen\_server,call,[\<0.28366.111\>,{request,[[\<\<"_”\>\>,“3”,\<\<“\r\n”\>\>],[[\<\<“$”\>\>,“8”,\<\<“\r\n”\>\>,\<\<“SENTINEL”\>\>,\<\<“\r\n”\>\>],[\<\<“$”\>\>,“23”,\<\<“\r\n”\>\>,\<\<“get-master-addr-by-name”\>\>,\<\<“\r\n”\>\>],[\<\<“$”\>\>,“8”,\<\<“\r\n”\>\>,\<\<“mymaster”\>\>,\<\<“\r\n”\>\>]]]},5000]}}  
2022-10-26T15:15:53.561973+08:00 [error] Master request for mymaster to sentinel “10.187.4.139”:26380 failed with sentinel\_unreachable  
2022-10-26T15:15:58.563725+08:00 [error] Sentinel error getting master mymaster : exit:{timeout,{gen\_server,call,[\<0.28371.111\>,{request,[[\<\<“\*”\>\>,“3”,\<\<“\r\n”\>\>],[[\<\<“$”\>\>,“8”,\<\<“\r\n”\>\>,\<\<“SENTINEL”\>\>,\<\<“\r\n”\>\>],[\<\<“$”\>\>,“23”,\<\<“\r\n”\>\>,\<\<“get-master-addr-by-name”\>\>,\<\<“\r\n”\>\>],[\<\<“$”\>\>,“8”,\<\<“\r\n”\>\>,\<\<“mymaster”\>\>,\<\<“\r\n”\>\>]]]},5000]}}  
2022-10-26T15:15:58.563988+08:00 [error] Master request for mymaster to sentinel “10.187.4.139”:26381 failed with sentinel\_unreachable  
2022-10-26T15:15:58.564206+08:00 [error] Generic server eredis\_sentinel terminating. Reason: {timeout,{gen\_server,call,[eredis\_sentinel,{get\_master\_req,mymaster,true}]}}. Last message: {‘EXIT’,\<0.28356.111\>,{timeout,{gen\_server,call,[eredis\_sentinel,{get\_master\_req,mymaster,true}]}}}. State: {state,[{sentinel,“10.187.4.139”,26379},{sentinel,“10.187.4.139”,26380},{sentinel,“10.187.4.139”,26381}],undefined,,{errors,3,0,0,3}}.  
2022-10-26T15:15:58.564389+08:00 [error] crasher: initial call: eredis\_sentinel:init/1, pid: \<0.28357.111\>, registered\_name: eredis\_sentinel, exit: {{timeout,{gen\_server,call,[eredis\_sentinel,{get\_master\_req,mymaster,true}]}},[{gen\_server,decode\_msg,9,[{file,“gen\_server.erl”},{line,475}]},{proc\_lib,init\_p\_do\_apply,3,[{file,“proc\_lib.erl”},{line,226}]}]}, ancestors: [\<0.28356.111\>,\<0.28355.111\>,\<0.28353.111\>,emqx\_auth\_redis\_sup,\<0.28351.111\>], message\_queue\_len: 3, messages: [{‘EXIT’,\<0.28359.111\>,normal},{‘EXIT’,\<0.28366.111\>,normal},{‘EXIT’,\<0.28371.111\>,normal}], links: , dictionary: [{redis\_opts,}], trap\_exit: true, status: running, heap\_size: 610, stack\_size: 28, reductions: 29142; neighbours:

配置文件  
##--------------------------------------------------------------------

## Redis Auth/ACL Plugin

##--------------------------------------------------------------------

## Redis Server cluster type

## single Single redis server

## sentinel Redis cluster through sentinel

## cluster Redis through cluster

auth.redis.type = sentinel

## Redis server address.

## 

## Value: Port | IP:Port

## 

## Single Redis Server: 127.0.0.1:6379, localhost:6379

## Redis Sentinel: 127.0.0.1:26379,127.0.0.2:26379,127.0.0.3:26379

## Redis Cluster: 127.0.0.1:6379,127.0.0.2:6379,127.0.0.3:6379

auth.redis.server = 10.187.4.139:26379,10.187.4.139:26380,10.187.4.139:26381

## Redis sentinel cluster name.

## 

## Value: String

auth.redis.sentinel = mymaster

## Redis pool size.

## 

## Value: Number

auth.redis.pool = 16

## Redis database no.

## 

## Value: Number

auth.redis.database = 3

## Redis password.

## 

## Value: String

auth.redis.password =ruomima123

## Redis query timeout

## 

## Value: Duration

## auth.redis.query\_timeout = 5s

## Authentication query command.

## 

## Value: Redis cmd

## 

## Variables:

## - %u: username

## - %c: clientid

## - %C: common name of client TLS cert

## - %d: subject of client TLS cert

## 

## Examples:

## - HGET mqtt\_user:%u password

## - HMGET mqtt\_user:%u password

## - HMGET mqtt\_user:%u password salt

auth.redis.auth\_cmd = HMGET mqtt\_user:%u password

## Password hash.

## 

## Value: plain | md5 | sha | sha256 | bcrypt

auth.redis.password\_hash = plain

## sha256 with salt prefix

## auth.redis.password\_hash = salt,sha256

## sha256 with salt suffix

## auth.redis.password\_hash = sha256,salt

## bcrypt with salt prefix

## auth.redis.password\_hash = salt,bcrypt

## pbkdf2 with macfun iterations dklen

## macfun: md4, md5, ripemd160, sha, sha224, sha256, sha384, sha512

## auth.redis.password\_hash = pbkdf2,sha256,1000,20

## Superuser query command.

## 

## Value: Redis cmd

## 

## Variables:

## - %u: username

## - %c: clientid

## - %C: common name of client TLS cert

## - %d: subject of client TLS cert

auth.redis.super\_cmd = HGET mqtt\_user:%u is\_superuser

## ACL query command.

## 

## Value: Redis cmd

## 

## Variables:

## - %u: username

## - %c: clientid

auth.redis.acl\_cmd = HGETALL mqtt\_acl:%u

## Redis ssl configuration.

## 

## Value: on | off

#auth.redis.ssl = off

## CA certificate.

## 

## Value: File

#auth.redis.ssl.cacertfile = path/to/your/cafile.pem

## Client ssl certificate.

## 

## Value: File

#auth.redis.ssl.certfile = path/to/your/certfile

## Client ssl keyfile.

## 

## Value: File

#auth.redis.ssl.keyfile = path/to/your/keyfile

## In mode verify\_none the default behavior is to allow all x509-path

## validation errors.

## 

## Value: true | false

#auth.redis.ssl.verify = false

## If not specified, the server’s names returned in server’s certificate is validated against

## what’s provided `auth.redis.server` config’s host part.

## Setting to ‘disable’ will make EMQ X ignore unmatched server names.

## If set with a host name, the server’s names returned in server’s certificate is validated

## against this value.

## 

## Value: String | disable

## auth.redis.ssl.server\_name\_indication = disable

---

<div class="post-metadata">

作者： ![Shawn](https://askemq.com/user_avatar/askemq.com/shawn/32/35_2.png) [@Shawn](https://askemq.com/u/Shawn)\
发布日期： [2022 年10 月 26 日 09:36 UTC](https://askemq.com/t/topic/3231/2 "2022-10-26T09:36:24Z")

</div>

`SENTINEL get-master-addr-by-name mymaster` 日志里提示这个命令超时了。

---

<div class="post-metadata">

作者： ![1070842701](https://askemq.com/letter_avatar/1070842701/32/6_449c533f586939b6e5f246632a46421f.png) [@1070842701](https://askemq.com/u/1070842701)\
发布日期： [2022 年10 月 26 日 09:38 UTC](https://askemq.com/t/topic/3231/3 "2022-10-26T09:38:47Z")

</div>

谢谢 我也在定位，集群的端口是通的，但是机器上不去，感觉大概率是集群出问题了
