阿里云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. windows下git hub的GUI软件配置与使用

    转载自:http://www.cnblogs.com/haore147/p/3618930.html   1. 安装两个软件 1 2 1. git的命令行程序--git for windows:htt ...

  2. 测试理论- the conten of test plan

    1 testing objects 测试对象 2 testing scope 测试范围 3 testing the frame (?) 4 the environment 5 reason for t ...

  3. POJ 1015 Jury Compromise (动态规划)

    dp[i][j]代表选了i个人,D(J)-P(J)的值为j的状态下,D(J)+P(J)的最大和. #include <cstdio> #include <cstring> #i ...

  4. 第十四次ScrumMeeting会议

    第十三次Scrum Meeting 时间:2017/12/2 地点:咖啡馆 人员:策划组美工组 目前工作情况 名字 完成的工作 计划工作 蔡帜 科技树策划设计,科技图鉴蓝图设计 员工方面细节设定 游心 ...

  5. Spring定时器调用Hibernate方法无法获得SessionFactory的解决办法

    由于在Spring定时器中无法通过注解的方式获取bean,因此需要通过原生的方式获取.获取session的方式如下: WebApplicationContext wac = ContextLoader ...

  6. Android隐藏键盘

    今天接到的任务是在验证码输入框中加入键盘监听事件,需要点击Enter实现登录,这个比较好实现,但是在登录时,键盘并没有隐藏掉,看上去很别扭,因此,百度了一堆方法,但是都无济于事,最后找到了一个,如下, ...

  7. PokeCats开发者日志(八)

      现在是PokeCats游戏开发的第十四天的中午,很不幸著作权申请又被打回来了.   据说是排版后代码行数还差500行,文档不足十版.我擦,原来他们会自己排版的啊.   只好从项目自带的xml里扣代 ...

  8. Docker实战系列一:初识Docker for Windows

    windows下安装Docker官网教程Install Docker for Windows Docker配置官网教程Get started with Docker for Windows

  9. SSH整合需要的jar包

    [struts相关jar] commons-fileupload-1.2.2.jar commons-io-2.0.1.jar commons-lang3-3.1.jar freemarker-2.3 ...

  10. BZOJ day1

    十题击破  1051108811921432195119682242245624632761