0

I have 1 master and 2 slaves. First I'm writining info replication to get infromation. If I'm on slave, I try to coonect to master with redis-cli -h ip-redis-master -a password. Can I automatize this? For example: redis-cli -h $(info replication | cut -d ip-addr-master) -a password. Is it possible?

1 Answers1

0

Maybe you want this:

redis-cli -h `redis-cli info replication|grep master_host|awk -F':' '{print $2}'|awk -F'\r' '{print $1}'` -a master-password
baozilaji
  • 304
  • 1
  • 10
  • Thanks for help but when I started this command I have error: `Could not connect to Redis at -p:6379: Name or service not known`. – igaro4ak337 Sep 09 '21 at 06:56
  • thanks for hel anyway but it won't work, mb I found other ways – igaro4ak337 Sep 09 '21 at 08:35
  • what's the error info? is the port default value 6379? – baozilaji Sep 09 '21 at 08:37
  • Yes, `Could not connect to Redis at -a:6379: Name or service not known` – igaro4ak337 Sep 09 '21 at 08:41
  • maybe you need to handle this problem step by step: 1、make sure that you can get the master ip info by this command ``` redis-cli info replication | grep master_host ``` 2、remeber the host info and try to connect to master manually ``` redis-cli -h ip -a pass ``` 3、if everything is ok, then maybe you need to check is there any invisible character in the result of redis-cli info replication, run this: ``` $(redis-cli info replication|grep master_host|awk -F':' '{print $2}') ``` – baozilaji Sep 09 '21 at 08:56