Unable to connect to HBase stand alone server from windows remote client

1.1k views Asked by At

I have my HBase standalone server on centos virtual machine, and my client is on windows desktop. Can I connect to the HBase standalone server remotely without installing HBase on windows ? If yes , Here are the following files

/etc/hosts file

172.16.108.1 CentOS60-64 # Added by NetworkManager 127.0.0.1 localhost.localdomain localhost 172.29.36.32 localhost.localdomain localhost

172.29.36.32 534CentOS64-0

hbase-site.xml file

<configuration>
        <property>
                <name>hbase.rootdir</name>
                <value>file:///root/Desktop/HBase/hbase</value>
        </property>


        <property>
                <name>hbase.zookeeper.property.dataDir</name>
                <value>/root/Desktop/HBase/zookeeper</value>
        </property>
        <property>
                <name>hbase.zookeeper.property.clientPort</name>
                <value>62181</value>
        </property>
        <property>
                <name>hbase.zookeeper.quorum</name>
                <value>172.29.36.32</value>
        </property>

</configuration>

/conf/regrionservers file

localhost 172.29.36.32

Code Snippet to connect to HBase server

Configuration config = HBaseConfiguration.create();
        config.set("hbase.zookeeper.quorum", "172.29.36.32");
        config.set("hbase.zookeeper.property.clientPort", "62181");

        // Creating Admin
        HBaseAdmin admin = new HBaseAdmin(config);

        // Creating Table Descriptor

        HTableDescriptor describe =admin.getTableDescriptor(org.apache.hadoop.hbase.TableName.valueOf("emp"));

        // Fetching all column families
        Set<byte[]> ColumnFamily = describe.getFamiliesKeys();

        // Listing Out the all column families
        System.out.println(ColumnFamily.size());
        Iterator<byte[]> it=ColumnFamily.iterator();
        while(it.hasNext())
        {
            System.out.println(Bytes.toString(it.next()));
        }

--- When I tried to run above code, Its taking too long time to run and raising error as .... unknown host: localhost.localdomain

--- I was able to connect to following url :- http://172.29.36.32:60010/master-status PS:- I will be thankful if someone can help me out

2

There are 2 answers

0
Adam Maciaszek On BEST ANSWER

The answer is late but I hope that it could help someone. The problem in your case may be /etc/hosts file. I think you should remove the following line:

172.29.36.32 localhost.localdomain localhost

Also, If you are connecting to a remote HBase cluster - make sure to add all of cluster hostnames and ip's to your local hosts file (/etc/hosts on Linux or C:\Windows\System32\drivers\etc\hosts on Windows), like that:

172.16.108.1 CentOS60-64

172.29.36.32 534CentOS64-0

Apparently Zookeper uses hostname instead of ip somewhere when trying to connect to HBase and it can be a problem when connecting remotely with Java.

Hope it helps!

0
elwin On

maybe you should modify your /etc/hosts file. Give you an example.

[your ip can be accessed remote] [your domain will be used by remote server ]
[your ip same as last row ] [your hostname which can get by command hostname]

and the domain and hostname should not be appear on other line mapping other ip addresses.

After that, the client will use the domain to access your hbase server.You can get that information in the log.

you can check by the following code.

import java.net.InetAddress;
public class Test{
    public static void main(String args[]) throws Exception{
       System.out.println(InetAddress.getLocalHost().getCanonicalHostName());
}
}