无法从windows远程客户端连接到HBase单机服务器

无法从windows远程客户端连接到HBase单机服务器,hbase,Hbase,我的HBase独立服务器位于centos虚拟机上,客户端位于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 534中心

我的HBase独立服务器位于centos虚拟机上,客户端位于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 534中心64-0

hbase-site.xml文件

hbase.rootdir
file:///root/Desktop/HBase/hbase
hbase.zookeeper.property.dataDir
/root/Desktop/HBase/zookeeper
hbase.zookeeper.property.clientPort
62181
hbase.zookeeper.quorum
172.29.36.32
/conf/regionservers文件 本地主机 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=新的HBaseAdmin(配置);
//创建表描述符
HTableDescriptor descripe=admin.getTableDescriptor(org.apache.hadoop.hbase.TableName.valueOf(“emp”);
//获取所有列族
Set ColumnFamily=description.getFamiliesKeys();
//列出所有列族
System.out.println(ColumnFamily.size());
迭代器it=ColumnFamily.Iterator();
while(it.hasNext())
{
System.out.println(Bytes.toString(it.next());
}
---当我试图运行上述代码时,运行时间太长,并引发错误,如。。。。未知主机:localhost.localdomain

---我能够连接到以下url:-
PS:-如果有人能帮助我,我将非常感激。

答案很晚了,但我希望它能帮助别人。 您案例中的问题可能是/etc/hosts文件。我认为您应该删除以下行:

172.29.36.32 localhost.localdomain localhost

此外,如果要连接到远程HBase群集,请确保将所有群集主机名和ip添加到本地主机文件(/etc/hosts(Linux上)或C:\Windows\System32\drivers\etc\hosts(Windows上),如下所示:

172.16.108.1世纪60-64

172.29.36.32 534中心64-0

显然,Zookeper在尝试连接到HBase时在某处使用主机名而不是ip,在远程连接Java时可能会出现问题


希望有帮助

也许你应该修改你的
/etc/hosts
文件。给你举个例子

[您的ip可以远程访问][您的域将被远程服务器使用]
[您的ip与最后一行相同][您的主机名,可以通过命令
hostname
]

主机名
不应出现在映射其他ip地址的其他行上

之后,客户端将使用
访问您的hbase服务器。您可以在日志中获取该信息

您可以通过以下代码进行检查

import java.net.InetAddress;
public class Test{
    public static void main(String args[]) throws Exception{
       System.out.println(InetAddress.getLocalHost().getCanonicalHostName());
}
}
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()));
        }
import java.net.InetAddress;
public class Test{
    public static void main(String args[]) throws Exception{
       System.out.println(InetAddress.getLocalHost().getCanonicalHostName());
}
}