Skip to main content

Hbase usage samples

hbase shell

hbase(main):003:0> create 'test', 'cf'
0 row(s) in 1.2200 seconds

hbase(main):003:0> list 'test'
..
1 row(s) in 0.0550 seconds

hbase(main):004:0> put 'test', 'row1', 'cf:a', 'value1'
0 row(s) in 0.0560 seconds

hbase(main):005:0> put 'test', 'row2', 'cf:b', 'value2'
0 row(s) in 0.0370 seconds

hbase(main):006:0> put 'test', 'row3', 'cf:c', 'value3'
0 row(s) in 0.0450 seconds

hbase(main):007:0> scan 'test'
ROW        COLUMN+CELL
row1       column=cf:a, timestamp=1288380727188, value=value1
row2       column=cf:b, timestamp=1288380738440, value=value2
row3       column=cf:c, timestamp=1288380747365, value=value3
3 row(s) in 0.0590 seconds

Get a single row
hbase(main):008:0> get 'test', 'row1'
COLUMN      CELL
cf:a        timestamp=1288380727188, value=value1
1 row(s) in 0.0400 seconds

hbase(main):012:0> disable 'test'
0 row(s) in 1.0930 seconds
hbase(main):013:0> drop 'test'
0 row(s) in 0.0770 seconds


hbase(main):004:0* scan 'test', {COLUMNS => ['cf:a']}
ROW                                                    COLUMN+CELL                                                                                                                                                 
 row1                                                  column=cf:a, timestamp=1369307716818, value=value1                                                                                                          
1 row(s) in 0.1230 seconds

hbase(main):005:0> scan 'test', {COLUMNS => 'cf:a', TIMERANGE => [1369307716900, 1369307716910]}
ROW                                                    COLUMN+CELL                                                                                                                                                 
 row1                                                  column=cf:a, timestamp=1369307716818, value=value1                                                                                                          
1 row(s) in 0.0650 seconds

hbase(main):006:0> scan 'test', {COLUMNS => 'cf:a', TIMERANGE => [1369307716900, 1369307716910]}
ROW                                                    COLUMN+CELL                                                                                                                                                 
0 row(s) in 0.0260 seconds



hbase(main):004:0> count 'test'
2 row(s) in 0.0070 seconds


hbase(main):007:0> create 't1', {NAME => 'f1'}, {NAME => 'f2'}, {NAME => 'f3'}
0 row(s) in 1.3320 seconds

=> Hbase::Table - t1


hbase(main):013:0> put 't1', 'r1', 'f1', 'value'
0 row(s) in 0.0600 seconds

hbase(main):014:0> scan 't1'
ROW                                                    COLUMN+CELL                                                                                                                                                 
 r1                                                    column=f1:, timestamp=1369310510758, value=value                                                                                                            
1 row(s) in 0.0180 seconds

hbase(main):015:0> put 't1', 'r1', 'f1:a', 'value'
0 row(s) in 0.0070 seconds

hbase(main):016:0> scan 't1'
ROW                                                    COLUMN+CELL                                                                                                                                                 
 r1                                                    column=f1:, timestamp=1369310510758, value=value                                                                                                            
 r1                                                    column=f1:a, timestamp=1369310547264, value=value                                                                                                           
1 row(s) in 0.0120 seconds

hbase(main):017:0> put 't1', 'r1', 'f1:b', 'value'
0 row(s) in 0.0060 seconds

hbase(main):018:0> scan 't1'
ROW                                                    COLUMN+CELL                                                                                                                                                 
 r1                                                    column=f1:, timestamp=1369310510758, value=value                                                                                                            
 r1                                                    column=f1:a, timestamp=1369310547264, value=value                                                                                                           
 r1                                                    column=f1:b, timestamp=1369310565203, value=value                                                                                                           
1 row(s) in 0.0140 seconds


hbase(main):020:0> put 't1', 'r1', 'f2', 'value'
0 row(s) in 0.0150 seconds

hbase(main):021:0> scan 't1'
ROW                                                    COLUMN+CELL                                                                                                                                                 
 r1                                                    column=f1:, timestamp=1369310510758, value=value                                                                                                            
 r1                                                    column=f1:a, timestamp=1369310547264, value=value                                                                                                           
 r1                                                    column=f1:b, timestamp=1369310565203, value=value                                                                                                           
 r1                                                    column=f2:, timestamp=1369310595376, value=value                                                                                                            
1 row(s) in 0.0150 seconds

hbase(main):022:0> put 't1', 'r1', 'f1:b', 'value'
0 row(s) in 0.0240 seconds

hbase(main):023:0> scan 't1'
ROW                                                    COLUMN+CELL                                                                                                                                                 
 r1                                                    column=f1:, timestamp=1369310510758, value=value                                                                                                            
 r1                                                    column=f1:a, timestamp=1369310547264, value=value                                                                                                           
 r1                                                    column=f1:b, timestamp=1369310610728, value=value                                                                                                           
 r1                                                    column=f2:, timestamp=1369310595376, value=value                                                                                                            
1 row(s) in 0.0150 seconds


hbase(main):025:0> scan 't1', {COLUMNS => ['f1:a']}
ROW                                                    COLUMN+CELL                                                                                                                                                 
 r1                                                    column=f1:a, timestamp=1369310547264, value=value                                                                                                           
1 row(s) in 0.0250 seconds

hbase(main):026:0> scan 't1', {COLUMNS => ['f1:']}
ROW                                                    COLUMN+CELL                                                                                                                                                 
 r1                                                    column=f1:, timestamp=1369310510758, value=value                                                                                                            
 r1                                                    column=f1:a, timestamp=1369310547264, value=value                                                                                                           
 r1                                                    column=f1:b, timestamp=1369310610728, value=value                                                                                                           
1 row(s) in 0.0340 seconds

hbase(main):027:0> scan 't1', {COLUMNS => ['f1']}
ROW                                                    COLUMN+CELL                                                                                                                                                 
 r1                                                    column=f1:, timestamp=1369310510758, value=value                                                                                                            
 r1                                                    column=f1:a, timestamp=1369310547264, value=value                                                                                                           
 r1                                                    column=f1:b, timestamp=1369310610728, value=value                                                                                                           
1 row(s) in 0.0090 seconds


scan 't1', {COLUMNS => ['f1', 'f2'], LIMIT => 10, \
             STARTROW => 'r1'}
ROW                                                    COLUMN+CELL                                                                                                                                                 
 r1                                                    column=f1:, timestamp=1369310510758, value=value                                                                                                            
 r1                                                    column=f1:a, timestamp=1369310547264, value=value                                                                                                           
 r1                                                    column=f1:b, timestamp=1369310610728, value=value                                                                                                           
 r1                                                    column=f2:, timestamp=1369310595376, value=value                                                                                                            
1 row(s) in 0.0170 seconds
            
            
hbase(main):033:0> scan 't1', {COLUMNS => ['f1', 'f2'], LIMIT => 10, STARTROW => 'r1'}   
ROW                                                    COLUMN+CELL                                                                                                                                                 
 r1                                                    column=f1:, timestamp=1369310510758, value=value                                                                                                            
 r1                                                    column=f1:a, timestamp=1369310547264, value=value                                                                                                           
 r1                                                    column=f1:b, timestamp=1369310610728, value=value                                                                                                           
 r1                                                    column=f2:, timestamp=1369310595376, value=value                                                                                                            
1 row(s) in 0.0170 seconds


hbase(main):039:0> status
4 servers, 0 dead, 1.0000 average load



hbase(main):040:0> status 'simple'
4 live servers
    hadoop-yarn2.mydomain.com:60020 1369297397823
        requestsPerSecond=0, numberOfOnlineRegions=2, usedHeapMB=39, maxHeapMB=287
    hadoop-yarn3.mydomain.com:60020 1369297396938
        requestsPerSecond=0, numberOfOnlineRegions=0, usedHeapMB=25, maxHeapMB=287
    hadoop-yarn4.mydomain.com:60020 1369297397877
        requestsPerSecond=0, numberOfOnlineRegions=1, usedHeapMB=41, maxHeapMB=287
    hadoop-yarn1.mydomain.com:60020 1369297417598
        requestsPerSecond=0, numberOfOnlineRegions=1, usedHeapMB=40, maxHeapMB=97
0 dead servers
Aggregate load: 0, regions: 4




            


create 't2', 'cf2', \
{ SPLITS => ['row-300', 'row-500', 'row-700' , 'row-900'] }


hbase(main):010:0> for i in '0'..'9' do \
                   for j in '0'..'9' do \
                   for k in '0'..'9' do \
                   put 't2', "row-#{i}#{j}#{k}", \
                   "cf2:#{j}#{k}", "#{j}#{k}" \
                   end end end


hbase(main):019:0> count 't2'
Current count: 1000, row: row-999                                                                                                                                                                                  
1000 row(s) in 0.4310 seconds

hbase(main):010:0> flush 't2'


hadoop dfs -lsr /hbase
hadoop dfs -cat /hbase/hbase.id
hadoop dfs -cat /hbase/hbase.version


hbase(main):010:0> for i in '0'..'1000000' do \
                   put 't2', "row-#{i}", \
                   "cf2:#{i}", "#{i}" \
                   end

Comments

Popular posts from this blog

Offline AI Coding in VSCode: Continue + Ollama Complete Setup Guide

Want GitHub Copilot-level code assistance — but fully offline, air-gapped, and private? This guide walks you through setting up Continue (a VSCode extension) with Ollama (a local model runner) so you get chat, autocomplete, and inline editing powered entirely by models running on your own machine. No internet required at runtime. Table of Contents What Are Continue and Ollama? Prerequisites & Hardware Requirements Choosing the Right Models Step 1 — Installing Ollama & Pulling Models Step 2 — Installing Continue in VSCode (Offline) Step 3 — Configuring config.yaml Step 4 — Disabling Telemetry Step 5 — Usage & Shortcuts Troubleshooting What Are Continue and Ollama? Continue is an open-source VSCode (and JetBrains) extension that adds AI-powered coding features directly into your editor — think chat, inline edits, and tab autocomplete. By default it can connect to Claude, GPT-4, or any API. But it also supports local providers , which is exactly what we want here. Ollama i...

Local LLM on Ubuntu (CPU-Only): Ollama + Qwen Coder + Open WebUI + RAG Setup

Local LLM on Ubuntu (CPU-Only): Ollama + Qwen Coder + Open WebUI + RAG Run a private, high-performance internal AI coding assistant on your own hardware—no GPU required. Feb 13, 2026 Qwen 2.5 Coder RAG Enabled Enterprise Ready Keeping your code and documents on your own infrastructure is the gold standard for enterprise security. By combining Ollama , Qwen Coder , and Open WebUI , we can build a production-grade AI assistant that respects your privacy. Environment: CPU-only Ubuntu server (e.g., i9/Threadripper) with 64GB+ RAM for smooth 14B model inference. 1. System Preparation First, update your local environment and install necessary dependencies: sudo apt update && sudo apt upgrade -y sudo apt install -y curl git ca-certificates lscpu 2. Ollama & Model Tuning Install Ollama and optimize the configuration for CPU-only inference by setting the thread count: ...

Defining tomcat and mysql server Amazon EC2 instance

-- Create new amazon ec2 instance http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EC2_GetStarted.html -- Give permisson to pem file chmod 400 mycertificate.pem -- Connect to EC2 instance ssh -i mycertificate.pem ubuntu@ec2-51-51-51-51.eu-west-1.compute.amazonaws.com -- Installation Oracle Java 1.8 $ wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u92-b14/jdk-8u92-linux-x64.tar.gz $ tar -xzvf jdk-8u92-linux-x64.tar.gz $ sudo mkdir -p /usr/java/ $ sudo mv jdk1.8.0_92/ /usr/java/ $ sudo vim  /etc/profile         JAVA_HOME=/usr/java/jdk1.8.0_92         PATH=$PATH:$HOME/bin:$JAVA_HOME/bin         JRE_HOME=/usr/java/jdk1.8.0_92/jre         PATH=$PATH:$HOME/bin:$JRE_HOME/bin         export JAVA_HOME...