Elastic-job报错:com.dangdang.ddframe.job.reg.exception.RegException...KeeperErrorCode=OperationTimeout

zookeeper作为注册中心

1.配置如下:




	
	
	
	
	
	

2.启动报错如下:

2017-08-31 17:22:12,614 [main] [org.springframework.beans.factory.support.DefaultListableBeanFactory]-[DEBUG] Eagerly caching bean 'regCenter' to allow for resolving potential circular references
2017-08-31 17:22:12,614 [main] [org.springframework.beans.factory.support.DefaultListableBeanFactory]-[DEBUG] Invoking init method  'init' on bean with name 'regCenter'
2017-08-31 17:22:31,230 [main] [org.springframework.beans.factory.support.DefaultListableBeanFactory]-[DEBUG] Retrieved dependent beans for bean '(inner bean)#6fd02e5': [regCenter]
2017-08-31 17:22:31,230 [main] [org.springframework.context.support.ClassPathXmlApplicationContext]-[WARN] Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'regCenter': Invocation of init method failed; nested exception is com.dangdang.ddframe.job.reg.exception.RegException: org.apache.zookeeper.KeeperException$OperationTimeoutException: KeeperErrorCode = OperationTimeout
2017-08-31 17:22:31,231 [main] [org.springframework.beans.factory.support.DefaultListableBeanFactory]-[DEBUG] Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@35fb3008: defining beans [regCenter,com.dangdang.ddframe.job.lite.spring.api.SpringJobScheduler#0]; root of factory hierarchy
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'regCenter': Invocation of init method failed; nested exception is com.dangdang.ddframe.job.reg.exception.RegException: org.apache.zookeeper.KeeperException$OperationTimeoutException: KeeperErrorCode = OperationTimeout
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1628)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543)
	at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:139)
	at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:93)
	at cn.sanishan.ss.job.demo.StartBySpring.main(StartBySpring.java:8)
Caused by: com.dangdang.ddframe.job.reg.exception.RegException: org.apache.zookeeper.KeeperException$OperationTimeoutException: KeeperErrorCode = OperationTimeout
	at com.dangdang.ddframe.job.reg.exception.RegExceptionHandler.handleException(RegExceptionHandler.java:52)
	at com.dangdang.ddframe.job.reg.zookeeper.ZookeeperRegistryCenter.init(ZookeeperRegistryCenter.java:107)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1758)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1695)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624)
	... 12 more
Caused by: org.apache.zookeeper.KeeperException$OperationTimeoutException: KeeperErrorCode = OperationTimeout
	at com.dangdang.ddframe.job.reg.zookeeper.ZookeeperRegistryCenter.init(ZookeeperRegistryCenter.java:102)
	... 19 more
原因分析:

1.zookeeper服务器防火墙问题,解决方案:

(1)关闭防火墙
命令:

service iptables stop
(2)如果不想关闭防火墙,在防火墙中添加2181端口

参考:http://blog.csdn.net/u013274055/article/details/77542143

2.修改连接重试次数,一般建议配置3次,如果连接失败,增加重试次数就可以了

你可能感兴趣的:(Job)