项目采用的是Codis集群部署,客户端jedis执行keys方法报如下错误:
Exception in thread "main" redis.clients.jedis.exceptions.JedisConnectionException: Unexpected end of stream.
at redis.clients.util.RedisInputStream.ensureFill(RedisInputStream.java:198)
at redis.clients.util.RedisInputStream.readByte(RedisInputStream.java:40)
at redis.clients.jedis.Protocol.process(Protocol.java:141)
at redis.clients.jedis.Protocol.read(Protocol.java:205)
at redis.clients.jedis.Connection.readProtocolWithCheckingBroken(Connection.java:297)
at redis.clients.jedis.Connection.getBinaryMultiBulkReply(Connection.java:233)
at redis.clients.jedis.Jedis.keys(Jedis.java:194)
报错信息是可以在Codis proxy代理服务器上看到日志信息:
1.首先登陆proxy代理服务器,找到日志目录
ps -ef | grep "codis"
root 15 1 0 May19 ? 00:00:00 sh /root/codisproxy.sh
root 26 15 0 May19 ? 05:10:33 /root/codis/bin/codis-proxy -c /root/codis/config.ini -L /data/log/proxy.log --cpu=8 --addr=172.16.11.38:19000 --http-addr=172.16.11.38:11000
root 148 134 0 09:40 pts/1 00:00:00 grep --color=auto codis
2.切换到日志目录,查看最新的日志
cd /data/log
ls -lt
tailf proxy.log
3.执行报错的程序,可以看到如下信息
2016/07/15 09:34:31 session.go:70: [INFO] session [0xc20a1e8900] closed: {"ops":3,"lastop":1468546471,"create":1468546471,"remote":"192.168.1.88:2549"}, error = command <KEYS> is not allowed
可以看到codis proxy代理不支持redis的keys方法。