开发环境:
hadoop: hadoop-1.1.2
hbase: hbase-0.94.11-security
eclipse:Juno Service Release 2
配置Eclipse
通过 Eclipse 创建一个新 Java 工程,右击项目根目录,选择“Properties> Java Build Path> Library> Add External JARs”,将 HBase 安装文件解压后根目录下的hbase-0.94.11-security.jar、hbase-0.94.11-security-tests.jar 和 lib 子目录下所有的 jar 包添加到本工程的 Build Path下。
示例一:输出表“users”的列族名称
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.util.Bytes; public class ExampleClient {
public static void main(String[] args) throws IOException { Configuration conf = HBaseConfiguration.create();
conf.set("hbase.zookeeper.quorum", "master");
conf.set("hbase.zookeeper.property.clientPort", "2181");
HBaseAdmin admin = new HBaseAdmin(conf);
HTableDescriptor tableDescriptor = admin.getTableDescriptor(Bytes.toBytes("users"));
byte[] name = tableDescriptor.getName();
System.out.println("result:"); System.out.println("table name: "+ new String(name));
HColumnDescriptor[] columnFamilies = tableDescriptor
.getColumnFamilies();
for(HColumnDescriptor d : columnFamilies){
System.out.println("column Families: "+ d.getNameAsString());
}
}
}
结果:
2013-09-09 15:58:51,890 WARN conf.Configuration (Configuration.java:<clinit>(195)) - DEPRECATED: hadoop-site.xml found in the classpath. Usage of hadoop-site.xml is deprecated. Instead use core-site.xml, mapred-site.xml and hdfs-site.xml to override properties of core-default.xml, mapred-default.xml and hdfs-default.xml respectively
2013-09-09 15:58:55,031 INFO zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:zookeeper.version=3.4.5-1392090, built on 09/30/2012 17:52 GMT
2013-09-09 15:58:55,031 INFO zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:host.name=w253245.ppp.asahi-net.or.jp
2013-09-09 15:58:55,031 INFO zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:java.version=1.6.0_10-rc2
2013-09-09 15:58:55,031 INFO zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:java.vendor=Sun Microsystems Inc.
2013-09-09 15:58:55,031 INFO zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:java.home=C:\Java\jre6
2013-09-09 15:58:55,031 INFO zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:java.class.path=D:\workspace\Eclipse-jee\Hadoop_APPs_U_tht\bin;D:\workspace\Eclipse-jee\hadoop-1.1.2\build\eclipse\classes-main;D:\workspace\Eclipse-jee\hadoop-1.1.2\build\eclipse\classes-test;D:\workspace\Eclipse-jee\hadoop-1.1.2\build\eclipse\classes-test-generated;D:\workspace\Eclipse-jee\hadoop-1.1.2\build\eclipse\classes-tools;D:\workspace\Eclipse-jee\hadoop-1.1.2\build\eclipse\classes-example;C:\apache-ant-1.9.2\lib\ant.jar;D:\workspace\Eclipse-jee\hadoop-1.1.2\lib\asm-3.2.jar;D:\workspace\Eclipse-jee\hadoop-1.1.2\lib\aspectjrt-1.6.11.jar;D:\workspace\Eclipse-jee\hadoop-1.1.2\lib\aspectjtools-1.6.11.jar;D:\workspace\Eclipse-jee\hadoop-1.1.2\lib\commons-beanutils-1.7.0.jar;D:\workspace\Eclipse-jee\hadoop-1.1.2\lib\commons-beanutils-core-1.8.0.jar;D:\workspace\Eclipse-jee\hadoop-1.1.2\lib\commons-cli-1.2.jar;D:\workspace\Eclipse-jee\hadoop-1.1.2\lib\commons-codec-1.4.jar;D:\workspace\Eclipse-jee\hadoop-1.1.2\lib\commons-collections-3.2.1.jar;D:\workspace\Eclipse-jee\hadoop-1.1.2\lib\commons-configuration-1.6.jar;D:\workspace\Eclipse-jee\hadoop-1.1.2\lib\commons-daemon-1.0.1.jar;D:\workspace\Eclipse-jee\hadoop-1.1.2\lib\commons-digester-1.8.jar;D:\workspace\Eclipse-jee\hadoop-1.1.2\lib\commons-el-1.0.jar;D:\workspace\Eclipse-jee\hadoop-1.1.2\lib\commons-httpclient-3.0.1.jar;D:\workspace\Eclipse-jee\hadoop-1.1.2\lib\commons-io-2.1.jar;D:\workspace\Eclipse-jee\hadoop-1.1.2\lib\commons-lang-2.4.jar;D:\workspace\Eclipse-jee\hadoop-1.1.2\lib\commons-logging-1.1.1.jar;D:\workspace\Eclipse-jee\hadoop-1.1.2\lib\commons-logging-api-1.0.4.jar;D:\workspace\Eclipse-jee\hadoop-1.1.2\lib\commons-math-2.1.jar;D:\workspace\Eclipse-jee\hadoop-1.1.2\lib\commons-net-3.1.jar;D:\workspace\Eclipse-jee\hadoop-1.1.2\lib\core-3.1.1.jar;D:\workspace\Eclipse-jee\hadoop-1.1.2\lib\hadoop-capacity-scheduler-1.1.2.jar;D:\workspace\Eclipse-jee\hadoop-1.1.2\lib\hadoop-fairscheduler-1.1.2.jar;D:\workspace\Eclipse-jee\hadoop-1.1.2\lib\hadoop-thriftfs-1.1.2.jar;D:\workspace\Eclipse-jee\hadoop-1.1.2\lib\hsqldb-1.8.0.10.jar;D:\workspace\Eclipse-jee\hadoop-1.1.2\lib\jackson-core-asl-1.8.8.jar;D:\workspace\Eclipse-jee\hadoop-1.1.2\lib\jackson-mapper-asl-1.8.8.jar;D:\workspace\Eclipse-jee\hadoop-1.1.2\lib\jasper-compiler-5.5.12.jar;D:\workspace\Eclipse-jee\hadoop-1.1.2\lib\jasper-runtime-5.5.12.jar;D:\workspace\Eclipse-jee\hadoop-1.1.2\lib\jdeb-0.8.jar;D:\workspace\Eclipse-jee\hadoop-1.1.2\lib\jersey-core-1.8.jar;D:\workspace\Eclipse-jee\hadoop-1.1.2\lib\jersey-json-1.8.jar;D:\workspace\Eclipse-jee\hadoop-1.1.2\lib\jersey-server-1.8.jar;D:\workspace\Eclipse-jee\hadoop-1.1.2\lib\jets3t-0.6.1.jar;D:\workspace\Eclipse-jee\hadoop-1.1.2\lib\jetty-6.1.26.jar;D:\workspace\Eclipse-jee\hadoop-1.1.2\lib\jetty-util-6.1.26.jar;D:\workspace\Eclipse-jee\hadoop-1.1.2\lib\jsch-0.1.42.jar;D:\workspace\Eclipse-jee\hadoop-1.1.2\lib\jsp-2.1\jsp-2.1.jar;D:\workspace\Eclipse-jee\hadoop-1.1.2\lib\jsp-2.1\jsp-api-2.1.jar;D:\workspace\Eclipse-jee\hadoop-1.1.2\lib\junit-4.5.jar;D:\workspace\Eclipse-jee\hadoop-1.1.2\lib\kfs-0.2.2.jar;D:\workspace\Eclipse-jee\hadoop-1.1.2\lib\log4j-1.2.15.jar;D:\workspace\Eclipse-jee\hadoop-1.1.2\lib\mockito-all-1.8.5.jar;D:\workspace\Eclipse-jee\hadoop-1.1.2\lib\oro-2.0.8.jar;D:\workspace\Eclipse-jee\hadoop-1.1.2\lib\servlet-api-2.5-20081211.jar;D:\workspace\Eclipse-jee\hadoop-1.1.2\lib\slf4j-api-1.4.3.jar;D:\workspace\Eclipse-jee\hadoop-1.1.2\lib\slf4j-log4j12-1.4.3.jar;D:\workspace\Eclipse-jee\hadoop-1.1.2\lib\xmlenc-0.52.jar;D:\workspace\Eclipse-jee\hadoop-1.1.2\src\test\lib\ftplet-api-1.0.0-SNAPSHOT.jar;D:\workspace\Eclipse-jee\hadoop-1.1.2\src\test\lib\ftpserver-core-1.0.0-SNAPSHOT.jar;D:\workspace\Eclipse-jee\hadoop-1.1.2\src\test\lib\ftpserver-server-1.0.0-SNAPSHOT.jar;D:\workspace\Eclipse-jee\hadoop-1.1.2\src\test\lib\mina-core-2.0.0-M2-20080407.124109-12.jar;D:\workspace\Eclipse-jee\hadoop-1.1.2\conf;D:\workspace\Eclipse-jee\hadoop-1.1.2\build\eclipse\test-resources;D:\workspace\Eclipse-jee\Hadoop_APPs_U_tht\build\activation-1.1.jar;D:\workspace\Eclipse-jee\Hadoop_APPs_U_tht\build\asm-3.1.jar;D:\workspace\Eclipse-jee\Hadoop_APPs_U_tht\build\avro-1.5.3.jar;D:\workspace\Eclipse-jee\Hadoop_APPs_U_tht\build\avro-1.7.4.jar;D:\workspace\Eclipse-jee\Hadoop_APPs_U_tht\build\avro-ipc-1.5.3.jar;D:\workspace\Eclipse-jee\Hadoop_APPs_U_tht\build\commons-beanutils-1.7.0.jar;D:\workspace\Eclipse-jee\Hadoop_APPs_U_tht\build\commons-beanutils-core-1.8.0.jar;D:\workspace\Eclipse-jee\Hadoop_APPs_U_tht\build\commons-cli-1.2.jar;D:\workspace\Eclipse-jee\Hadoop_APPs_U_tht\build\commons-codec-1.4.jar;D:\workspace\Eclipse-jee\Hadoop_APPs_U_tht\build\commons-collections-3.2.1.jar;D:\workspace\Eclipse-jee\Hadoop_APPs_U_tht\build\commons-configuration-1.6.jar;D:\workspace\Eclipse-jee\Hadoop_APPs_U_tht\build\commons-digester-1.8.jar;D:\workspace\Eclipse-jee\Hadoop_APPs_U_tht\build\commons-el-1.0.jar;D:\workspace\Eclipse-jee\Hadoop_APPs_U_tht\build\commons-httpclient-3.1.jar;D:\workspace\Eclipse-jee\Hadoop_APPs_U_tht\build\commons-io-2.1.jar;D:\workspace\Eclipse-jee\Hadoop_APPs_U_tht\build\commons-lang-2.5.jar;D:\workspace\Eclipse-jee\Hadoop_APPs_U_tht\build\commons-logging-1.1.1.jar;D:\workspace\Eclipse-jee\Hadoop_APPs_U_tht\build\commons-math-2.1.jar;D:\workspace\Eclipse-jee\Hadoop_APPs_U_tht\build\commons-net-1.4.1.jar;D:\workspace\Eclipse-jee\Hadoop_APPs_U_tht\build\core-3.1.1.jar;D:\workspace\Eclipse-jee\Hadoop_APPs_U_tht\build\guava-11.0.2.jar;D:\workspace\Eclipse-jee\Hadoop_APPs_U_tht\build\hadoop-common-0.23.9-javadoc.jar;D:\workspace\Eclipse-jee\Hadoop_APPs_U_tht\build\hamcrest-all-1.3.jar;D:\workspace\Eclipse-jee\Hadoop_APPs_U_tht\build\hamcrest-core-1.3.jar;D:\workspace\Eclipse-jee\Hadoop_APPs_U_tht\build\hbase-0.94.11-security.jar;D:\workspace\Eclipse-jee\Hadoop_APPs_U_tht\build\hbase-0.94.11-security-tests.jar;D:\workspace\Eclipse-jee\Hadoop_APPs_U_tht\build\high-scale-lib-1.1.1.jar;D:\workspace\Eclipse-jee\Hadoop_APPs_U_tht\build\httpclient-4.1.2.jar;D:\workspace\Eclipse-jee\Hadoop_APPs_U_tht\build\httpcore-4.1.3.jar;D:\workspace\Eclipse-jee\Hadoop_APPs_U_tht\build\jackson-core-asl-1.8.8.jar;D:\workspace\Eclipse-jee\Hadoop_APPs_U_tht\build\jackson-jaxrs-1.8.8.jar;D:\workspace\Eclipse-jee\Hadoop_APPs_U_tht\build\jackson-mapper-asl-1.8.8.jar;D:\workspace\Eclipse-jee\Hadoop_APPs_U_tht\build\jackson-xc-1.8.8.jar;D:\workspace\Eclipse-jee\Hadoop_APPs_U_tht\build\jamon-runtime-2.3.1.jar;D:\workspace\Eclipse-jee\Hadoop_APPs_U_tht\build\jasper-compiler-5.5.23.jar;D:\workspace\Eclipse-jee\Hadoop_APPs_U_tht\build\jasper-runtime-5.5.23.jar;D:\workspace\Eclipse-jee\Hadoop_APPs_U_tht\build\jaxb-api-2.1.jar;D:\workspace\Eclipse-jee\Hadoop_APPs_U_tht\build\jaxb-impl-2.2.3-1.jar;D:\workspace\Eclipse-jee\Hadoop_APPs_U_tht\build\jersey-core-1.8.jar;D:\workspace\Eclipse-jee\Hadoop_APPs_U_tht\build\jersey-json-1.8.jar;D:\workspace\Eclipse-jee\Hadoop_APPs_U_tht\build\jersey-server-1.8.jar;D:\workspace\Eclipse-jee\Hadoop_APPs_U_tht\build\jettison-1.1.jar;D:\workspace\Eclipse-jee\Hadoop_APPs_U_tht\build\jetty-6.1.26.jar;D:\workspace\Eclipse-jee\Hadoop_APPs_U_tht\build\jetty-util-6.1.26.jar;D:\workspace\Eclipse-jee\Hadoop_APPs_U_tht\build\jruby-complete-1.6.5.jar;D:\workspace\Eclipse-jee\Hadoop_APPs_U_tht\build\jsp-2.1-6.1.14.jar;D:\workspace\Eclipse-jee\Hadoop_APPs_U_tht\build\jsp-api-2.1-6.1.14.jar;D:\workspace\Eclipse-jee\Hadoop_APPs_U_tht\build\jsr305-1.3.9.jar;D:\workspace\Eclipse-jee\Hadoop_APPs_U_tht\build\junit-4.10-HBASE-1.jar;D:\workspace\Eclipse-jee\Hadoop_APPs_U_tht\build\libthrift-0.8.0.jar;D:\workspace\Eclipse-jee\Hadoop_APPs_U_tht\build\log4j-1.2.16.jar;D:\workspace\Eclipse-jee\Hadoop_APPs_U_tht\build\metrics-core-2.1.2.jar;D:\workspace\Eclipse-jee\Hadoop_APPs_U_tht\build\mrunit-1.0.0-hadoop2.jar;D:\workspace\Eclipse-jee\Hadoop_APPs_U_tht\build\mrunit-1.0.0-javadoc.jar;D:\workspace\Eclipse-jee\Hadoop_APPs_U_tht\build\netty-3.2.4.Final.jar;D:\workspace\Eclipse-jee\Hadoop_APPs_U_tht\build\protobuf-java-2.4.0a.jar;D:\workspace\Eclipse-jee\Hadoop_APPs_U_tht\build\servlet-api-2.5-6.1.14.jar;D:\workspace\Eclipse-jee\Hadoop_APPs_U_tht\build\slf4j-api-1.4.3.jar;D:\workspace\Eclipse-jee\Hadoop_APPs_U_tht\build\slf4j-log4j12-1.4.3.jar;D:\workspace\Eclipse-jee\Hadoop_APPs_U_tht\build\snappy-java-1.0.3.2.jar;D:\workspace\Eclipse-jee\Hadoop_APPs_U_tht\build\stax-api-1.0.1.jar;D:\workspace\Eclipse-jee\Hadoop_APPs_U_tht\build\velocity-1.7.jar;D:\workspace\Eclipse-jee\Hadoop_APPs_U_tht\build\xmlenc-0.52.jar;D:\workspace\Eclipse-jee\Hadoop_APPs_U_tht\build\zookeeper-3.4.5.jar
2013-09-09 15:58:55,031 INFO zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:java.library.path=D:\workspace\Eclipse-jee\hadoop-1.1.21\lib\native;D:\workspace\Eclipse-jee\hadoop-1.1.21\lib\native
2013-09-09 15:58:55,031 INFO zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:java.io.tmpdir=C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\
2013-09-09 15:58:55,031 INFO zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:java.compiler=<NA>
2013-09-09 15:58:55,031 INFO zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:os.name=Windows XP
2013-09-09 15:58:55,031 INFO zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:os.arch=x86
2013-09-09 15:58:55,031 INFO zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:os.version=5.1
2013-09-09 15:58:55,031 INFO zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:user.name=hadoop
2013-09-09 15:58:55,031 INFO zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:user.home=C:\Documents and Settings\Administrator
2013-09-09 15:58:55,031 INFO zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:user.dir=D:\workspace\Eclipse-jee\Hadoop_APPs_U_tht
2013-09-09 15:58:55,031 INFO zookeeper.ZooKeeper (ZooKeeper.java:<init>(438)) - Initiating client connection, connectString=master:2181 sessionTimeout=180000 watcher=hconnection
2013-09-09 15:58:56,171 INFO zookeeper.RecoverableZooKeeper (RecoverableZooKeeper.java:<init>(104)) - The identifier of this process is 6032@tht
2013-09-09 15:58:56,234 INFO zookeeper.ClientCnxn (ClientCnxn.java:logStartConnect(966)) - Opening socket connection to server master/121.1.253.251:2181. Will not attempt to authenticate using SASL (无法定位登录配置)
2013-09-09 15:58:56,296 INFO zookeeper.ClientCnxn (ClientCnxn.java:primeConnection(849)) - Socket connection established to master/121.1.253.251:2181, initiating session
2013-09-09 15:58:56,484 INFO zookeeper.ClientCnxn (ClientCnxn.java:onConnected(1207)) - Session establishment complete on server master/121.1.253.251:2181, sessionid = 0x141011ad7db000e, negotiated timeout = 180000
result:
table name: users
column Families: address
column Families: info
column Families: user_id
hbase:应用开发的更多相关文章
-
HBase应用开发回顾与总结系列之四:HBase配置管理类接口设计
利用Eclipse进行HBase应用开发时,至少需要确定三个配置信息,如下表所示: #hbase config #HMaster服务部署主机及端口号 hbase.master=hdp-wuyong ...
-
HBase应用开发回顾与总结系列之一:概述HBase设计规范
概述 笔者本人接触研究HBase也有半年之久了,虽说不上深入和系统,但至少算是比较沉迷.作为部门里大数据技术的探路者,笔者还要承担起技术传播的职责,所以在摸索研究的过程中总是不断地进行总结和测试, ...
-
FusionInsight大数据开发--HBase应用开发
HBase应用开发 HBase的定义 HBase是一个高可靠.高性能.面向列.可伸缩的分布式存储系统. 适合于存储大表数据,可以达到实时级别. 利用Hadoop HDFS 作为其文件存储系统,提供实时 ...
-
HBase应用开发回顾与总结系列之三:RowKey行键生成器工具
所谓RowKey行键生成器,是指通过软件工具制定行键生成策略,并可将策略信息保存成本地策略文件,待需要时再将本地策略文件序列化成行键生成策略对象,传入数据行信息后可自动生成RowKey行键. 那么 ...
-
HBase应用开发回顾与总结系列之二:RowKey行键设计规范
2. RowKey行键设计规范 2.1. RowKey四大特性 2.1.1 字符串类型 虽然行键在HBase中是以byte[]字节数组的形式存储的,但是建议在系统开发过程中将其数据类型设置为Strin ...
-
HBase(一): c#访问hbase组件开发
HDP2.4安装系列介绍了通过ambari创建hbase集群的过程,但工作中一直采用.net的技术路线,如何去访问基于Java搞的Hbase呢? Hbase提供基于Java的本地API访问,同时扩展了 ...
-
HBase eclipse开发环境搭建
伪分布式环境安装 事先本机必须部署好了伪分布式hadoop开发环境将Hbase/lib下的 hadoop-core-*.jar 与 hadoop保持一致. 将hadoop下的复制到hbase下将had ...
-
hbase 快速开发
hbase是一个分布式的NoSQL,部署起来配置很多东西,开发起来太慢,可以使用docker快速搭建环境 gs@gs-virtual-machine:~$ sudo docker run -ti ha ...
-
运行HBase应用开发程序产生异常,提示信息包含org.apache.hadoop.hbase.ipc.controller.ServerRpcControllerFactory的解决办法
Using Spark's default log4j profile: org/apache/spark/log4j-defaults.properties Exception in thread ...
-
HBase学习----windows10下使用eclipse搭建HBase的开发环境
以下是我搭建HBase开发环境的一些心得(windows10) 0.安装JDK和eclipse和一个可用的HBase. 这步是最基础的,在此就不赘述了 1.创建一个java项目: 基础问题,不赘述. ...
随机推荐
-
BLOCKED和WAITING的区别
/** * Thread state for a thread blocked waiting for a monitor lock. * A thread in the blocked state ...
-
kafka consumer 分区reblance算法
转载请注明原创地址 http://www.cnblogs.com/dongxiao-yang/p/6238029.html 最近需要详细研究下kafka reblance过程中分区计算的算法细节,网上 ...
-
【Common】-NO.122.common.1 - pv、uv、ip,tps、qps、rps术语
Style:Mac Series:Java Since:2018-09-10 End:2018-09-10 Total Hours:1 Degree Of Diffculty:5 Degree Of ...
-
获取外网出口ip
curl ifconfig.me 或 curl cip.cc
-
table 表头固定 thead固定. 1) 使用jquery.freezeheader.js
方法一: 使用jquery.freezeheader.js 固定表头: 1-: 初始化: <!DOCTYPE html> <html lang="en"> ...
-
【java】浅谈while 和do-while
while语法格式:while(布尔表达式){//语句}先判断布尔表达式,如果为true就会执行循环体中的语句,然后再判断布尔表达式,一直到布尔表达式为false,然后循环结束.通常用算术运算符(++ ...
-
网站软件FTP下载
网站软件FTP下载 统一管理站 http://www.mmnt.net/ db2 http://www.mmnt.net/db/0/0/public.dhe.ibm.com/software/hk/ ...
-
Linux(Contos7.5)环境搭建之Gitblit安装(三)
1.yum安装git(这一步暂时不清楚是否必要,因为在window上搭建并不需要)
-
Rotor envoy control plane 简单试用
rotor 基于golang 的envoy xds 服务,支持多种集成方式: k8s consul aws dc/os demo试用docker 以及consul 进行环境运行 下载demo 可以试用 ...
-
记一次线上Kafka消息堆积踩坑总结
2018年05月31日 13:26:59 xiaoguozi0218 阅读数:2018更多 个人分类: 大数据 年后上线的系统,与其他业务系统的通信方式采用了第三代消息系统中间件Kafka.由于是 ...