Name or service not known

org.triber.bui.Application- No active profile set, falling back to default profiles: default
2017/12/05-18:00:54 [localhost-startStop-1] ERROR redis.clients.jedis.HostAndPort- cant resolve localhost address
java.net.UnknownHostException: host-172-16-14-106: host-172-16-14-106: Name or service not known
at java.net.InetAddress.getLocalHost(InetAddress.java:1505) ~[na:1.8.0_144]
at redis.clients.jedis.HostAndPort.getLocalHostQuietly(HostAndPort.java:105) [classes!/:0.1]
at redis.clients.jedis.HostAndPort.(HostAndPort.java:12) [classes!/:0.1]
at redis.clients.jedis.JedisFactory.(JedisFactory.java:37) [classes!/:0.1]
at redis.clients.jedis.JedisPool.(JedisPool.java:185) [classes!/:0.1]
at redis.clients.jedis.JedisPool.(JedisPool.java:162) [classes!/:0.1]
at redis.clients.jedis.JedisPool.(JedisPool.java:92) [classes!/:0.1]
at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.createRedisPool(JedisConnectionFactory.java:268) [classes!/:0.1]
at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.createPool(JedisConnectionFactory.java:244) [classes!/:0.1]
at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.afterPropertiesSet(JedisConnectionFactory.java:231) [classes!/:0.1]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1642) [classes!/:0.1]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1579) [classes!/:0.1]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553) [classes!/:0.1]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) [classes!/:0.1]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) [classes!/:0.1]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) [classes!/:0.1]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) [classes!/:0.1]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) [classes!/:0.1]
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:207) [classes!/:0.1]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1131) [classes!/:0.1]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1059) [classes!/:0.1]
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:835) [classes!/:0.1]
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741) [classes!/:0.1]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:467) [classes!/:0.1]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1128) [classes!/:0.1]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1022) [classes!/:0.1]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:512) [classes!/:0.1]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) [classes!/:0.1]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) [classes!/:0.1]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) [classes!/:0.1]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) [classes!/:0.1]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) [classes!/:0.1]
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:207) [classes!/:0.1]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1131) [classes!/:0.1]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1059) [classes!/:0.1]
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:835) [classes!/:0.1]
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741) [classes!/:0.1]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:467) [classes!/:0.1]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1128) [classes!/:0.1]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1022) [classes!/:0.1]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:512) [classes!/:0.1]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) [classes!/:0.1]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) [classes!/:0.1]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) [classes!/:0.1]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) [classes!/:0.1]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) [classes!/:0.1]
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:207) [classes!/:0.1]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1131) [classes!/:0.1]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1059) [classes!/:0.1]
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:835) [classes!/:0.1]
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741) [classes!/:0.1]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:467) [classes!/:0.1]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1128) [classes!/:0.1]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1022) [classes!/:0.1]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:512) [classes!/:0.1]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) [classes!/:0.1]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) [classes!/:0.1]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) [classes!/:0.1]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) [classes!/:0.1]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) [classes!/:0.1]
at org.springframework.boot.web.servlet.ServletContextInitializerBeans.getOrderedBeansOfType(ServletContextInitializerBeans.java:234) [classes!/:0.1]
at org.springframework.boot.web.servlet.ServletContextInitializerBeans.addAsRegistrationBean(ServletContextInitializerBeans.java:182) [classes!/:0.1]
at org.springframework.boot.web.servlet.ServletContextInitializerBeans.addAsRegistrationBean(ServletContextInitializerBeans.java:177) [classes!/:0.1]
at org.springframework.boot.web.servlet.ServletContextInitializerBeans.addAdaptableBeans(ServletContextInitializerBeans.java:159) [classes!/:0.1]
at org.springframework.boot.web.servlet.ServletContextInitializerBeans.(ServletContextInitializerBeans.java:80) [classes!/:0.1]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.getServletContextInitializerBeans(EmbeddedWebApplicationContext.java:241) [classes!/:0.1]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.selfInitialize(EmbeddedWebApplicationContext.java:228) [classes!/:0.1]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.access$000(EmbeddedWebApplicationContext.java:89) [classes!/:0.1]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext$1.onStartup(EmbeddedWebApplicationContext.java:213) [classes!/:0.1]
at org.springframework.boot.context.embedded.tomcat.TomcatStarter.onStartup(TomcatStarter.java:55) [classes!/:0.1]
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5178) [classes!/:0.1]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [classes!/:0.1]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1403) [classes!/:0.1]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1393) [classes!/:0.1]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_144]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_144]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_144]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_144]
Caused by: java.net.UnknownHostException: host-172-16-14-106: Name or service not known
at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method) ~[na:1.8.0_144]
at java.net.InetAddress$2.lookupAllHostAddr(InetAddress.java:928) ~[na:1.8.0_144]
at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1323) ~[na:1.8.0_144]
at java.net.InetAddress.getLocalHost(InetAddress.java:1500) ~[na:1.8.0_144]
... 77 common frames omitted
2017/12/05-18:00:55 [main] DEBUG org.triber.bui.portal.web.LoginMainController- Found action method [public java.lang.String org.triber.bui.portal.web.LoginMainController.success(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)]
2017/12/05-18:00:55 [main] DEBUG org.triber.bui.portal.web.LoginMainController- Found action method [public void org.triber.bui.portal.web.LoginMainController.reLogin(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) throws java.io.IOException]
2017/12/05-18:01:13 [main] DEBUG com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsPoller- Starting HystrixMetricsPoller
2017/12/05-18:01:13 [main] INFO  org.triber.bui.Application- Started Application in 55.741 seconds (JVM running for 57.343)

在发布项目的时候,可能会遇到这种问题,

解决方案:

在命令窗口输入:ping [IP] 查看是否有连接,如果没有,则为网络问题,如果有,尝试第二步.

查看报错说明:redis.clients.jedis.HostAndPort- cant resolve localhost address,每个项目虽然都可能报Name or service not known,但指向不同,可能指向不同服务,我这里指向redis,则有针对性处理.

# redis-server redis.conf 以redis.conf文件形式运行redis服务,可以ping一下查看或直接查看redis运行的端口,看是否启动了redis,若没有,则启动.若已启动,则尝试第三步.

如果第一步第二步都处理不了,那么进行第四步:java.net.UnknownHostException: host-172-16-14-106: host-172-16-14-106: Name or service not known.

那就是很可能你发布项目的主机不在/etc/hosts文件里,没有环境.

则:先获取发布项目的服务器的主机名:#hostname

然后在打开并编辑/etc/hosts文件将[hostname]加入到环境中:vim /etc/hosts 进入--INSERT--模式,在[email protected]   中加入[hostname]

然后打出 :wq 保存并退出.重启服务即可.

如果第三步执行完,仍然报错,则只剩下最后一种可能,就是网络主机名设置,则编辑

vi /etc/sysconfig/network 文件配置如下

NETWORKING=yes

HOSTNAME=node005

//HOSTNAME=本机别名

配置完保存 service network restart 即可

你可能感兴趣的:(JAVA,部署,解决方案)