1、修改redis服务器的配置文件
本机安装的redis-4.0.14默认的配置文件 redis.conf 设置
绑定本机地址:bind 127.0.0.1
开启保护模式:protected-mode yes
此时连接,服务器是拒绝的
[root@fjgh redis]# ./redis-cli -h 192.168.100.109 -p 6379 Could not connect to Redis at 192.168.100.109:6379: Connection refused Could not connect to Redis at 192.168.100.109:6379: Connection refused not connected> eixt
配置文件比较大,我们通过ctrl + F 查找关键字修改为:
bind 0.0.0.0
protected-mode no
2、重启redis服务:先通过kill -9 杀死现有redis进程在启动redis服务
[root@fjgh redis]# ps -ef|grep redis root 10768 1 0 Jun19 ? 00:01:37 ./redis-server 127.0.0.1:6379 root 11339 11251 0 10:05 pts/1 00:00:00 grep --color=auto redis [root@fjgh redis]# kill -9 10768 [root@fjgh redis]# ps -ef|grep redis root 11343 11251 0 10:05 pts/1 00:00:00 grep --color=auto redis [root@fjgh redis]# ./redis-server redis.conf 11344:C 20 Jun 10:05:46.798 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo 11344:C 20 Jun 10:05:46.798 # Redis version=4.0.14, bits=64, commit=00000000, modified=0, pid=11344, just started 11344:C 20 Jun 10:05:46.798 # Configuration loaded
3、通过IP地址连接
[root@fjgh redis]# ./redis-cli -h 192.168.100.109 -p 6379 192.168.100.109:6379> get setUpTime "201906191227" 192.168.100.109:6379>