發表文章

hbase shell (1)

要存取hbase, 最簡單的方法就是透過hbase shell, hbase shell是hbase內建的存取介面, 透過即時的命令輸入, 可以操作hbase中資料表的操作, 我們以hbase 0.94版本為例, 介紹hbase shell的功能: 首先, 我們先確認hbase和hadoop的程式都仍在執行, 接著, 進入hbase的路徑(/opt/hbase), 進入hbase shell: $ /opt/hbase/bin/hbase shell 進入hbase shell後, 我們先輸入help查看說明: hbase(main):003:0> help HBase Shell, version 0.94.2, r1395367, Sun Oct  7 19:11:01 UTC 2012 Type 'help "COMMAND"', (e.g. 'help "get"' -- the quotes are necessary) for help on a specific command. Commands are grouped. Type 'help "COMMAND_GROUP"', (e.g. 'help "general"') for help on a command group. COMMAND GROUPS:   Group name: general   Commands: status, version, whoami   Group name: ddl   Commands: alter, alter_async, alter_status, create, describe, disable, disable_all, drop, drop_all, en  able, enable_all, exists, is_disabled, is_enabled, list, show_filters   Group name: dml   Commands: count, delete, deleteall, get, get_counter,...

thrift api 使用: HTML

在這一篇文章中, 我們將介紹如何使用HTML透過PHP讀取hbase, 我們安裝的目錄結構為: hadoop                     /opt/hadoop hbase                        /opt/hbase 網頁根目錄             /var/www/ hbase的php目錄      /var/www/hbase thrift php                  /var/www/hbase/thrift php存放目錄           /var/www/php 測試程式之前,請先確定hbase , hadoop 都有正常運作中 $ bin/hbase thrift start 尚在執行 以下是我們的範例程式(example.php):     <!DOCTYPE html>     <html>     <meta charset="utf-8">     <head>     <script>     function getUser()     {     if(window.XMLHttpRequest)     {         xmlhttp = new XMLHttpRequest();         if(xmlhttp != null)     ...

thrift api 使用: PHP

在 上一篇 文章中, 提及thrift server的建立與存取, 在這一篇文章中, 將介紹如何透過thrift存取hbase資料, 類似的內容,  waue0920 已經寫下詳細的紀錄, 因此, 我們將跟隨相同的架構, 並補充一些內容, 我們安裝的目錄結構為: hadoop                     /opt/hadoop hbase                        /opt/hbase 網頁根目錄             /var/www/ hbase的php目錄 /var/www/hbase thrift php                  /var/www/hbase/thrift 測試程式之前,請先確定hbase , hadoop 都有正常運作中 $ bin/hbase thrift start 尚在執行 以下是這次範例程式(example.php) <?php $GLOBALS['THRIFT_ROOT'] = '/var/www/hbase/thrift'; require_once( $GLOBALS['THRIFT_ROOT'].'/Thrift.php' ); require_once( $GLOBALS['THRIFT_ROOT'].'/transport/TSocket.php' ); require_once( $GLOBALS['THRIFT_ROOT'].'/transport/TBufferedTransport.php' ); require_once( $GLOBALS['THRIFT_ROOT'].'/protocol/TBinaryProtocol.php' ); require_once( $GLOBALS['THRIFT_ROOT'].'/pa...

hbase java api 介紹 (1)

在之前, 我們介紹 如何編譯hbase-client程式 時, 曾經放上一段程式碼作為範例, 然而, 該程式碼需要預先建立好一個hbase table (myHBaseTable), 並且在myHBaseTable中, 建立一個column: myFamily, 在今天的範例中, 我們將擴展這個例子, 從建立table開始, 都由hbase java api負責, 以下是程式: import java.io.*; import java.net.*; import java.util.*; import java.lang.*; import org.apache.hadoop.hbase.*; import org.apache.hadoop.hbase.client.*; import org.apache.hadoop.hbase.util.*; import org.apache.hadoop.conf.Configuration; public class hbasetest {     public static Configuration conf;     static {         conf = HBaseConfiguration.create();         conf.set("hbase.zookeeper.property.clientPort", "2222");         conf.set("hbase.zookeeper.quorum", "hbasemaster");     }     public static void main(String[] args) throws IOException {         HBaseAdmin admin = new HBaseAdmin(conf);         // create a hbase table   ...

hbase 0.94 + thrift 0.7.0 安裝 (2)

之前介紹了thrift的 安裝 , 在這裡要特別提醒的是, thrift有版本相容問題, 以作者的測試經驗, 0.9.1和0.9.2版的thrift都和hbase 0.94不相容, 不相容的地方主要在於library的位置, 以及name space的支援, 若是使用較新版本的thrift, 可能要自行更改一些變數設定,

hbase 0.94 + thrift 0.7.0 安裝 (1)

在 上一篇 文章中, 我們介紹了如何用java來存取hbase叢集, 在這一文章中, 我們介紹如何建立thrift的環境, 要注意的是: 這一篇文章是以hbase 0.94作為範例, 在其他版本(0.96)上是否需要其他設定, 則需要再試看看, 考慮到hbase原生只支援java與shell方式存取, 對於其他程式語言, 尤其是網頁界面而言, 就成了很大的障礙, thrift就提供了解決方案, 讓像是PHP的網頁語言也可以使用,

hbase-client java 程式的編譯與執行

完成hbase從即架設之後, 接下來, 就要利用hbase來存取資料, 在hbase的架構中, 原生的存取方式有三種: thrift, java program 以及 hbase shell, 在這篇文章中, 我們假設hbase中已經有一個myHBaseTable, 在myHBaseTable中, 只有一個column: myFamily, 接著, 我們想執行以下的程式: import java.io.IOException; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.client.Get; import org.apache.hadoop.hbase.client.HTable; import org.apache.hadoop.hbase.client.Put; import org.apache.hadoop.hbase.client.Result; import org.apache.hadoop.hbase.client.ResultScanner; import org.apache.hadoop.hbase.client.Scan; import org.apache.hadoop.hbase.util.Bytes; public class hbasetest {     public static Configuration conf;     static {         conf = HBaseConfiguration.create();         conf.set("hbase.zookeeper.property.clientPort", "2222");         conf.set("hbase.zookeeper.quorum", "master.hbase.mbwcl.nctu.edu.tw");     }     public static void m...