Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How Windows Java code remotely accesses HBase

Shulou Source: shulou.com Published: 2022-06-01 20:52:29 10月23日 Update

This article will explain in detail how Windows Java code remotely accesses HBase. The content of the article is of high quality, so the editor shares it for you as a reference. I hope you will have some understanding of the relevant knowledge after reading this article.

To build a maven project, pom depends on the following:

Org.apache.hbase

Hbase-client

1.2.0-cdh6.7.0

Org.apache.hadoop

Hadoop-hdfs

2.6.0-cdh6.7.0

Since the cdh version I use, the default source contains only common dependencies, so you need to add the following sources provided by Cloudera:

Cloudera

Https://repository.cloudera.com/artifactory/cloudera-repos/

Note: if Ali image is configured in the Maven configuration file setting.xml, the CDH-related jar package cannot be downloaded. You can use the default image of maven.

Establish a connection

The pseudo code is as follows:

Public class HbaseBaseClient {

Private static Configuration confHbase = null

Private static Connection connection = null

{

ConfHbase = HBaseConfiguration.create ()

ConfHbase.setLong ("hbase.rpc.timeout", 600000)

ConfHbase.setLong ("hbase.client.scanner.caching", 1000)

ConfHbase.set ("hbase.zookeeper.quorum", zknode)

ConfHbase.set ("hbase.zookeeper.property.clientPort", "2181")

/ / No FileSystem for schema: hdfs

ConfHbase.set ("fs.hdfs.impl", "org.apache.hadoop.hdfs.DistributedFileSystem")

Try {

Connection=ConnectionFactory.createConnection (confHbase);} catch (IOException e) {e.printStackTrace ();}

Just configure the zk address, and you can access it through Master.

The most important step:

Configure the hosts file!

All hosts should be configured!

Otherwise, it will make the following error:

Java.net.UnknownHostException: unknown host

In this way, you can write the add, delete, modify and check code, and then right-click to execute the run command!

Of course, you must be able to ping the server! Some intranets are inaccessible! There are other ways to debug! We'll talk about it later!

About Windows Java code how to remotely access HBase to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Tags: Configuration code content files articles more knowledge articles mirrors good important hosts methods can be passed commands addresses projects commonly used servers versions Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Shulou Technology Docker Xiaomi Linux