Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to get local hostname java.net.UnknownHostException: centos-ami: centos-ami: Name or service not known #7

Open
pentium10 opened this issue Feb 10, 2014 · 5 comments

Comments

@pentium10
Copy link

[root@centos-ami riak-data-migrator-0.2.5]# ../jdk1.7.0_51/bin/java -jar riak-data-migrator-0.2.5.jar -h 10.46.100.10 -p 8081 -H 8071 -r ~ -b products -d
Destination PB Port not specified, using the default: 8087
09:38:53,941 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback.groovy]
09:38:53,941 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-test.xml]
09:38:53,942 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback.xml] at [file:/root/riak-data-migrator-0.2.5/conf/logback.xml]
09:38:54,362 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - debug attribute not set
09:38:54,480 |-ERROR in ch.qos.logback.core.util.ContextUtil@64cf5b3 - Failed to get local hostname java.net.UnknownHostException: centos-ami: centos-ami: Name or service not known
        at java.net.UnknownHostException: centos-ami: centos-ami: Name or service not known
        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:56)
        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:157)
        at      at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:143)
        at      at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:106)
        at      at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:56)
        at      at ch.qos.logback.classic.util.ContextInitializer.configureByResource(ContextInitializer.java:75)
        at      at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:148)
        at      at org.slf4j.impl.StaticLoggerBinder.init(StaticLoggerBinder.java:85)
        at      at org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:55)
        at      at org.slf4j.LoggerFactory.bind(LoggerFactory.java:128)
        at      at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:107)
        at      at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:295)
        at      at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:269)
        at      at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:281)
        at      at com.basho.proserv.datamigrator.riak.Connection.<init>(Connection.java:21)
        at      at com.basho.proserv.datamigrator.Main.runDumper(Main.java:378)
        at      at com.basho.proserv.datamigrator.Main.main(Main.java:96)
Caused by: java.net.UnknownHostException: centos-ami: Name or service not known
        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      ... 23 common frames omitted
09:38:54,481 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]
09:38:54,494 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [STDOUT]
09:38:54,643 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
09:38:54,863 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.FileAppender]
09:38:54,866 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [FILE]
09:38:54,872 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
09:38:54,873 |-INFO in ch.qos.logback.core.FileAppender[FILE] - File property is set to [log/riak-data-migrator-error.log]
09:38:54,875 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.FileAppender]
09:38:54,875 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [STATUS]
09:38:54,939 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
09:38:54,940 |-INFO in ch.qos.logback.core.FileAppender[STATUS] - File property is set to [log/riak-data-migrator-status.log]
09:38:54,942 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [status] to INFO
09:38:54,942 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [status] to false
09:38:54,942 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STATUS] to Logger[status]
09:38:54,943 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to ERROR
09:38:54,943 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [FILE] to Logger[ROOT]
09:38:54,943 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
09:38:54,947 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator@2c6d1158 - Registering current configuration as safe fallback point

this long message shouldn't be there, the job gets done (the dump happens correctly, but each time I issue riak-data-migrator I get this printed), but I don't know why it's printed, it might be an error.

@dankerrigan
Copy link

This looks like a logging configuration error. The logger prints to stdout
because of the failure. Can you reply with the contents of your
conf/logback.xml file. Thanks.

On Mon, Feb 10, 2014 at 9:43 AM, Pentium10 [email protected] wrote:

[root@centos-ami riak-data-migrator-0.2.5]# ../jdk1.7.0_51/bin/java -jar riak-data-migrator-0.2.5.jar -h 10.46.100.10 -p 8081 -H 8071 -r ~ -b products -d
Destination PB Port not specified, using the default: 8087
09:38:53,941 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback.groovy]
09:38:53,941 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-test.xml]
09:38:53,942 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback.xml] at [file:/root/riak-data-migrator-0.2.5/conf/logback.xml]
09:38:54,362 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - debug attribute not set
09:38:54,480 |-ERROR in ch.qos.logback.core.util.ContextUtil@64cf5b3 - Failed to get local hostname java.net.UnknownHostException: centos-ami: centos-ami: Name or service not known
at java.net.UnknownHostException: centos-ami: centos-ami: Name or service not known
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:56)
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:157)
at at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:143)
at at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:106)
at at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:56)
at at ch.qos.logback.classic.util.ContextInitializer.configureByResource(ContextInitializer.java:75)
at at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:148)
at at org.slf4j.impl.StaticLoggerBinder.init(StaticLoggerBinder.java:85)
at at org.slf4j.impl.StaticLoggerBinder.(StaticLoggerBinder.java:55)
at at org.slf4j.LoggerFactory.bind(LoggerFactory.java:128)
at at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:107)
at at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:295)
at at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:269)
at at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:281)
at at com.basho.proserv.datamigrator.riak.Connection.(Connection.java:21)
at at com.basho.proserv.datamigrator.Main.runDumper(Main.java:378)
at at com.basho.proserv.datamigrator.Main.main(Main.java:96)
Caused by: java.net.UnknownHostException: centos-ami: Name or service not known
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 ... 23 common frames omitted
09:38:54,481 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]
09:38:54,494 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [STDOUT]
09:38:54,643 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
09:38:54,863 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.FileAppender]
09:38:54,866 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [FILE]
09:38:54,872 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
09:38:54,873 |-INFO in ch.qos.logback.core.FileAppender[FILE] - File property is set to [log/riak-data-migrator-error.log]
09:38:54,875 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.FileAppender]
09:38:54,875 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [STATUS]
09:38:54,939 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
09:38:54,940 |-INFO in ch.qos.logback.core.FileAppender[STATUS] - File property is set to [log/riak-data-migrator-status.log]
09:38:54,942 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [status] to INFO
09:38:54,942 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [status] to false
09:38:54,942 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STATUS] to Logger[status]
09:38:54,943 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to ERROR
09:38:54,943 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [FILE] to Logger[ROOT]
09:38:54,943 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
09:38:54,947 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator@2c6d1158 - Registering current configuration as safe fallback point

this long message shouldn't be there, the job gets done (the dump happens
correctly, but each time I issue riak-data-migrator I get this printed),
but I don't know why it's printed, it might be an error.

Reply to this email directly or view it on GitHubhttps://github.com//issues/7
.

@pentium10
Copy link
Author

[root@centos-ami conf]# cat logback.xml
<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="false">

        <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <!-- encoders are assigned the type
             ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
                <encoder>
                        <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{5} - %msg%n</pattern>
                </encoder>
        </appender>

        <appender name="FILE" class="ch.qos.logback.core.FileAppender">
                <file>log/riak-data-migrator-error.log</file>
                <append>false</append>
                <encoder>
                        <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
                </encoder>
        </appender>

        <appender name="STATUS" class="ch.qos.logback.core.FileAppender">
                <file>log/riak-data-migrator-status.log</file>
                <append>false</append>
                <encoder>
                        <pattern>%msg%n</pattern>
                </encoder>
        </appender>

        <logger name="status" level="INFO" additivity="false">
                <appender-ref ref="STATUS" />
        </logger>

        <!-- Strictly speaking, the level attribute is not necessary since -->
        <!-- the level of the root level is set to DEBUG by default.       -->
        <root level="ERROR">
                <appender-ref ref="FILE" />
        </root>

</configuration>

I don't remember modifying this, so it might exactly what we have downloaded from your link.

@dankerrigan
Copy link

You're correct that the log file configuration is the default. I
should have noticed that it's the call
java.net.InetAddress.getLocalHost() that is failing. It appears that
your machine hostname, centos-ami, is not resolving via DNS
[http://holtstrom.com/michael/blog/post/401/Hostname-in-Amazon-Linux.html].
You can try adding it to your hosts file to resolve your issue quickly
[http://stackoverflow.com/questions/1881546/inetaddress-getlocalhost-throws-unknownhostexception].
I am closing this issue since it's related to your environment and
tangentially, the logback library, versus this program.

On Mon, Feb 10, 2014 at 11:40 AM, Pentium10 [email protected]:

[root@centos-ami conf]# cat logback.xml

    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
    <!-- encoders are assigned the type
         ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
            <encoder>
                    <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{5} - %msg%n</pattern>
            </encoder>
    </appender>

    <appender name="FILE" class="ch.qos.logback.core.FileAppender">
            <file>log/riak-data-migrator-error.log</file>
            <append>false</append>
            <encoder>
                    <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
            </encoder>
    </appender>

    <appender name="STATUS" class="ch.qos.logback.core.FileAppender">
            <file>log/riak-data-migrator-status.log</file>
            <append>false</append>
            <encoder>
                    <pattern>%msg%n</pattern>
            </encoder>
    </appender>

    <logger name="status" level="INFO" additivity="false">
            <appender-ref ref="STATUS" />
    </logger>

    <!-- Strictly speaking, the level attribute is not necessary since -->
    <!-- the level of the root level is set to DEBUG by default.       -->
    <root level="ERROR">
            <appender-ref ref="FILE" />
    </root>

I don't remember modifying this, so it might exactly what we have
downloaded from your link.

Reply to this email directly or view it on GitHubhttps://github.com//issues/7#issuecomment-34652261
.

@pentium10
Copy link
Author

I don't agree.

The script should support machines where the hostname is not set. And this is not something I should quickly resolve as we have a farm of machines, and they are auto-scaling. Instances die, and they are respawn with others, we don't have hostnames for all these, as it's a big thing to accomplish on every machine. Instead we use the tags, and other IP related management to identify our machines.

The issue is, that the message itself spams our logs, and we get alerted by email/sms because the output itself has the ERROR keyword. So I think this can be serious and not cataloged to some environment flaw. What do you think?

@dankerrigan
Copy link

If the error were something that could be handled in riak-data-migrator, I
would agree, but the issue is with the underlying logging library, so I
don't.

The options are:

  1. Switch logging libraries to one that doesn't attempt to use
    java.net.InetAddress.getLocalHost(). Feel free to submit a PR.
  2. Log an issue with the logback folks. A quick google search shows that
    this is an issue that has come up before and they opted not to fix it.
  3. Try Java 8. I also found a link that said the exception thrown by
    java.net.InetAddress.getLocalHost() is a Java bug and it may have been
    resolved/behave differently in that environment.

It sounds like you might be deploying riak-data-migrator to machines in an
auto-scale environment. This does not fit the development assistance scope
of the program. It's primarily intended to be run from a single machine
against an existing Riak cluster. In this case, I don't believe it's too
much trouble to add your hostname to your hosts file once [echo "127.0.0.1
$(hostname -s)" >> /etc/hosts].

On Mon, Feb 10, 2014 at 12:55 PM, Pentium10 [email protected]:

I don't agree.

The script should support machines where the hostname is not set. And this
is not something I should quickly resolve as we have a farm of machines,
and they are auto-scaling. Instances die, and they are respawn with others,
we don't have hostnames for all these, as it's a big thing to accomplish on
every machine. Instead we use the tags, and other IP related management to
identify our machines.

The issue is, that the message itself spams our logs, and we get alerted
by email/sms because the output itself has the ERROR keyword. So I think
this can be serious and not cataloged to some environment flaw. What do you
think?

Reply to this email directly or view it on GitHubhttps://github.com//issues/7#issuecomment-34660785
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants