1. 找的你的redis配置文件编辑配置文件
[root@ecm-ice01 bin]# vim /usr/local/redis-7.0.15/redis.conf
2. 修改如下配置:
1. bind 0.0.0.0 // 全都是0代表 全部可利用的 ip 地址
2 .protected-mode no // 设置保护模式
3. port 6379 // 设置端口
4. daemonize yes // 后台运行模式
5. requirepass 你的密码 // 填入你密码
保存配置
3. 重启redis 服务
1. [root@localhost src]# ./redis-cli -p 6379 // 连接 redis
127.0.0.1:6379> shutdown // 关闭 redis
2. [root@localhost redis-6.2.6]# /usr/local/redis-6.2.6/src/redis-server/usr/local/redis-6.2.6/redis.conf // 启动redis
4. 防火墙放行端口
1. firewall-cmd --zone=public --add-port=6379/tcp --permanent //防火墙放行端口
2. 如果是云主机(如阿里云),在安全组中放行 6379 端口
5. 测试远程连接
1. [root@localhost src]# ./redis-cli -h xxx.xxx.xxx.xxx -p 6379 //h 后面是输入你的ip地址
2. 127.0.0.1:6379> auth '你的密码' // 打该命令并填入你的密码
3. 127.0.0.1:6379> ping
PONG //测试成功
127.0.0.1:6379> exit