Search code examples
shellredisredis-cli

How to connect to master in redis from slave


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?


Solution

  • 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