如今,配置Kestrel的Worker都是时候,遇到了这样的问题:
引用
[2012-08-06 11:35:56,165][ERROR][net.rubyeye.xmemcached.monitor.XMemcachedMbeanServer:88] Get HostName Error
java.net.UnknownHostException: 49_114: 49_114
at java.net.InetAddress.getLocalHost(InetAddress.java:1354)
at net.rubyeye.xmemcached.monitor.XMemcachedMbeanServer.initialize(XMemcachedMbeanServer.java:84)
at net.rubyeye.xmemcached.monitor.XMemcachedMbeanServer.<init>(XMemcachedMbeanServer.java:73)
at net.rubyeye.xmemcached.monitor.XMemcachedMbeanServer.<clinit>(XMemcachedMbeanServer.java:66)
这里的 49_114是这台机器的 hostname,而我要访问的是另一个ip。并发我的代码访问了localhost,可能xmemcached默认初始化时,进行了本机信息获取,才导致这一问题。
看看hostname是谁:
引用
$ hostname
49_114
$ hostname -i
hostname: 未知的主机
太悲剧了 ,难怪出现 Get HostName Error!
再看看 hosts
引用
cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
这就是悲剧的根源,在 hosts中,没有指明自身ip绑定。
这个问题其实很容易解决,将hostname与localhost绑定即可。
引用 # Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 49_114 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
就这么简单!
引用
$ hostname
49_114
$ hostname -i
127.0.0.1
这时候,就不会再出来 Get HostName Error异常了!
转载于:https://my.oschina.net/mohaiyong/blog/221236