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.
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/installSupported 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:latestPull a specific version
docker pull harisekhon/hbase:1.43. 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/hbaseConfigure the server's /etc/hosts file: 127.0.0.1 docker-hbase Configure the local /etc/hosts similarly:
server_ip docker-hbase4. HBase Operations
4.1 Access HBase Web UI
http://docker-hbase:16010/master-status4.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'
list4.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-demoSigned-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Big Data Technology Architecture
Exploring Open Source Big Data and AI Technologies
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
