Databases 5 min read

Quick Start Guide: Running HBase with Docker

This tutorial demonstrates how to rapidly set up and use HBase inside a Docker container, covering Docker installation, image pulling, container execution, host configuration, accessing the HBase Web UI and shell, Zookeeper interaction, and a Java API example for beginners.

Big Data Technology Architecture
Big Data Technology Architecture
Big Data Technology Architecture
Quick Start Guide: Running HBase with Docker

Introduction : This article explains how to quickly get started with HBase using Docker, avoiding complex installation and deployment, and is suitable for beginners.

1. Docker Installation

Reference address:

https://yeasy.gitbook.io/docker_practice/install

Supported operating systems include CentOS, Ubuntu, Windows, and macOS.

2. Pulling the Image

Image repository: https://hub.docker.com/r/harisekhon/hbase/tags Recommended image: harisekhon/hbase, supporting multiple versions (latest supports HBase2.1.3).

Pull latest version

docker pull harisekhon/hbase:latest

Pull a specific version

docker pull harisekhon/hbase:1.4

3. Running the Container

After Docker is installed, run the following command:

docker run -d -h docker-hbase \
    -p 2181:2181 \
    -p 8080:8080 \
    -p 8085:8085 \
    -p 9090:9090 \
    -p 9000:9000 \
    -p 9095:9095 \
    -p 16000:16000 \
    -p 16010:16010 \
    -p 16201:16201 \
    -p 16301:16301 \
    -p 16020:16020 \
    --name hbase \
    harisekhon/hbase

Configure the server's /etc/hosts file: 127.0.0.1 docker-hbase Configure the local /etc/hosts similarly:

server_ip docker-hbase

4. HBase Operations

4.1 Access HBase Web UI

http://docker-hbase:16010/master-status

4.2 Use HBase Shell

List running containers: docker ps Enter the container (replace <container ID> with the actual ID): docker exec -it <container ID> bash Start the HBase shell inside the container: hbase shell Example shell commands:

create 'test-docker','f'
list

4.3 Access Zookeeper

Exit the container and run: hbase zkcli List Zookeeper nodes:

ls /

4.4 Java API Test

public class HBaseHelper {
    public static String ZK_QUORUM = "docker-hbase";
    public static String ZK_ZNODE = "/hbase";
    public static String ZK_PORT = "2181";
    public static String SUPER_USER = "hbase";
    // Configure connection information
    public Configuration getConfiguration() {
        Configuration conf = HBaseConfiguration.create();
        conf.set("hbase.zookeeper.quorum", ZK_QUORUM);
        conf.set("zookeeper.znode.parent", ZK_ZNODE);
        conf.set("hbase.zookeeper.property.clientPort", ZK_PORT);
        return conf;
    }
    ...
}

The full demo code is available at:

https://github.com/zhoupengbo/demos-bigdata/tree/master/hbase/hbase-docker-demo
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

DockerdatabaseHBaseTutorial
Big Data Technology Architecture
Written by

Big Data Technology Architecture

Exploring Open Source Big Data and AI Technologies

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.