CodisLabs / jodis

A java client for codis based on Jedis and Curator
MIT License
218 stars 97 forks source link

求教 ConnectionLossException: KeeperErrorCode #15

Closed baoyongan closed 7 years ago

baoyongan commented 8 years ago

我用spring-DM 集成jodis之后,本地代码测试正常,服务器报错。开始以为环境问题,我用测试例子打了个执行jar包,在服务器执行没问题。环境上应该没有问题的。。可以帮看一下我的错误,给我一个查找错误的方向吗? 报错如下 Caused by: org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /zk/codis/db_test_codis_cluster/proxy/foo at org.apache.zookeeper.KeeperException.create(KeeperException.java:99) [null:na] at org.apache.zookeeper.KeeperException.create(KeeperException.java:51) [null:na] at org.apache.zookeeper.ZooKeeper.exists(ZooKeeper.java:1045) [null:na] at org.apache.curator.framework.imps.ExistsBuilderImpl$3.call(ExistsBuilderImpl.java:226) [null:na] at org.apache.curator.framework.imps.ExistsBuilderImpl$3.call(ExistsBuilderImpl.java:215) [null:na] at org.apache.curator.RetryLoop.callWithRetry(RetryLoop.java:107) [null:na] at org.apache.curator.framework.imps.ExistsBuilderImpl.pathInForegroundStandard(ExistsBuilderImpl.java:212) [null:na] at org.apache.curator.framework.imps.ExistsBuilderImpl.pathInForeground(ExistsBuilderImpl.java:205) [null:na] at org.apache.curator.framework.imps.ExistsBuilderImpl.forPath(ExistsBuilderImpl.java:168) [null:na] at org.apache.curator.framework.imps.ExistsBuilderImpl.forPath(ExistsBuilderImpl.java:39) [null:na] at org.apache.curator.framework.imps.CuratorFrameworkImpl.createContainers(CuratorFrameworkImpl.java:193) [null:na] at org.apache.curator.framework.recipes.cache.PathChildrenCache.ensurePath(PathChildrenCache.java:616) [null:na] at org.apache.curator.framework.recipes.cache.PathChildrenCache.rebuild(PathChildrenCache.java:322) [null:na] at org.apache.curator.framework.recipes.cache.PathChildrenCache.start(PathChildrenCache.java:299) [null:na] at com.wandoulabs.jodis.RoundRobinJedisPool.(RoundRobinJedisPool.java:242) [null:na] ... 56 common frames omitted

Apache9 commented 8 years ago

这个路径配的对么? '/zk/codis/db_test_codis_cluster/proxy/foo' 为什么最后有个'foo'?

baoyongan commented 8 years ago

我用zkCli.sh 查看了三台zookeeper 的路劲,我在代码上这样的curatorClient("66.0.34.24:2181,66.0.34.23:2181,66.0.34.217:2181",30000).zkProxyDir("/zk/codis/db_test_codis_cluster/proxy") 的所以我查看了ls /zk/codis/db_test_codis_cluster/proxy 下面是[proxy_1,proxy_2] 根本没有foo.所以我也很奇怪怎么会有个foo

baoyongan commented 8 years ago

import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory;

import redis.clients.jedis.JedisPoolConfig;

import com.wandoulabs.jodis.JedisResourcePool; import com.wandoulabs.jodis.RoundRobinJedisPool;

/**

}

Apache9 commented 8 years ago
log.debug("ZookServer-->" +"zkServerUri: "+zkServerUri+"\r\nzkProxyDir: "+zkProxyDir);
log.debug("RedisPoolConfig-->" +"blockWhenExhausted: "+blockWhenExhausted+"\r\nmaxIdle: "+maxIdle+"\r\nminIdle: "+minIdle+"\r\nmaxTotal: "+maxTotal+"\r\nmaxWaitMillis: "+maxWaitMillis+"\r\ntestOnBorrow: "+testOnBorrow);

这两行日志输出的结果对么?

baoyongan commented 8 years ago

对的。。。跟我写的测试例子的参数一样,测试例子没有加设置poolConfig。 package com.baozi.test;

import redis.clients.jedis.Jedis;

import com.wandoulabs.jodis.JedisResourcePool; import com.wandoulabs.jodis.RoundRobinJedisPool;

public class TestJodis { public static void main(String[] args) { JedisResourcePool jedisPool = RoundRobinJedisPool.create().curatorClient("66.0.34.24:2181,66.0.34.23:2181,66.0.34.217:2181",10000).zkProxyDir("/zk/codis/db_test_codis_cluster/proxy").build(); Jedis jedis =jedisPool.getResource(); jedis.set("foo", "bar"); String value = jedis.get("foo"); jedis.del("foo"); jedis.close();

    Jedis jedis1 =jedisPool.getResource();
    jedis1.set("foo1", "barssss");
    String value1 = jedis1.get("foo1");
    System.out.println(value1);
    jedis1.del("foo1");
    jedis1.close();

    Jedis jedis2 =jedisPool.getResource();
    jedis2.set("foo1", "barssss");
    String value2 = jedis2.get("foo1");
    System.out.println(value2);
    jedis2.del("foo1");
    jedis2.close();

}

}

Apache9 commented 8 years ago

你把日志贴一下?

baoyongan commented 8 years ago

2016-03-15 16:19:50.102 [taskExecutor-7] DEBUG org.springframework.beans.CachedIntrospectionResults - Not strongly caching class [com.csii.rdb.mgmt.action.RedisCacheControl] because it is not cache-safe 2016-03-15 16:19:50.102 [taskExecutor-7] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Invoking init method 'createPool' on bean with name 'RedisCacheControl' 2016-03-15 16:19:50.104 [taskExecutor-7] DEBUG com.csii.rdb.mgmt.action.RedisPoolSingleInstance - ZookServer-->zkServerUri: 66.0.34.24:2181,66.0.34.23:2181,66.0.34.217:2181 zkProxyDir: /zk/codis/db_test_codis_cluster/proxy 2016-03-15 16:19:50.104 [taskExecutor-7] DEBUG com.csii.rdb.mgmt.action.RedisPoolSingleInstance - RedisPoolConfig-->blockWhenExhausted: true maxIdle: 500 minIdle: 0 maxTotal: 100 maxWaitMillis: 1000 testOnBorrow: true 2016-03-15 16:20:51.926 [taskExecutor-7] ERROR com.csii.rdb.mgmt.action.RedisPoolSingleInstance - RedisPoolSingleInstance: init pool error: redis.clients.jedis.exceptions.JedisException: org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /zk/codis/db_test_codis_cluster/proxy/foo at com.wandoulabs.jodis.RoundRobinJedisPool.(RoundRobinJedisPool.java:244) [null:na] at com.wandoulabs.jodis.RoundRobinJedisPool.(RoundRobinJedisPool.java:207) [null:na] at com.wandoulabs.jodis.RoundRobinJedisPool$Builder.build(RoundRobinJedisPool.java:482) [null:na] at com.csii.rdb.mgmt.action.RedisPoolSingleInstance.getJedisPo(RedisPoolSingleInstance.java:54) [null:na] at com.csii.rdb.mgmt.action.RedisPoolSingleInstance.getRedisPool(RedisPoolSingleInstance.java:37) [null:na] at com.csii.rdb.mgmt.action.RedisCacheControl.createPool(RedisCacheControl.java:33) [null:na] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [na:1.6.0] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60) [na:1.6.0] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37) [na:1.6.0] at java.lang.reflect.Method.invoke(Method.java:611) [na:1.6.0] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1414) [null:2.5.6.SEC01] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1375) [null:2.5.6.SEC01] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335) [null:2.5.6.SEC01] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473) [null:2.5.6.SEC01] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409) [null:2.5.6.SEC01] at java.security.AccessController.doPrivileged(AccessController.java:298) [na:na] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380) [null:2.5.6.SEC01] at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264) [null:2.5.6.SEC01] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) [null:2.5.6.SEC01] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261) [null:2.5.6.SEC01] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185) [null:2.5.6.SEC01] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164) [null:2.5.6.SEC01] at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:269) [null:2.5.6.SEC01] at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:104) [null:2.5.6.SEC01] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1245) [null:2.5.6.SEC01] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010) [null:2.5.6.SEC01] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472) [null:2.5.6.SEC01] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409) [null:2.5.6.SEC01] at java.security.AccessController.doPrivileged(AccessController.java:298) [na:na] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380) [null:2.5.6.SEC01] at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264) [null:2.5.6.SEC01] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) [null:2.5.6.SEC01] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261) [null:2.5.6.SEC01] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185) [null:2.5.6.SEC01] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164) [null:2.5.6.SEC01] at org.springframework.osgi.service.exporter.support.OsgiServiceFactoryBean.afterPropertiesSet(OsgiServiceFactoryBean.java:167) [null:1.2.1] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369) [null:2.5.6.SEC01] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335) [null:2.5.6.SEC01] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473) [null:2.5.6.SEC01] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409) [null:2.5.6.SEC01] at java.security.AccessController.doPrivileged(AccessController.java:298) [na:na] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380) [null:2.5.6.SEC01] at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264) [null:2.5.6.SEC01] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) [null:2.5.6.SEC01] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261) [null:2.5.6.SEC01] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185) [null:2.5.6.SEC01] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164) [null:2.5.6.SEC01] at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:423) [null:2.5.6.SEC01] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728) [null:2.5.6.SEC01] at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.access$1600(AbstractDelegatedExecutionApplicationContext.java:69) [null:1.2.1] at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:355) [null:1.2.1] at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85) [null:1.2.1] at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320) [null:1.2.1] at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:132) [null:1.2.1] at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:906) [na:1.6.0] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:929) [na:1.6.0] at java.lang.Thread.run(Thread.java:796) [na:1.6.0] Caused by: org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /zk/codis/db_test_codis_cluster/proxy/foo at org.apache.zookeeper.KeeperException.create(KeeperException.java:99) [null:na] at org.apache.zookeeper.KeeperException.create(KeeperException.java:51) [null:na] at org.apache.zookeeper.ZooKeeper.exists(ZooKeeper.java:1045) [null:na] at org.apache.curator.framework.imps.ExistsBuilderImpl$3.call(ExistsBuilderImpl.java:226) [null:na] at org.apache.curator.framework.imps.ExistsBuilderImpl$3.call(ExistsBuilderImpl.java:215) [null:na] at org.apache.curator.RetryLoop.callWithRetry(RetryLoop.java:107) [null:na] at org.apache.curator.framework.imps.ExistsBuilderImpl.pathInForegroundStandard(ExistsBuilderImpl.java:212) [null:na] at org.apache.curator.framework.imps.ExistsBuilderImpl.pathInForeground(ExistsBuilderImpl.java:205) [null:na] at org.apache.curator.framework.imps.ExistsBuilderImpl.forPath(ExistsBuilderImpl.java:168) [null:na] at org.apache.curator.framework.imps.ExistsBuilderImpl.forPath(ExistsBuilderImpl.java:39) [null:na] at org.apache.curator.framework.imps.CuratorFrameworkImpl.createContainers(CuratorFrameworkImpl.java:193) [null:na] at org.apache.curator.framework.recipes.cache.PathChildrenCache.ensurePath(PathChildrenCache.java:616) [null:na] at org.apache.curator.framework.recipes.cache.PathChildrenCache.rebuild(PathChildrenCache.java:322) [null:na] at org.apache.curator.framework.recipes.cache.PathChildrenCache.start(PathChildrenCache.java:299) [null:na] at com.wandoulabs.jodis.RoundRobinJedisPool.(RoundRobinJedisPool.java:242) [null:na] ... 56 common frames omitted 2016-03-15 16:20:51.928 [taskExecutor-7] DEBUG com.csii.rdb.mgmt.action.RedisCacheControl - RedisCacheControl.afterPropertiesSet(): redis pool is create failed.

baoyongan commented 8 years ago

你看着日志,有帮助吗