日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

hbase开发环境搭建及运行hbase小实例(HBase 0.98.3新api)

發布時間:2025/6/15 编程问答 14 豆豆
生活随笔 收集整理的這篇文章主要介紹了 hbase开发环境搭建及运行hbase小实例(HBase 0.98.3新api) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

問題導讀:
1.如何搭建hbase開發環境?
2.HTableDescriptor初始化產生了那些變化?
3.eclipse如何連接hbase集群?





hbase開發環境搭建與hadoop開發環境搭建差不多的。這里是以win7為例。
首先我們看一下hadoop的開發環境搭建,參考

hadoop開發方式總結及操作指導
http://www.aboutyun.com/thread-6950-1-1.html
,這里講了兩個方式,一種是用插件,另外一種是不是用插件。
那么對于hbase的開發環境是什么樣子的,該如何搭建?
我們采用的是添加包的方式。
首先需要下載安裝包:

1.安裝包下載


可以通過官網下載:
http://mirror.bit.edu.cn/apache/hbase/hbase-0.98.3/

?


百度網盤下載:
hbase-0.98.3-hadoop2-bin.tar.gz
鏈接:http://pan.baidu.com/s/1mguTsRu?密碼:xlhc


2.添加包

(1)我們解壓包
解壓之后,得到如下包
?


(2)添加包
添加包的操作

?

如上圖5個步驟:
單擊hbase-》屬性彈出(2所示)Properties for hbase屬性對話框.

然后我們通過下標5,單擊Add External JARs。
找到hbase_home/lib,我這里是D:\hadoop2\hbase-0.98.3-hadoop2\lib

?


添加完畢,這樣開發環境就搭建完畢。





搭建完畢,我們先做個簡單的例子吧
就創建一個blog表。
1.首先通過list命令查看表

?



2.我們運行下面程序:

運行通過下面操作方式:
?


package?www.aboutyun.com.hbase;

import java.io.IOException;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.client.HBaseAdmin;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.util.Bytes;

public class OperateTable {
? ?? ?? ?public static void main(String[] args) throws IOException {
? ?? ?? ?
? ?? ?? ?Configuration conf = HBaseConfiguration.create();
? ?? ????conf.set("hbase.zookeeper.quorum", "master");//使用eclipse時必須添加這個,否則無法定位
? ?? ?? ?conf.set("hbase.zookeeper.property.clientPort", "2181");
? ?? ?? ?HBaseAdmin admin = new HBaseAdmin(conf);// 新建一個數據庫管理員//新api
? ?? ?? ?HTableDescriptor desc=new HTableDescriptor(TableName.valueOf("blog"));
? ?? ?? ?//HTableDescriptor desc = new HTableDescriptor("blog");
? ?? ?? ?desc.addFamily(new HColumnDescriptor("article"));
? ?? ?? ?desc.addFamily(new HColumnDescriptor("author"));
? ?? ?? ?admin.createTable(desc );
? ?? ?? ?admin.close();
? ?? ?? ?//admin.disableTable("blog");
? ?? ?? ?//admin.deleteTable("blog");
? ?? ?? ?//assertThat(admin.tableExists("blog"),is(false));
? ?}
}
得到結果:我們看到blog就創建成功了。

?

這里說一下:
HTableDescriptor的初始化發生變化:
?

新API
??HTableDescriptor desc=new HTableDescriptor(TableName.valueOf("blog"));
舊API
??HTableDescriptor desc = new HTableDescriptor("blog");






更多編程內容參考:

Java操作hbase編程
http://www.aboutyun.com/thread-7075-1-1.html


spark使用java讀取hbase數據做分布式計算
http://www.aboutyun.com/thread-8242-1-1.html

hbase編程:通過Java api操作hbase
http://www.aboutyun.com/thread-7151-1-1.html

hbase HTable之Put、delete、get等源碼分析
http://www.aboutyun.com/thread-7644-1-1.html

Hbase Java編程實現增刪改查
http://www.aboutyun.com/thread-6901-1-1.html

總結Eclipse 遠程連接 HBase問題及解決方案大全
http://www.aboutyun.com/thread-5866-1-1.html

HBase中如何開發LoadBalance插件
http://www.aboutyun.com/thread-8350-1-1.html

Hbase與eclipse集成的第一個例子
http://www.aboutyun.com/thread-7837-1-1.html

hbase分頁應用場景及分頁思路與代碼實現
http://www.aboutyun.com/thread-7030-1-1.html


HBase MapReduce排序Secondary Sort
http://www.aboutyun.com/thread-7304-1-1.html


CDH4源碼搭建hbase開發環境
http://www.aboutyun.com/thread-7259-1-1.html

Thrift了解4:C#通過Thrift操作HBase實戰
http://www.aboutyun.com/thread-7142-1-1.html




hbase API

hadoop2.2.0幫助手冊下載API及HBase 0.98.1-hadoop2 API
http://www.aboutyun.com/thread-6113-1-1.html

HBase數據遷移(1)-使用HBase的API中的Put方法
http://www.aboutyun.com/thread-8336-1-1.html


hbase編程:Java API連接Hbase進行增刪改查講解實例
http://www.aboutyun.com/thread-8290-1-1.html

總結

以上是生活随笔為你收集整理的hbase开发环境搭建及运行hbase小实例(HBase 0.98.3新api)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。