阿里云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. python之pyquery库

    如果熟悉jquery,那么使用pyquery进行网页信息提取将会是非常方便的,因为语法都是一样的 1.字符串初始化 2.url和文件初始化 3.CSS选择器 4.子元素 5.父元素 6.兄弟节点 7. ...

  2. redis安装与启动

    安装简介: 在安装redis前需要了解redis官方发布时的版本规则,redis官方约定次版本号(即第一个小数点后的数字)为偶数的版本是稳定版(如2.8版,3.0版),奇数版本则为非稳定版本(如2.7 ...

  3. lintcode-135-数字组合

    135-数字组合 给出一组候选数字(C)和目标数字(T),找到C中所有的组合,使找出的数字和为T.C中的数字可以无限制重复被选取. 例如,给出候选数组[2,3,6,7]和目标数字7,所求的解为: [7 ...

  4. 【python爬虫】对喜马拉雅上一个专辑的音频进行爬取并保存到本地

    >>>内容基本框架: 1.爬虫目的 2.爬取过程 3.代码实现 4.爬取结果  >>>实验环境: python3.6版本,pycharm,电脑可上网. [一 爬虫目 ...

  5. To Chromium之VS调试追踪

    启动的code: for(;;){...WaitForWork()}base.dll!base::MessagePumpForUI::DoRunLoop                         ...

  6. oracle 引用类型声明

  7. 判断腾讯QQ是否在线

    http://webpresence.qq.com/getonline?Type=1&1617052138: 判断腾讯QQ是否在线接口. 下面是个简单的例子: <!doctype htm ...

  8. timeSetEvent()函数

    原文链接地址:http://www.cnblogs.com/kangwang1988/archive/2010/09/16/1827872.html 微软公司在其多媒体Windows中提供了精确定时器 ...

  9. HDU 1203 01背包

    I NEED A OFFER! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)T ...

  10. Educational Codeforces Round 55:B. Vova and Trophies

    B. Vova and Trophies 题目链接:https://codeforc.es/contest/1082/problem/B 题意: 给出一个“GS”串,有一次交换两个字母的机会,问最大的 ...