welcome to xlongwei.com

欢迎大家一起学习、交流、分享


QQ群:162333776 邮箱:admin@xlongwei.com

dubbo配置redis注册中心


分类 Java   关键字 分享   标签 linux   dubbo   发布 hongwei  1429609123683
注意 转载须保留原文链接,译文链接,作者译者等信息。  
redis配置为注册中心和内存缓存,可替换掉zookeeper+ehcache。

参考dubbo分布式配置实例

修改provider.xml和consumers.xml
<dubbo:registry address="redis://127.0.0.1:6379"/>
修改web.xml
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:consumers.xml,classpath:cache.xml,classpath:shiro.xml,classpath:front.xml</param-value>
</context-param>

运行mvn assembly:directory -f ite-domain-impl/pom.xml
sh /soft/restart-providers.sh
sh /soft/evergreen/trunk/ite-domain-impl/target/ite-domain-impl-1.0.0-assembly/ite-domain-impl-1.0.0/bin/stop.sh
sh /soft/evergreen/trunk/ite-domain-impl/target/ite-domain-impl-1.0.0-assembly/ite-domain-impl-1.0.0/bin/start.sh

报错信息处理:
java.lang.IllegalArgumentException: Unsupported redis cluster: failsafe. The redis cluster only supported failover or replicate.
at com.alibaba.dubbo.registry.redis.RedisRegistry.<init>(RedisRegistry.java:109) ~[dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.registry.redis.RedisRegistryFactory.getRegistry(RedisRegistryFactory.java:30) ~[dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.registry.RegistryFactory$Adpative.getRegistry(RegistryFactory$Adpative.java) ~[na:2.5.3]
去掉dubbo.properties里面dubbo.monitor.protocol=registry
dubbo.container=log4j,spring
dubbo.application.name=ite-provider
dubbo.registry.address=redis://127.0.0.1:6379
dubbo.protocol.name=dubbo
dubbo.protocol.port=20880
dubbo.spring.config=provider.xml
dubbo.log4j.file=/var/log/ite/stdout.log
dubbo.log4j.level=WARN

如果配置了监控中心,可以配置直连方式,然后监控中心就可以看到统计信息和图表展示了
<dubbo:monitor protocol="dubbo" address="10.29.86.191:7070" />