Connecting to remote redis server

user1304683 picture user1304683 · May 29, 2013 · Viewed 68.7k times · Source

I wanted to make some changes in redis.conf, so that whenever i type redis-cli it connects me to redis installed on remote server.

I know that we can connect to redis installed on remote server by :

redis-cli -h 'IP-Address-Of-Server'. 

But actually, I have some bash scripts and in those scripts i have used redis-cli at many place. So instead of replacing redis-cli with redis-cli -h 'IP-Address-Of-Server' in each file, I wanted to somehow change redis configuration, so that by default it connects me to the remote server. I hope it make sense :)

Answer

Tommaso Barbugli picture Tommaso Barbugli · May 29, 2013

there is no good reason to touch redis conf for this.

just make a script that wraps redis-cli with the desired parameters to connect to the remote host

eg. create a redis-cli-remotename.sh

#!/bin/sh
redis-cli -h remote.host_name

and give it +x permissions (eg. chmod +x redis-cli-remotename.sh)