【问题标题】:Unable to connect to HBase stand alone server from windows remote client无法从 Windows 远程客户端连接到 HBase 独立服务器
【发布时间】:2015-06-10 08:35:57
【问题描述】:

我的 HBase 独立服务器在 centos 虚拟机上,我的客户端在 windows 桌面上。我可以在 Windows 上不安装 HBase 的情况下远程连接到 HBase 独立服务器吗?如果是,这里有以下文件

/etc/hosts 文件

172.16.108.1 CentOS60-64 # 由 NetworkManager 添加 127.0.0.1 localhost.localdomain 本地主机 172.29.36.32 localhost.localdomain 本地主机

172.29.36.32 534CentOS64-0

hbase-site.xml 文件

<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 文件

本地主机 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");

        // 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()));
        }

--- 当我尝试运行上面的代码时,运行时间太长并引发错误 .... unknown host: localhost.localdomain

--- 我能够连接到以下网址:- http://172.29.36.32:60010/master-status PS:-如果有人可以帮助我,我将不胜感激

【问题讨论】:

    标签: hbase


    【解决方案1】:

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

    172.29.36.32 localhost.localdomain 本地主机

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

    172.16.108.1 CentOS60-64

    172.29.36.32 534CentOS64-0

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

    希望对你有帮助!

    【讨论】:

      【解决方案2】:

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

      [你的ip可以远程访问][你的域名将被远程服务器使用]
      [你的ip和最后一行一样] [你的主机名可以通过命令hostname得到]

      并且domainhostname不应出现在映射其他IP地址的其他行上。

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

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

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-12-10
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-06-20
        • 2020-07-20
        • 1970-01-01
        相关资源
        最近更新 更多