修改Redis中bind地址
阅读原文时间:2021年04月20日阅读:1

昨天刚装完redis,今天想通过eclipse去实现一些业务场景,发现被服务器拒绝连接了,然后想到应该是自己的IP变掉了,然后想去redis.conf里面去修改下bind

  [root@localhost /]# cd redis/redis-5.0.3/
    [root@localhost redis-5.0.3]# ls
    00-RELEASENOTES  CONTRIBUTING  deps     Makefile   README.md   runtest          runtest-sentinel  src    utils
    BUGS             COPYING       INSTALL  MANIFESTO  redis.conf  runtest-cluster  sentinel.conf     tests
    [root@localhost redis-5.0.3]# vi redis.conf

?bind 然后回车,按n向上搜索

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bind 127.0.0.1

# Protected mode is a layer of security protection, in order to avoid that
# Redis instances left open on the internet are accessed and exploited.

并没有昨天绑定的IP,然后想去etc目录去找下,果然,里面有个昨天我安装redis时修改的配置文件

    [root@localhost redis]# cd /etc/redis
    [root@localhost redis]# ls
     6379.conf
    [root@localhost redis]#      

然后去里面找到昨天bind的地址,把它修改成自己要连的IP就好了

  [root@localhost redis]# vi 6379.conf 

?bind,然后回车,按n,向上搜索,果然被我找到了

  # IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES
# JUST COMMENT THE FOLLOWING LINE.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bind 127.0.0.1 192.168.160.128

# Protected mode is a layer of security protection, in order to avoid that
# Redis instances left open on the internet are accessed and exploited.

去客户端查下:

127.0.0.1:6379> CONFIG GET bind
1) "bind"
2) "127.0.0.1 192.168.160.128"
127.0.0.1:6379> 

然后就有结果了,之后就能正常连接。(初学redis,服务器在自己电脑上,会出现这样的问题,感觉以后去公司应该就不会碰到这样的问题了)