Connecting to remote redis server

妖精的绣舞 提交于 2019-12-02 22:13:01

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.

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)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!