Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

hbase REST API return '...loading... ' through knox gateway

avatar
Explorer

In HDP sandbox, I started the hbase rest daemon at 60080. It's OK to get table list by:

curl http://localhost:60080

but when I try it through knox gateway as below:

curl -ik -u guest:guest-password -H "Accept: text/xml" -X GET 'https://localhost:8443/gateway/default/hbase'

it returns the message instead of tables:

<body> <div id="loading">...Loading...</div> <div id="wrapper"> <!-- ApplicationView --> </div> <footer> <div> <a href="http://www.apache.org/licenses/LICENSE-2.0" target="_blank">Licensed under the Apache License, Version 2.0</a>.<br> <a href="/licenses/NOTICE.txt" target="_blank">See third-party tools/resources that Ambari uses and their respective authors</a> </div> </footer> </body>

One point to mention is it's OK to list the directory of HDFS through knox gateway:

curl -iku guest:guest-password -X GET 'https://localhost:8443/gateway/default/webhdfs/v1/?op=LISTSTATUS'

1 ACCEPTED SOLUTION

avatar
Explorer

@jerry shen. Something seems to be off in your setup. Mostly what is confusing me is that you don't have a default.xml file.

In any case, I think I did find an issue with the sandbox setup. I imported the sandbox like you said and turned off maintenance mode and started HBase, Knox and the Demo LDAP. In addition to that I started the REST server for Hbase. As of now this is unfortunately not something you can do in Ambari so you will need to ssh to the box and execute something like this:

{HBASE_BIN/hbase-daemon.sh start rest -p 60080

As is described here:

http://knox.apache.org/books/knox-0-11-0/user-guide.html#HBase

Now once the REST server is running you can execute 'curl http://localhost:60080' like you originally said.

Now coming to the issue. I see that in Ambari the wrong port is getting set for the service. If you go into Ambari and the Knox service's 'Configs' tab. Expand on the section "Advanced Topology" and scroll to the <service> xml section for WEBHBASE. You should see this:

    <service>
                <role>WEBHBASE</role>
                <url>http://{{hbase_master_host}}:{{hbase_master_port}}</url>
            </service>

That value is getting saved to the topology file 'default.xml' as this (which is the wrong port):

<service> 
   <role>WEBHBASE</role> 
   <url>http://sandbox.hortonworks.com:8080</url>
 </service> 

You want it to look like this:

<service> 
   <role>WEBHBASE</role> 
   <url>http://sandbox.hortonworks.com:60080</url>
 </service> 

So the easiest thing to do right now in the sandbox you are using would be to change it in that 'Advanced Topology" section and save it to:

    <service>
                <role>WEBHBASE</role>
                <url>http://{{hbase_master_host}}:60080</url>
            </service>

Remember to restart Knox from Ambari after this. If you can validate the default.xml file on disk in this entire process it would be useful.

Please note: the path for me on the sandbox VM for the topology file was /usr/hdp/2.5.0.0-1245/knox/conf/topologies/default.xml

The path for HBase bin for me was /usr/hdp/2.5.0.0-1245/hbase/bin/

and the curl command to use in the end is:

curl -ik -u guest:guest-password -H "Accept: text/xml" -X GET 'https://localhost:8443/gateway/default/hbase'

View solution in original post

6 REPLIES 6

avatar
Explorer

Hi @jerry shen, are there any errors in the gateway.log file (can be found under the logs directory in Knox's installation directory). Also please verify the URL in topology file (default.xml under conf/topologies) for HBase is correct.

avatar
Explorer

There is no output to /var/log/knox/gateway.log file when executing the problem curl command. And in I checked the HBase URL in /usr/hdp/2.5.0.0-1245/etc/knox/conf/topologies/sandbox.xml, it seems right. In file, it contains the following entry:

<service>

<role>WEBHBASE</role>

<url>http://localhost:60080</url>

</service>

Did I check with right files? Thanks for your reply.

avatar
Explorer

Thanks @jerry shen. There are a couple of things you can do to help debug the issue:

1. Increase the debug level so that we can see what is going on. This can be done by editing the file gateway-log4j.properties file. You can uncomment the line :

log4j.logger.org.apache.http.wire=DEBUG

for example to see wire level logs for request and response to the backend service. Please note that after changing this file you need to restart Knox for the change to take effect. If you have Ambari installed then you should use Ambari to do this.

The other file to check is the audit log, which can be found in the same logs directory and is called 'gateway-audit.log'.

2. The file topology file you checked (/usr/hdp/2.5.0.0-1245/etc/knox/conf/topologies/sandbox.xml) does not match the URL you were trying. Since you said you tried:

curl -ik -u guest:guest-password -H "Accept: text/xml" -X GET 'https://localhost:8443/gateway/default/hbase'

you should be checking /usr/hdp/2.5.0.0-1245/etc/knox/conf/topologies/default.xml or you should change the curl request to:

curl -ik -u guest:guest-password -H "Accept: text/xml" -X GET 'https://localhost:8443/gateway/sandbox/hbase'

Just a word of note here. If you are using Ambari, then Ambari manages the 'default' topology and not 'sandbox'.

avatar
Explorer

I enabled the log4j.logger.org.apache.http.wire=DEBUG, but it seems that something wrote into the gateway.log and gateway-audit.log only when I am starting the knox service in Ambari. Anyway, I attached the log files, please have a look on them.

I tried with the command: curl -ik -u guest:guest-password -H "Accept: text/xml" -X GET 'https://localhost:8443/gateway/sandbox/hbase', but the result is same.

There is no default.xml in topology folder. I manually make a copy from sandbox.xml, and try again with "default" in the curl command, the result is same.

I paste the sandbox-version output as below:

Sandbox information: Created on: 25_10_2016_08_11_26 for Hadoop stack version: Hadoop 2.7.3.2.5.0.0-1245 Ambari Version: 2.4.0.0-1225 Ambari Hash: 59175b7aa1ddb74b85551c632e3ce42fed8f0c85 Ambari build: Release : 1225 Java version: 1.8.0_111 OS Version: CentOS release 6.8 (Final)

I just import the sandbox vm, and power it. Then I start HBase service, Knox service, turn off the maintenance mode on them and start Demo LDAP. Then try the curl command, and meet the issue. Did I miss something need to do?

Thanks.

avatar
Explorer

@jerry shen. Something seems to be off in your setup. Mostly what is confusing me is that you don't have a default.xml file.

In any case, I think I did find an issue with the sandbox setup. I imported the sandbox like you said and turned off maintenance mode and started HBase, Knox and the Demo LDAP. In addition to that I started the REST server for Hbase. As of now this is unfortunately not something you can do in Ambari so you will need to ssh to the box and execute something like this:

{HBASE_BIN/hbase-daemon.sh start rest -p 60080

As is described here:

http://knox.apache.org/books/knox-0-11-0/user-guide.html#HBase

Now once the REST server is running you can execute 'curl http://localhost:60080' like you originally said.

Now coming to the issue. I see that in Ambari the wrong port is getting set for the service. If you go into Ambari and the Knox service's 'Configs' tab. Expand on the section "Advanced Topology" and scroll to the <service> xml section for WEBHBASE. You should see this:

    <service>
                <role>WEBHBASE</role>
                <url>http://{{hbase_master_host}}:{{hbase_master_port}}</url>
            </service>

That value is getting saved to the topology file 'default.xml' as this (which is the wrong port):

<service> 
   <role>WEBHBASE</role> 
   <url>http://sandbox.hortonworks.com:8080</url>
 </service> 

You want it to look like this:

<service> 
   <role>WEBHBASE</role> 
   <url>http://sandbox.hortonworks.com:60080</url>
 </service> 

So the easiest thing to do right now in the sandbox you are using would be to change it in that 'Advanced Topology" section and save it to:

    <service>
                <role>WEBHBASE</role>
                <url>http://{{hbase_master_host}}:60080</url>
            </service>

Remember to restart Knox from Ambari after this. If you can validate the default.xml file on disk in this entire process it would be useful.

Please note: the path for me on the sandbox VM for the topology file was /usr/hdp/2.5.0.0-1245/knox/conf/topologies/default.xml

The path for HBase bin for me was /usr/hdp/2.5.0.0-1245/hbase/bin/

and the curl command to use in the end is:

curl -ik -u guest:guest-password -H "Accept: text/xml" -X GET 'https://localhost:8443/gateway/default/hbase'

avatar
Explorer

@sumit gupta. I setup a new sandbox, the default.xml is back, and follow your instruction of modifying the port, everything goes well. So thanks very much.