前文已经结束了在本机安装伪分布式的hadoop,这篇文章介绍安装伪分布式的hbase。hbase也是个主从架构,有hmaster和hregionserver,自带有zookeeper。关于具体的概念我不细说,hadoop这一套东西版本的搭配很重要,版本选错了可能会出错,这是我在网上看到的一张图

我就是安装上面的做的,没有出现错误

版本介绍

jdk:1.6(可能这个版本比较低,我用1.7就错误了,换1.6版本没问题)

hadoop:0.20.2

hbase:0.90.3

1:第一步去apache官网下载对应的版本:http://archive.apache.org/dist/hbase/

2:下载后解压,此处有几个文件需要修改一下

hbase-env.sh

export JAVA_HOME=/cygdrive/c/java/jdk1.6
export HBASE_CLASSPATH=/cygdrive/c/cygwin64/hadoop/conf

hbase-site.xml

<property><name>hbase.rootdir</name><value>hdfs://localhost:9000/hbase</value>   </property><property><name>hbase.cluster.distributed</name><value>true</value></property>

3:因为hbase是把数据存hdfs,在hbase的lib下有个hadoop的jar包,把这个去掉,再把下载的hadoop核心core包复制进去

4:把hbase放在cygwin安装目录下

5:用cygwin启动服务,先启动hadoop,再启动hbase,关闭则相反

6:可以分别打开hdfs和hbase管理页面,localhost:50070   localhost:60010

可以看到在hdfs上已经有了hbase文件夹

到这里一个简单的伪分布式搭好了,接下来eclipse连接并对habse进行DDL和DML

前提是把hbase里面的jar包导入到工程,maven就写入依赖

package com.qqw.test;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.KeyValue;
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.HBaseAdmin;
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;
import org.junit.Test;public class HbaseTest {//@Test/*** 创建表* @throws Exception*/public void test1() throws Exception{Configuration config = HBaseConfiguration.create();config.set("hbase.zookeeper.quorum", "localhost");//通过zk来获取hmaster的主机入口HBaseAdmin admin = new HBaseAdmin(config);String table="student";//表名if(admin.isTableAvailable(table)){admin.disableTable(table);admin.deleteTable(table);}else{HTableDescriptor hd=new HTableDescriptor(table.getBytes());HColumnDescriptor cd=new HColumnDescriptor("cf1".getBytes());hd.addFamily(cd);//表添加列族admin.createTable(hd);//创建表}}//@Test/*** 插入表* @throws Exception*/public void test2() throws Exception{Configuration config = HBaseConfiguration.create();config.set("hbase.zookeeper.quorum", "localhost");//通过zk来获取hmaster的主机入口HTable table=new HTable(config, "student".getBytes());String rowkey="18600754234";Put put=new Put(rowkey.getBytes());put.add("cf1".getBytes(), "name".getBytes(), Bytes.toBytes("李思思"));put.add("cf1".getBytes(), "age".getBytes(), "23".getBytes());put.add("cf1".getBytes(), "addrss".getBytes(), "beijing".getBytes());table.put(put);table.close(); }@Test/*** 根据rowkey查询* @throws Exception*/public void test3() throws Exception{Configuration config = HBaseConfiguration.create();config.set("hbase.zookeeper.quorum", "localhost");//通过zk来获取hmaster的主机入口HTable table=new HTable(config, "student".getBytes());String rowkey="18600754238";Get get = new Get(rowkey.getBytes());Result result = table.get(get);for (KeyValue kv : result.list()) {System.out.println("family:" + Bytes.toString(kv.getFamily()));System.out.println("qualifier:" + Bytes.toString(kv.getQualifier()));System.out.println("value:" + Bytes.toString(kv.getValue()));System.out.println("Timestamp:" + kv.getTimestamp());System.out.println("-------------------------------------------");}table.close();  }@Test/*** 扫描全表* @throws Exception*/public void test4() throws Exception{Configuration config = HBaseConfiguration.create();config.set("hbase.zookeeper.quorum", "localhost");//通过zk来获取hmaster的主机入口HTable table=new HTable(config, "student".getBytes());Scan scan=new Scan();ResultScanner scanner = table.getScanner(scan);for(Result r:scanner){for (KeyValue kv : r.list()) {System.out.println("family:" + Bytes.toString(kv.getFamily()));System.out.println("qualifier:" + Bytes.toString(kv.getQualifier()));System.out.println("value:" + Bytes.toString(kv.getValue()));System.out.println("Timestamp:" + kv.getTimestamp());System.out.println("-------------------------------------------");}}table.close(); }@Test/*** 查询某列* @throws Exception*/public void test5() throws Exception{Configuration config = HBaseConfiguration.create();config.set("hbase.zookeeper.quorum", "localhost");//通过zk来获取hmaster的主机入口HTable table=new HTable(config, "student".getBytes());String rowkey="18600754238";Get get = new Get(rowkey.getBytes());get.addColumn("cf1".getBytes(), "addrss".getBytes());Result result = table.get(get);for (KeyValue kv : result.list()) {System.out.println("family:" + Bytes.toString(kv.getFamily()));System.out.println("qualifier:" + Bytes.toString(kv.getQualifier()));System.out.println("value:" + Bytes.toString(kv.getValue()));System.out.println("Timestamp:" + kv.getTimestamp());System.out.println("-------------------------------------------");}table.close();   }@Test/*** 更新某列* @throws Exception*/public void test6() throws Exception{Configuration config = HBaseConfiguration.create();config.set("hbase.zookeeper.quorum", "localhost");//通过zk来获取hmaster的主机入口HTable table=new HTable(config, "student".getBytes());String rowkey="18600754238";Put put = new Put(rowkey.getBytes());put.add(Bytes.toBytes("cf1"), Bytes.toBytes("addrss"),Bytes.toBytes("南昌"));table.put(put);System.out.println("update table Success!");table.close();    }/*** 查询某列数据的多个版本* @throws Exception*/@Testpublic void test7() throws Exception{Configuration config = HBaseConfiguration.create();config.set("hbase.zookeeper.quorum", "localhost");//通过zk来获取hmaster的主机入口HTable table=new HTable(config, "student".getBytes());String rowkey="18600754238";Get get = new Get(rowkey.getBytes());get.addColumn("cf1".getBytes(), "addrss".getBytes());get.setMaxVersions(5);Result result = table.get(get);for (KeyValue kv : result.list()) {System.out.println("family:" + Bytes.toString(kv.getFamily()));System.out.println("qualifier:" + Bytes.toString(kv.getQualifier()));System.out.println("value:" + Bytes.toString(kv.getValue()));System.out.println("Timestamp:" + kv.getTimestamp());System.out.println("-------------------------------------------");}table.close();  }/** 删除指定的列* * @tableName 表名* * @rowKey rowKeypublic static void deleteAllColumn(String tableName, String rowKey)throws IOException {HTable table = new HTable(conf, Bytes.toBytes(tableName));Delete deleteAll = new Delete(Bytes.toBytes(rowKey));table.delete(deleteAll);System.out.println("all columns are deleted!");}* 删除表* * @tableName 表名public static void deleteTable(String tableName) throws IOException {HBaseAdmin admin = new HBaseAdmin(conf);admin.disableTable(tableName);admin.deleteTable(tableName);System.out.println(tableName + "is deleted!");}*/}

至此hbase简单介绍到此告一段落,建议多看看hbase的构造,比较复杂。

hadoop整合hbase相关推荐

  1. nagios整合ganglia实现hadoop、Hbase监控及手机短信报警

    预计该博文篇幅较长,这里不再废话,对ganglia不太了解的去问谷老师,直接看环境: hadoop1.updb.com    192.168.0.101 hadoop2.updb.com    192 ...

  2. 2.4-2.5、Hive整合(整合Spark、整合Hbase)、连接方式Cli、HiveServer和hivemetastore、Squirrel SQL Client等

    2.4其它整合 2.4.1Hive整合Spark Spark整合hive,需要将hive_home下的conf下的hive_site.xml放到spark_home下的conf目录下.(3台服务器都做 ...

  3. Hive 整合Hbase(来自学习资料--博学谷)

    1.摘要 Hive提供了与HBase的集成,使得能够在HBase表上使用HQL语句进行查询 插入操作以及进行Join和Union等复杂查询.同时也可以将hive表中的数据映射到Hbase中. 2.应用 ...

  4. SpringBoot整合HBase将数据写入Docker中的HBase

    在之前的项目里,docker容器中已经运行了HBase,现将API操作HBase实现数据的增删改查 通过SpringBoot整合Hbase是一个很好的选择 首先打开IDEA,创建项目(project) ...

  5. Hive 整合 HBase

    作者 | 广   责编 | 张文 头图 | CSDN 下载自视觉中国 HBase 虽然可以存储数亿或数十亿行数据,但是对于数据分析来说不太友好,它只提供了简单的基于 Key 值的快速查询能力,没法进行 ...

  6. hive整合HBase:HBase table xsg:test05 doesn't exist while the table is declared as an external table

    版本 虚拟机centOS7 hive 1.2.1 hbase 1.2.6 1,在hive-site.xml中添加配置 <property><name>hbase.zookeep ...

  7. hive安装及整合hbase

    hive安装及整合hbase (1). 上传hive安装包并解压 tar -zxvf apache-hive-3.1.3-bin.tar.gz -C /export/server/ (2). 配置hi ...

  8. solrcloud 高可用集群搭建加solr整合hbase以及向ganglia报告度量

    一.环境准备 CentOS-6.4-x86_64-minimal.iso jdk-6u45-linux-i586-rpm.bin zookeeper-3.4.5.tar solr-4.6.0.zip ...

  9. hadoop+zookeeper+hbase+hive

    hadoop安装配置 hadoop安装文档:https://blog.csdn.net/pucao_cug/article/details/71698903 zookeeper安装文档:https:/ ...

最新文章

  1. 宽带服务价值链之:ISP,ICP,ASP,IDC,CDN
  2. 2016搜狗:矩阵元素相乘
  3. LayUi 树形组件tree 实现懒加载模式,展开父节点时异步加载子节点数据
  4. 重构-改善既有代码的设计:重构原则(二)
  5. Xcode8注释有时会失效的解决方法
  6. tableview动态修改和删除_Ubuntu加载动态库失败的解决方案
  7. 理解并实施:GLBP(ccna200-120新增考点)
  8. CF1100F Ivan and Burgers(线性基)
  9. CMake 使用方法
  10. JAVA入门级教学之(静态内部类)
  11. python2和python3共存时,设置默认python为python3
  12. 简单的PHP数据后台实现用户登录
  13. 修改注册表,改回主页---内容来自百度
  14. win10 64位 JavaJDK的下载、安装与配置。
  15. CE教程:植物大战僵尸(单卡片无CD)
  16. java+mysql 基于ssm205网上购物超市系统#毕业设计
  17. ips 测试软件,IPS测试方法.doc
  18. QQ空间删除的照片怎么找回,你知道回收站吗?
  19. 6个超实用网站,让你工作时长减半。
  20. Java 8 Stream流的常见操作

热门文章

  1. jquery显示、隐藏div
  2. TXT文本大数据手机号码归属地批量归类查询处理工具
  3. weblogic 漏洞复现
  4. 中鑫吉鼎|大学生的理财攻略有哪些
  5. 迪厅装修后地板清洁与保养
  6. android 给图片加文字、图片水印
  7. CTC束搜索解码原理和Pytorch实现(CTC Prefix BeamSearch Decode)
  8. python实现四参数七参数坐标转换
  9. 【壁纸】动漫绝美壁纸
  10. Checking Table 设计模式 - 从概念、建模、设计到实现