Dict.CN 在线词典, 英语学习, 在线翻译 ------------- MyGitee 朱秋贵内科诊所 My腾云code

springboot+hbase 新增记录

1、先部署好 Hadoop

    参考:idea+Hadoop 增删改查20220614

2、配置hbase

 3、启动hbase

 

 

 

 

 

4、进入hbase shell

 

 

 

 

 

 

 

 

 

 

 

5、进入hbase shell  创建testtable

 

 

 

 

 

 

6、idea  

     表testtable 新增行记录 row1

 

  1)、pom.xml

 

 2)、HBaseTEST

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.client.HTable;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.util.Bytes;
import java.io.IOException;

public class HBaseTEST {

  public static  void  main(String[] args) throws IOException {

      Configuration configuration=HBaseConfiguration.create();
      configuration.set("hbase.zookeeper.quorum","127.0.0.1");
      HTable table=new HTable(configuration,"testtable");
      Put put=new Put(Bytes.toBytes("row1"));
      put.add(Bytes.toBytes("colfam1"),Bytes.toBytes("qual1"),Bytes.toBytes("val1"));
      put.add(Bytes.toBytes("colfam1"),Bytes.toBytes("qual2"),Bytes.toBytes("val2"));
      table.put(put);
  }
}

 

3)、表testtable记录查询scan 如下

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

7、访问hbase 

 

posted @ 2022-06-20 16:13  cn2023  阅读(149)  评论(0编辑  收藏  举报