redis集群链接-java
2017-05-16 16:26
363 查看
java链接redis集群报错:
redis.clients.jedis.exceptions.JedisDataException: MOVED
13102 127.0.0.1
MOVED indicates that you're using Redis Cluster.
ShardedJedis is not for Redis Cluster, so you should use JedisCluster instead. Please note that JedisCluster doesn't have pipeline mode, so you may want to send your operation one by one.
大概意思就是ShardedJedis 不能用于Redis集群,要用JedisCluster 代替ShardedJedis 才可以,而且JedisCluster 还没有pipeline 模式,所以一次只能执行一个操作
JedisCluster jedisCluster = RedisUtils.getJedisCluster(
new HostAndPort("192.168.0.140", 7000),
new HostAndPort("192.168.0.140", 7001),
new HostAndPort("192.168.0.140", 7002),
new HostAndPort("192.168.0.140", 7003),
new HostAndPort("192.168.0.140", 7003),
new HostAndPort("192.168.0.140", 7004)
);
jedisCluster.hset("hashs", "hello2", "world2");
print("判断是否存在key001:"+jedisCluster.hexists("hashs", "hello2"));
print("查找key001的值:"+jedisCluster.hget("hashs", "hello2"));
redis.clients.jedis.exceptions.JedisDataException: MOVED
13102 127.0.0.1
MOVED indicates that you're using Redis Cluster.
ShardedJedis is not for Redis Cluster, so you should use JedisCluster instead. Please note that JedisCluster doesn't have pipeline mode, so you may want to send your operation one by one.
大概意思就是ShardedJedis 不能用于Redis集群,要用JedisCluster 代替ShardedJedis 才可以,而且JedisCluster 还没有pipeline 模式,所以一次只能执行一个操作
JedisCluster jedisCluster = RedisUtils.getJedisCluster(
new HostAndPort("192.168.0.140", 7000),
new HostAndPort("192.168.0.140", 7001),
new HostAndPort("192.168.0.140", 7002),
new HostAndPort("192.168.0.140", 7003),
new HostAndPort("192.168.0.140", 7003),
new HostAndPort("192.168.0.140", 7004)
);
jedisCluster.hset("hashs", "hello2", "world2");
print("判断是否存在key001:"+jedisCluster.hexists("hashs", "hello2"));
print("查找key001的值:"+jedisCluster.hget("hashs", "hello2"));
相关文章推荐
- java链接access
- java技术文章列表(存放一些我在网上看到的文章的链接)
- 整理几个java游戏开发的链接
- 优秀的java开发网站链接
- JAVA链接SQL2005数据库遇到的问题
- java链接
- java乱码问题及解决方法的相关链接!
- 几个开关于JAVA开源框架的选择链接
- 不使用 java.awt.Desktop API,打开默认浏览器访问指定链接的方法
- Think In JavaII 中文版下载(链接已修正)
- [导入][链接] Qt for Java?
- 链接:Java学习的30个目标
- 使用java快速判断网页链接是否有效
- 关于JavaCC的一些链接
- Java 站点链接
- Java开发链接地址
- 优秀的java开发网站链接
- java链接oracle数据库
- (源码实例)通过层DIV实现,当鼠标放在链接上面,显示图片及文字 - 流星絮语 JAVA学习笔记 - CSDNBlog
- Java正则表达式获取网址和链接文字