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

    1. 目的

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

    2. 环境

      虚拟机:CentOS Linux release 7.4.1708 (Core)

      redis:3.2.12

      防火墙:firewall (已经关闭)

    3. 配置 

      我修改的是默认的配置文件(yum安装在/etc/redis.conf) 开机启动也默认加载这个

      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远程连接。 (由于这个收费了, redis的可视化连接工具我用的fastoredis 见我上一个文章)

    转 :  http://www.cnblogs.com/jinjiyese153/p/8600703.html

  • 相关阅读:
    python判断字典中key是否存在
    获取redis中所有的key,清空整个 Redis 服务器的数据
    python redis模块详解
    Windows中redis的下载及安装、设置
    .htaccess
    python介绍
    vi和vim
    其他
    Linux系统相关命令
    Linux用户权限常见命令
  • 原文地址:https://www.cnblogs.com/fps2tao/p/9969539.html
Copyright © 2011-2022 走看看