阿里云ECS部署spring-boot访问redis出现redis.clients.jedis.HostAndPort - cant resolve localhost address
摘要: 阿里云ECS部署spring-boot+redis的坑
问题LOG
2017-08-17 09:06:52.526 [main] ERROR redis.clients.jedis.HostAndPort - cant resolve localhost address
door_1 | java.net.UnknownHostException: iZuf6buf42e89crw6zf: iZuf6buf42e89crw6zf: Name or service not known
door_1 | at java.net.InetAddress.getLocalHost(InetAddress.java:1505)
door_1 | at redis.clients.jedis.HostAndPort.getLocalHostQuietly(HostAndPort.java:105)
door_1 | at redis.clients.jedis.HostAndPort.<clinit>(HostAndPort.java:12)
door_1 | at redis.clients.jedis.JedisFactory.<init>(JedisFactory.java:37)
door_1 | at redis.clients.jedis.JedisPool.<init>(JedisPool.java:185)
door_1 | at redis.clients.jedis.JedisPool.<init>(JedisPool.java:169)
door_1 | at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.createRedisPool(JedisConnectionFactory.java:275)
door_1 | at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.createPool(JedisConnectionFactory.java:250)
door_1 | at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.afterPropertiesSet(JedisConnectionFactory.java:237)
door_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687)
door_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624)
door_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
door_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
door_1 | at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
door_1 | at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
door_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
door_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
door_1 | at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.obtainBeanInstanceFromFactory(ConfigurationClassEnhancer.java:389)
door_1 | at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:361)
根本原因
这个问题的原因是spring-redis在初始化时会实例化LocalHost,但是ECS的host name并没有在/etc/hosts中设置。
解决方案
在/etc/hosts中设置ECS的host name。类似
127.0.0.1 iZuf6buf42e89crw6zf
 
以上的iZuf6buf42e89crw6zf,用命令hostname 取到你阿里云自己服务器的名字

redis.clients.jedis.HostAndPort - cant resolve localhost address的更多相关文章

  1. Linux下使用RedisPool时报错:redis.clients.jedis.HostAndPort getLocalHostQuietly 严重: cant resolve localhost address

    项目在本地无错误,当部署到linux服务器以后,启动tomcat报错: 意思是找不到服务的名称. 后在网上检索相关答案,是因为在/etc/hosts文件中没有加入当前服务器实例的名称,将当前服务器实例 ...

  2. redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketException: 断开的管道 (Write failed)

    昨晚,包发到测试环境中,出现redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketException: 断开的 ...

  3. redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool

    超时 Exception in thread "main" redis.clients.jedis.exceptions.JedisConnectionException: jav ...

  4. redis.clients.jedis.exceptions.JedisDataException: ERR Client sent AUTH, but no password is set

    使用哨兵模式连接redis连接池时,遇到错误: Caused by: redis.clients.jedis.exceptions.JedisDataException: ERR Client sen ...

  5. ERR Unsupported CONFIG parameter: notify-keyspace-events; nested exception is redis.clients.jedis.exceptions.JedisDataException

    异常信息 时间:2017-04-05 15:53:57,361 - 级别:[ WARN] - 消息: [other] The web application [ROOT] appears to hav ...

  6. redis报错:java.net.SocketException: Broken pipe (Write failed); nested exception is redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketException: Broken pipe (Write failed)

    最近写了一个服务通过springboot构建,里面使用了redis作为缓存,发布到服务器运行成功,但是有时候会报redis的错误:org.springframework.data.redis.Redi ...

  7. redis.clients.jedis.exceptions.JedisDataException: ERR invalid DB index

    添加redis配置文件, 启动后,调用报错  redis.clients.jedis.exceptions.JedisDataException: ERR invalid DB index ERR i ...

  8. jedisCluster 报错: redis.clients.jedis.exceptions.JedisClusterException: No way to dispatch this command to Redis Cluster because keys have different slots.

    根本原因:jedisCluster不支持mget/mset等跨槽位的操作. 版本:2.9.0 解决办法,推荐更改redis的驱动修改为: lettuce lettuce 项目地址:https://gi ...

  9. redis.clients.jedis.exceptions.JedisDataException :READONLY You can't write

    分布式直连同步调用测试时出现的错误:主从复制架构下,默认Slave是只读的,如果写入则会报错: redis.clients.jedis.exceptions.JedisDataException: R ...

随机推荐

  1. PHP Fatal error: Undefined class constant 'MYSQL_ATTR_INIT_COMMAND'

    最近用ThinkPHP,给公司布置线上的网站的时候,遇到的一个问题,记录一下. 打开IE浏览器的设置,Internet选项里的高级,将”显示友好的HTTP错误消息“前都勾去掉! 再次刷新,看到的错误是 ...

  2. 常用的gif加载动态图片

    精心搜集的网页素材,包括:Loading GIF动画,"正在加载中"小图片,"请等待"小图标等,欢迎您的下载. 提示:点击鼠标右键,选择”图片另存为“即可轻松保 ...

  3. Augmenting Path Algorithm : 一般图最大匹配

    算法原理详见 http://www.csie.ntnu.edu.tw/~u91029/Matching.html orz 带花树很神奇,挖坑最大权匹配 #include <iostream> ...

  4. Xinetd服务的安装与配置

    Xinetd服务的安装与配置 http://blog.chinaunix.net/uid-21411227-id-1826885.html 1.什么是xinetd xinetd即extended in ...

  5. 【题解】SCOI2010幸运数字

    最近在学习容斥相关,于是就看到了这个题.一开始以为是补集转化,但是观察一下马上发现不可行,好像直接做会比较容易一些.一个数满足要求的充要条件即为是一个幸运数字的倍数,那么容斥可以轻松搞定,只要枚举是一 ...

  6. 关于GDI+

    原文链接地址:http://www.2cto.com/kf/201107/97283.html 一 介绍 其实本人对GDI+不能算是专家,只是在几个小项目中应用了一些而已, 算是入门了. 刚好最近有点 ...

  7. Expect使用小记

    By francis_hao    May 31,2017   本文翻译了部分Expect的man手册,只选取了个人常用的功能,因此并不完善.   Expect是一个可以和交互式程序对话的程序 概述 ...

  8. MySQL使用笔记(四)数据的操作

    By francis_hao    Dec 14,2016 数据的操作包括插入数据记录.更新数据记录和删除数据记录. 插入数据记录 插入单条数据记录 field表示的字段名和value表示数据要一一对 ...

  9. 打造适合日常使用的ubuntu,以ubuntu 16.04.1 LTS为例(不涉及版本)

    因为调试些程序需要用到ubuntu,又不喜欢虚拟机,因此装了双系统,在这过程中因为各种原因ubuntu来回安装过好多次,每次安装到用得爽都要捣鼓很久,也算稍微有点经验心得,将ubuntu调教的过程写在 ...

  10. Spring Boot(一)

    1.注解  @EnableAutoConfiguration 官方文档:The @EnableAutoConfiguration annotation is often placed on your ...