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

Job 专栏收录该内容
2 篇文章 0 订阅

zookeeper作为注册中心

1.配置如下:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:reg="http://www.dangdang.com/schema/ddframe/reg"
	xmlns:job="http://www.dangdang.com/schema/ddframe/job"
	xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.dangdang.com/schema/ddframe/reg
        http://www.dangdang.com/schema/ddframe/reg/reg.xsd
        http://www.dangdang.com/schema/ddframe/job
        http://www.dangdang.com/schema/ddframe/job/job.xsd
        ">

	<!-- 配置注册中心 ,任务的信息都会在zk中存储 -->
	<reg:zookeeper id="regCenter" server-lists="192.168.206.144:2181"
		namespace="test-job" base-sleep-time-milliseconds="1000"
		max-sleep-time-milliseconds="3000" max-retries="4" />
	<!-- 配置简单作业 -->
	<!-- 分片为1,即不需要分片;支持覆盖,即会用本次的配置覆盖缓存在zk中的配置 -->
	<job:simple id="testTask" class="cn.sanishan.ss.job.demo.DemoSimpleJob"
		registry-center-ref="regCenter" cron="0 10 * * * ?"
		sharding-total-count="1" overwrite="true">
	</job:simple>
</beans>

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.<init>(ClassPathXmlApplicationContext.java:139)
	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(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次,如果连接失败,增加重试次数就可以了

  • 0
    点赞
  • 0
    评论
  • 4
    收藏
  • 一键三连
    一键三连
  • 扫一扫,分享海报

©️2021 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值