zoukankan      html  css  js  c++  java
  • CentOS下配置redis允许远程连接

    © 版权声明:本文为博主原创文章,转载请注明出处

    1. 目的

      因为想要学习redis,因此在虚拟机中安装了redis,为了实现在物理机可以访问redis,弄了好久;因此记录下来,以免忘记。

    2. 环境

      虚拟机:CentOS Linux release 7.4.1708 (Core)

      redis:4.0.8

      防火墙:iptables

    3. 配置

      3.1 配置redis.conf

        将 bind 127.0.0.1 使用#注释掉,改为# bind 127.0.0.1(bind配置的是允许连接的ip,默认只允许本机连接;若远程连接需注释掉,或改为0.0.0.0)

        将 protected-mode yes 改为 protected-mode no(3.2之后加入的新特性,目的是禁止公网访问redis cache,增强redis的安全性)

        将 requirepass foobared 注释去掉,foobared为密码,也可修改为别的值(可选,建议设置)

      3.2 设置iptables规则,允许外部访问6379端口

        iptables -I INPUT 1 -p tcp -m state --state NEW -m tcp --dport 6379 -j ACCEPT

        临时生效,重启后失效。若想永久生效,请参考另一篇文章:http://www.cnblogs.com/jinjiyese153/p/8600855.html

      3.3 启动redis,并指定配置文件

        ./redis-server ../redis.conf

    4. 检查

      本机安装RedisDesktopManager进行redis远程连接。

    连接成功。

  • 相关阅读:
    spring日记(三)
    spring日记(二)
    spring框架日记(一)
    springMVC日记(四)
    springMVC日记(三),文件上传,拦截器,数据校验
    springMVC日记(二)
    springMVC日记(一)
    Mybatis总结
    优化Dalvik虚拟机的内存分配
    简单对App进行单元测试
  • 原文地址:https://www.cnblogs.com/jinjiyese153/p/8600703.html
Copyright © 2011-2022 走看看