阿里云主机ECS部署项目报:ERROR: cant resolve localhost address

一、我在阿里云买了个云主机ECS,在上面部署了一个Redis,并开启了远程连接,我在本地,通过IP+端口+用户名+密码,远程连接到Redis是一点问题都没有的。

二、现在我将项目部署到阿里云主机上去了。
我在启动项目的时候,一直给我报一个错误:

[2018-05-04 15:50:04] ERROR: cant resolve localhost address
java.net.UnknownHostException: iZbp17cj14ulhfrlj02rkaZ: iZbp17cj14ulhfrlj02rkaZ: Name or service not known
    at java.net.InetAddress.getLocalHost(InetAddress.java:1505) ~[?:1.8.0_171]
    at redis.clients.jedis.HostAndPort.getLocalHostQuietly(HostAndPort.java:105) [jedis-2.9.0.jar!/:?]
    at redis.clients.jedis.HostAndPort.(HostAndPort.java:12) [jedis-2.9.0.jar!/:?]
    at redis.clients.jedis.JedisFactory.(JedisFactory.java:37) [jedis-2.9.0.jar!/:?]
    at redis.clients.jedis.JedisPool.(JedisPool.java:185) [jedis-2.9.0.jar!/:?]
    at redis.clients.jedis.JedisPool.(JedisPool.java:169) [jedis-2.9.0.jar!/:?]
    at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.createRedisPool(JedisConnectionFactory.java:275) [spring-data-redis-1.8.10.RELEASE.jar!/:?]
说的是主机名无法解析。

三、首先查看Linux的主机名

root@iZbp17cj14ulhfrlj02rkaZ:~# hostname
iZbp17cj14ulhfrlj02rkaZ
root@iZbp17cj14ulhfrlj02rkaZ:~# 

四、编辑/etc/hosts

root@iZbp17cj14ulhfrlj02rkaZ:~# vi /etc/hosts

五、将主机名添加到localhost后面
阿里云主机ECS部署项目报:ERROR: cant resolve localhost address_第1张图片

六、再次启动,成功。

你可能感兴趣的:(Redis数据库,Linux运维部署)