Connecting to remote redis server

前端 未结 2 458
梦毁少年i
梦毁少年i 2021-02-04 00:23

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 i

2条回答
  •  被撕碎了的回忆
    2021-02-04 01:06

    Like Tommaso said, this is no good reason to touch the redis conf for this purpose. Instead what you can do is use environment variables to in your bash scripts to execute the command and then use that environment variable wherever you've used redis-cli directly.

    For eg. $REDIS_CONNECTION="redis-cli -h "

    If at any future point in time, you decide to change the host you want to connect to, its simply a matter of changing the env variables value.

    Replacing redis-cli with the environment variable is pretty straightforward with sed in all the files. So that shouldn't be much of a hassle.

提交回复
热议问题