gpt4 book ai didi

java - HBase Java客户端无法访问远程HBase区域服务器

转载 作者:行者123 更新时间:2023-12-02 21:49:55 25 4
gpt4 key购买 nike

我已经在服务器中启动了一个独立的HBase(192.168.36.42)

客户端

package com.test;

import java.util.ArrayList;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.client.HTable;
import org.apache.hadoop.hbase.client.Put;

public class HBaseClient {

public static void main(String[] args) throws Exception {
Configuration config = HBaseConfiguration.create();
System.out.println("IP Address : " + config.get("hbase.zookeeper.quorum"));

HTable table = new HTable(config, "test_table");
ArrayList<Put> data = new ArrayList<Put>();
Put p = new Put("row3".getBytes());
p.add("field1".getBytes(), "qualifier".getBytes(), "value".getBytes());

table.put(data);
table.flushCommits();

data.clear();
table.close();
System.out.println("close table");
}
}

这是客户端的控制台输出:
14/02/26 16:21:31 INFO ipc.HBaseRPC: Server at BJ-NQ-V-CR002/192.168.36.42:44525 could not be reached after 1 tries, giving up.
14/02/26 16:21:33 INFO ipc.HBaseRPC: Server at BJ-NQ-V-CR002/192.168.36.42:44525 could not be reached after 1 tries, giving up.
14/02/26 16:21:35 INFO ipc.HBaseRPC: Server at BJ-NQ-V-CR002/192.168.36.42:44525 could not be reached after 1 tries, giving up.
14/02/26 16:21:37 INFO ipc.HBaseRPC: Server at BJ-NQ-V-CR002/192.168.36.42:44525 could not be reached after 1 tries, giving up.

客户端 /etc/host:
192.168.36.42   BJ-NQ-V-CR002

hbase-site.xml
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>hbase.zookeeper.quorum</name>
<value>BJ-NQ-V-CR002</value>
</property>
<property>
<name>hbase.zookeeper.property.clientPort</name>
<value>2181</value>
</property>
</configuration>

服务器端
hbase(main):003:0> describe 'test_table'
DESCRIPTION ENABLED
'test_table', {NAME => 'field1', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'NONE', REPLICATION_SCOPE => '0', true
VERSIONS => '3', COMPRESSION => 'NONE', MIN_VERSIONS => '0', TTL => '2147483647', KEEP_DELETED_CELLS => 'false',
BLOCKSIZE => '65536', IN_MEMORY => 'false', ENCODE_ON_DISK => 'true', BLOCKCACHE => 'true'}, {NAME => 'field2', D
ATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'NONE', REPLICATION_SCOPE => '0', VERSIONS => '3', COMPRESSION => 'N
ONE', MIN_VERSIONS => '0', TTL => '2147483647', KEEP_DELETED_CELLS => 'false', BLOCKSIZE => '65536', IN_MEMORY =>
'false', ENCODE_ON_DISK => 'true', BLOCKCACHE => 'true'}
1 row(s) in 0.1680 seconds

/ etc / hosts
127.0.0.1  BJ-NQ-V-CR002
127.0.0.1 localhost localhost.localdomain
192.168.36.42 BJ-NQ-V-CR002

hbase-site.xml
<configuration>
<property>
<name>hbase.zookeeper.quorum</name>
<value>BJ-NQ-V-CR002</value>
</property>
<property>
<name>hbase.rootdir</name>
<value>file:///root/hbase-0.94.16/data/hbase</value>
</property>
<property>
<name>hbase.zookeeper.property.dataDir</name>
<value>/root/hbase-0.94.16/data/zookeeper</value>
</property>
</configuration>

地区服务器
BJ-NQ-V-CR002

最佳答案

您的日志不显示任何超时异常,仅显示一些Zookeeper输出。尽管如此,我之前已经看到过这一点。

检查是否可以从hbase shell进行put。您可能只有一个区域服务器为该表提供服务,并且出现问题。相关区域服务器已关闭或表文件在hdfs上不可用。

重新启动区域服务器并查看其日志

关于java - HBase Java客户端无法访问远程HBase区域服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21924330/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com