连接另一台设备的本地 Redis 服务

95 阅读1分钟

前提条件

  1. 另一台设备上的 Redis 服务已启动并运行
  2. 两台设备在同一网络中可以互相访问
  3. Redis 配置允许远程连接(默认只允许本地连接)

步骤 1: 配置远程 Redis 服务

在运行 Redis 的设备上:

  1. 编辑 Redis 配置文件 (通常位于 /etc/redis/redis.conf 或 redis.conf)

  2. 找到并修改以下配置:

    conf

    bind 0.0.0.0  # 允许所有网络接口连接
    protected-mode no  # 关闭保护模式(仅限测试环境)
    
  3. 重启 Redis 服务