使用sentinel的情况下,一步登录redis的master主机

redis-bus() {
 if [ x"$#" != x"1" ] ; then
   echo "Usage: redis-bus <master-name>" 
 else
   RedisCli='/home/tutor/lihy/redis-4.0.6/src/redis-cli'
   cmd=$(echo "sentinel get-master-addr-by-name $1" | $RedisCli -h sentinel-server -p 26379 | tr -s '\n' ' ' | awk -v cli=$RedisCli '{ print cli" -h "$1" -p "$2" -a password"}')
   $cmd
 fi
}

 

Leave a Reply

Your email address will not be published.