无法从Windows远程客户端连接到HBase独立服务器 [英] Unable to connect to HBase stand alone server from windows remote client
问题描述
我在Centos虚拟机上安装了HBase独立服务器,而我的客户端安装在Windows桌面上。我可以远程连接到HBase独立服务器而无需在Windows上安装HBase吗?如果是的话,这里有下列文件
/ etc / hosts文件
172.16.108.1 CentOS60-64#由NetworkManager添加
127.0.0.1 localhost.localdomain localhost
172.29.36.32 localhost.localdomain localhost
172.29.36.32 534CentOS64-0
hbase-site.xml文件
< configuration>
<属性>
<名称> hbase.rootdir< /名称>
< value> file:/// root / Desktop / HBase / hbase< / value>
< / property>
<属性>
<名称> hbase.zookeeper.property.dataDir< / name>
<值> / root / Desktop / HBase / zookeeper< /值>
< / property>
<属性>
< name> hbase.zookeeper.property.clientPort< / name>
<值> 62181< /值>
< / property>
<属性>
<名称> hbase.zookeeper.quorum< / name>
<值> 172.29.36.32< /值>
< / property>
< / configuration>
/ CONF / regrionservers文件
本地主机
172.29.36.32
代码片段连接到HBase服务器
Configuration config = HBaseConfiguration.create();
config.set(hbase.zookeeper.quorum,172.29.36.32);
config.set(hbase.zookeeper.property.clientPort,62181);
//创建管理员
HBaseAdmin admin = new HBaseAdmin(config);
//创建表格描述符
HTableDescriptor describe = admin.getTableDescriptor(org.apache.hadoop.hbase.TableName.valueOf(emp));
//获取所有列系列
Set< byte []> ColumnFamily = describe.getFamiliesKeys();
//列出所有列族
System.out.println(ColumnFamily.size());
Iterator< byte []>它= ColumnFamily.iterator(); (it.hasNext())
{
System.out.println(Bytes.toString(it.next()));
}
---当我尝试运行上面的代码时,它花费的时间太长运行并将错误提升为....未知主机:localhost.localdomain
---我可以连接到以下url: -
http://172.29.36.32:60010/master-status
PS: - 我会感谢有人可以帮我解决问题。答案很晚,但我希望它能帮助别人。
您的问题可能是/ etc / hosts文件。我认为你应该删除以下行:
172.29.36.32 localhost.localdomain localhost
另外,如果你要连接到远程HBase的集群 - 确保添加全部集群主机名和IP对本地hosts文件(在/ etc /在Linux或C主机:\Windows\System32\drivers\\在Windows上的\\ etc \hosts),如下所示:
36.32 534CentOS64-0显然Zookeper当试图连接到HBase的,并与Java远程连接时,它可以是一个问题,使用主机名而不是IP某处。
希望它有帮助!
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
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!
这篇关于无法从Windows远程客户端连接到HBase独立服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!