Java程序里面写了使用redis缓存,但是死活调用不了redis里面的数据,redis里面有缓存
首先,登录查看redis是否可以get数据,发现只有本地
[root@redis_test ~]# ss -lntup|grep redis #查看端口是否起来 tcp LISTEN 0 128 *:6379 *:* users:(("redis-server",2248,4)) [root@redis_test ~]# redis-cli #登录 redis 127.0.0.1:6379> set dd "haha" #set值看能否取到 OK redis 127.0.0.1:6379> get dd "haha"
[root@redis_test ~]# redis-cli redis 127.0.0.1:6379> CLIENT LIST #返回所有连接到服务器的客户端信息和统计数据 addr=127.0.0.1:33955 fd=5 name= age=20 idle=0 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=32768 obl=0 oll=0 omem=0 events=r cmd=client redis 127.0.0.1:6379> CLIENT LIST addr=127.0.0.1:33955 fd=5 name= age=24 idle=0 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=32768 obl=0 oll=0 omem=0 events=r cmd=client
2.查看selinux和防火墙是否关闭
root@redis_test ~]# getenforce Disabled [root@redis_test ~]# service iptables status Table: filter
3.关闭防火墙再看
[root@redis_test ~]# service iptables stop iptables: Setting chains to policy ACCEPT: filter [ OK ] iptables: Flushing firewall rules: [ OK ] iptables: Unloading modules: [ OK ] [root@redis_test ~]# redis-cli redis 127.0.0.1:6379> CLIENT LIST addr=127.0.0.1:33956 fd=5 name= age=2 idle=0 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=32768 obl=0 oll=0 omem=0 events=r cmd=client redis 127.0.0.1:6379> CLIENT LIST addr=127.0.0.1:33956 fd=5 name= age=3 idle=0 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=32768 obl=0 oll=0 omem=0 events=r cmd=client redis 127.0.0.1:6379> CLIENT LIST addr=127.0.0.1:33956 fd=5 name= age=15 idle=0 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=32768 obl=0 oll=0 omem=0 events=r cmd=client addr=10.0.0.106:60182 fd=6 name= age=5 idle=5 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r cmd=ping
4.总结
果然是防火墙没关的问题。