表映射的话,在phoenix中的表与hbase中的表会被同时删除与修改,视图映射中的表删除,hbase中的表不会被删除。...,只需要将createview改为createtable即可。...2)当HBase中不存在表时,可以直接使用createtable指令创建需要的表,并且在创建指令中可以根据需要对HBase表结构进行显示的说明。...address"varchar); 种情况下,直接使用与第1)种情况一样的createtable语句进行创建即可,这样系统将会自动在Phoenix和HBase中创建person_infomation的表...使用createtable创建的关联表,如果对表进行了修改,源数据也会改变,同时如果关联表被删除,源表也会被删除。但是视图就不会,如果删除视图,源数据不会发生改变。
上一篇博客说了怎样搭建HBase环境,今天说说怎样使用 HBase 的客户端 API 来操作 HBase 中的数据。...private void createTable() throws IOException { Admin admin = connection.getAdmin();...ColumnFamilyDescriptorBuilder.newBuilder(Bytes.toBytes("address")).build()) .build(); admin.createTable...ConnectionFactory.createConnection(config); TestAPI t = new TestAPI(connection); t.listTable(); t.createTable...tableName)); } } finally { admin.close(); } } private void createTable
(t *hrpc.CreateTable) error DeleteTable(t *hrpc.DeleteTable) error EnableTable(t *hrpc.EnableTable...DisableTable(t *hrpc.DisableTable) error ClusterStatus() (*pb.ClusterStatus, error) } // CreateTable...represents a CreateTable HBase call type CreateTable struct { base families map[string]map...[string]string splitKeys [][]byte } // NewCreateTable creates a new CreateTable request that will...)) *CreateTable { ct := &CreateTable{ base: base{ table: table,
connection = ConnectionFactory.createConnection(config); // 执行各种操作 createTable...) { e.printStackTrace(); } } } // 创建表 private static void createTable...HTableDescriptor(tableName); tableDescriptor.addFamily(new HColumnDescriptor("cf1")); // 添加列族 admin.createTable...;public static void createTable(Connection connection) throws Exception { Admin admin = connection.getAdmin...info".getBytes()); tableDescriptor.setColumnFamily(columnFamily.build()); admin.createTable
HBase 使用 Java 语言开发,因而 HBase 原生提供了一个 Java 语言客户端。这篇文章介绍 HBase Admin API,包括创建、启用、禁用、删除表等。...创建表 可以使用 Admin 类的 createTable() 方法在 HBase 中创建表。此类属于 org.apache.hadoop.hbase.client 包中。...然后使用 Admin 类的 createTable() 方法创建表: public static void create(String name, String... columnFamilies)...columnFamilies) { builder.setColumnFamily(ColumnFamilyDescriptorBuilder.of(cf)); } admin.createTable...for (String cf : columnFamilies) { tableDescriptor.addFamily(new HColumnDescriptor(cf)); } admin.createTable
import org.apache.hadoop.hbase.client.Put; import org.apache.hadoop.hbase.client.Get; import org.apache.hadoop.hbase.client.Delete...; import org.apache.hadoop.hbase.util.*; import org.apache.hadoop.hbase.KeyValue; import org.apache.hadoop.hbase.util.Writables...Helloworld"); String[] cfs; cfs = new String[1]; cfs[0] = "Hello"; createTable...cfs); } /** * 创建表操作 * @throws IOException */ public static void createTable... tableDesc.addFamily(new HColumnDescriptor(cfs[i])); } admin.createTable
hbase数据库的操作也非常简单,但你需要先大致了解一下hbase的架构。 hbase架构 hbase是基于列存储的nosql数据库,hbase官方参考指南中有很详细的使用说明。...hbase简单api调用 hbase的功能相当丰富,运维也相对比较复杂,下面是对hbase的简单调用,仅供参考学习。如果想了解更多深入的内容,可以参考上边提到的官方参考指南。...ConnectionFactory.createConnection(configuration); admin = connection.getAdmin(); } public void createTable...TableDescriptorBuilder.newBuilder(tableName) .setColumnFamilies(list) .build(); admin.createTable..."; List colFamilyList = Lists.newArrayList("learn", "body"); hBaseLearnMain.createTable
configuration=null; static{ configuration= HBaseConfiguration.create(); configuration.set("hbase.zookeeper.property.clientPort...","2081"); configuration.set("hbase.zookeeper.quorum","192.168.136.135"); configuration.set...("hbase.master","192.168.136.135:60000"); } /** * HBase 根据表名与列信息与配置信息创建表 * @param...org.apache.hadoop.conf.Configuration 配置对象 * @throws Exception */ public static void createTable...tableDescriptor.addFamily(new HColumnDescriptor(column)); } hbaseAdmin.createTable
一.前述 1.HBase,是一个高可靠性、高性能、面向列、可伸缩、实时读写的分布式数据库。...二.Hbase数据模型 ? 2.1 ROW KEY(相当于关系型数据库中的ID) 决定一行数据 按照字典顺序排序的。...HBase把同一列族里面的数据存储在同一目录下,由几个文件保存。 2.3 Timestamp时间戳(相当于版本!!!)...三.Hbase架构 ?...3.1 Client 包含访问HBase的接口并维护cache来加快对HBase的访问 3.2 Zookeeper 保证任何时候,集群中只有一个master(HA) 存贮所有Region的寻址入口。
wget http://archive.apache.org/dist/hbase/1.3.2/hbase-1.3.2-bin.tar.gz tar -zxvf hbase-1.3.2-bin.tar.gz...#解压 mv hbase-1.3.2 /usr/local/hbase 配置hbase-site.xml cd /usr/local/hbase/conf vi hbase-site.xml <property...param myTableName 表名 * @param colFamily 列族数组 * @throws IOException */ public void createTable...HColumnDescriptor(str); hTableDescriptor.addFamily(hColumnDescriptor); } admin.createTable...String[] cols=new String[]{"S_No","S_Name","S_Sex","S_Age"}; //建表 hbaseCRUD.createTable
一、简介 在上一篇文章 HBase 基础入门 中,我们已经介绍了 HBase 的一些基本概念,以及如何安装使用的方法。...connection * @param tableName * @param columnFamilies * @throws IOException */ public static void createTable...builder.setColumnFamily(ColumnFamilyDescriptorBuilder.of(columnFamily)); } admin.createTable...; TableName tableName = TableName.valueOf("DeviceState"); //创建DeviceState表 createTable...logger.error("error occurs", e); } } } } 执行代码,控制台输出如下: INFO -createTable
在使用HBase的API查询数据的时候,我们经常需要设置一些过滤条件来查询数据,这个时候我们就需要使用 HBase API 的各种 Filter 来实现这一功能。...; import org.apache.hadoop.hbase.HBaseConfiguration; import org.apache.hadoop.hbase.TableName; import...org.apache.hadoop.hbase.client.*; import org.apache.hadoop.hbase.exceptions.DeserializationException...= connection; } private void test() throws IOException, DeserializationException { createTable...BinaryComparator(Bytes.toBytes("user_0")))); deleteTable(); } private void createTable
前一篇博客说了一下 HBase 的一些过滤器,今天看看 HBase 的分页过滤器。...; import org.apache.hadoop.hbase.HBaseConfiguration; import org.apache.hadoop.hbase.TableName; import...org.apache.hadoop.hbase.client.*; import org.apache.hadoop.hbase.exceptions.DeserializationException...= connection; } private void test() throws IOException, DeserializationException { createTable...break; } } table.close(); deleteTable(); } private void createTable
htd.addFamily(hcd1); htd.addFamily(hcd2); //创建表 admin.createTable...e.printStackTrace(); } } } // 创建表 public static void createTable...hcd = new HColumnDescriptor(fc); htd.addFamily(hcd); } admin.createTable...class HBaseUtilTest { @Test public void testCreateTable() { //创建表 HBaseUtil.createTable...("myTest", "myfc1", "myfc2", "myfc3"); HBaseUtil.close(); HBaseUtil.createTable("myTest02
Hbase(四):Hbase原理 Hbase的工作方式 region的分裂和结构 hbase表中的数据按照行键的字典顺序排序 hbase表中的数据按照行的的方向切分为多个region 最开始只有一个...写入数据到hdfs的过程其实是不断追加hfile的过程 Hbase写入数据 数据写入hbase时 先在hlog中记录日志 再修改memstore 直接返回成功 这样 不需要真正等待写入hdfs的过程 所以很快...由于hbase中的数据天然排序 再加上索引 整个查询也可以非常的快 Hbase中的region的寻址 在hbase中有一个hbase:meta表,其中存放了 表和region和regionSever 之间的对应关系信息... 支持增、删、读、改、顺序扫描操作 牺牲了一部分读的性能换取了高效写入能力 Hbase系统架构 hbase中的老大叫hmaster 小弟叫hregionServer 客户端叫Client...Zookeepr为hbase提供集群协调 client 访问hbase 保留一些缓存信息提升效率 zookeeper 保证任何时候集群只有一个HMaster 监控regionServer的状态
可以用如下语句在hive上实行创表,然后hbase上会出现对应的表 ? ?...此时可以看见basketball2已经在hbase上建立了 ps:CREATE TABLE basketball2(num int,team string,state string) STORED BY...‘org.apache.hadoop.hive.hbase.HBaseStorageHandler’ WITH SERDEPROPERTIES (“hbase.columns.mapping” = “...:key,player:team,player:state”) TBLPROPERTIES (“hbase.table.name” = “basketball2”); create table后面跟hive...上要创建的表名,mapping相当于映射,:前面没有东西就相当于是hbase里的rowkey,后面的player相当于列族里的Column family,而team和state相当于Column qualifier
集群服务) 启动HBase 由于伪分布式下的 HBase 依赖 HDFS ,因此我们需要先启动 HDFS : start-dfs.sh 然后启动 HBase : start-hbase.sh 3.然后就是代码实现...import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.client.*; import org.apache.hadoop.hbase.util.Bytes...class HbaseDemo1 { /** * @Description: createTable():创建表的方法 * @Param: 0 * @return: 0...*/ @Test public void createTable() throws IOException { Configuration conf = HBaseConfiguration.create...//讲列簇定义到表中 hTableDescriptor.addFamily(hColumnDescriptor); //执行建表操作 admin.createTable
.build(); admin.createNamespace(namespce); admin.close(); } public void createTable...(String tableName, String... families) throws IOException { // 因为下面的存在,此处可以省略 createTable...(tableName,1,families); } public void createTable(String tableName,Integer versions, String....创建命名空间以及表名的定义 dao.createNamespace(Names.NAMESPACE_WEIBO); //2) 创建微博内容表 dao.createTable...(Names.TABLE_WEIBO,Names.WEIBO_FAMILY_DATA); //3) 创建用户关系表 dao.createTable(Names.TABLE_RELATION
HColumnDescriptor hcd = new HColumnDescriptor("wordcount"); htd.addFamily(hcd); admin.createTable...org.apache.hadoop.hbase.client.Put; import org.apache.hadoop.hbase.client.Result; import org.apache.hadoop.hbase.client.Scan...class, ImmutableBytesWritable.class, ImmutableBytesWritable.class, job); createTable...0 : 1; } private static void createTable(Configuration conf) throws IOException{ Connection...HColumnDescriptor hcd = new HColumnDescriptor("wordcount"); htd.addFamily(hcd); admin.createTable
来加速Hbase的访问,比如cache的.META.元数据的信息。...流程 老的Region寻址方式 在Hbase 0.96版本以前,Hbase有两个特殊的表,分别是-ROOT-表和.META.表,其中-ROOT-的位置存储在ZooKeeper中,-ROOT-本身存储了...(3)Hlog数量上限 前面说到Hlog为了保证Hbase数据的一致性,那么如果Hlog太多的话,会导致故障恢复的时间太长,因此Hbase会对Hlog的最大个数做限制。...该参数为:hbase.hregion.majorcompaction.jitter 具体算法为: hbase.hregion.majorcompaction参数的值乘于一个随机分数,这个随机分数不能超过...通过hbase.hregion.majorcompaction参数的值加上或减去hbase.hregion.majorcompaction参数的值乘于一个随机分数的值就确定下一次大合并的时间区间。