记录一下Temporary failure in name resolution错误的解决方法

15:35:45,380 |-ERROR in ch.qos.logback.core.util.ContextUtil@62214c6f - Failed to get local hostname java.net.UnknownHostException: qtbj-dmz-122: qtbj-dmz-122: Temporary failure in name resolution
        at java.net.UnknownHostException: qtbj-dmz-122: qtbj-dmz-122: Temporary failure in name resolution
        at      at java.net.InetAddress.getLocalHost(InetAddress.java:1473)
        at      at ch.qos.logback.core.util.ContextUtil.getLocalHostName(ContextUtil.java:32)
        at      at ch.qos.logback.core.util.ContextUtil.addHostNameAsProperty(ContextUtil.java:41)
        at      at ch.qos.logback.classic.joran.action.ConfigurationAction.begin(ConfigurationAction.java:48)
        at      at ch.qos.logback.core.joran.spi.Interpreter.callBeginAction(Interpreter.java:276)
        at      at ch.qos.logback.core.joran.spi.Interpreter.startElement(Interpreter.java:148)
        at      at ch.qos.logback.core.joran.spi.Interpreter.startElement(Interpreter.java:130)
        at      at ch.qos.logback.core.joran.spi.EventPlayer.play(EventPlayer.java:50)
        at      at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:147)
        at      at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:133)
        at      at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:96)
        at      at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:73)
        at      at com.froad.platform.logback.LogCvt.(LogCvt.java:92)
        at      at com.froad.platform.database.connection.impl.DBPool_DBCP.init(DBPool_DBCP.java:17)
        at      at com.froad.platform.database.connection.DBConnection.(DBConnection.java:155)
        at      at com.qt.main.QtpayMain.main(QtpayMain.java:42)
Caused by: java.net.UnknownHostException: qtbj-dmz-122: Temporary failure in name resolution
        at      at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
        at      at java.net.InetAddress$1.lookupAllHostAddr(InetAddress.java:901)
        at      at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1293)
        at      at java.net.InetAddress.getLocalHost(InetAddress.java:1469)
        at      ... 15 common frames omitted

这个主要是/etc/hosts文件里面配置的主机名和显示的主机名不一致,改成一样就行了。

#下面这个qtbj-dmz-122就是主机名
[qtservices@qtbj-dmz-122 lib]$ 
#/etc/hosts中的主机名要和前面的一样,也需要改成一样的。
[qtservices@qtbj-dmz-122 lib]$ cat /etc/hosts
127.0.0.1   qtbj-dmz-122 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
[qtservices@qtbj-dmz-122 lib]$ 

你可能感兴趣的:(java)