当前位置: 首页 > news >正文

淘宝上面的网站建设是靠谱大批量刷关键词排名软件

淘宝上面的网站建设是靠谱,大批量刷关键词排名软件,免费空间网,网页设计与制作课程评价内实idea操作Hbase数据库并且映射到Hive 文章目录idea操作Hbase数据库并且映射到Hiveidea操作Hbase数据库环境准备启动服务创建Maven工程在测试类中编写初始化方法在测试类中编写关闭方法在测试类中编写创建命名空间方法在测试类中编写创建表方法在测试类中编写查看表结构方法在测试…

idea操作Hbase数据库并且映射到Hive


文章目录

  • idea操作Hbase数据库并且映射到Hive
  • idea操作Hbase数据库
    • 环境准备
    • 启动服务
    • 创建Maven工程
      • 在测试类中编写初始化方法
      • 在测试类中编写关闭方法
      • 在测试类中编写创建命名空间方法
      • 在测试类中编写创建表方法
      • 在测试类中编写查看表结构方法
      • 在测试类中编写插入数据方法
      • 在测试类中编写查询数据方法(get)
      • 在测试类中编写扫描数据方法(scan)
      • 在测试类中编写删除表方法
  • Hbase表映射成Hive表
    • 创建外部表
    • 查询


idea操作Hbase数据库

环境准备

再安装过Hadoop+Hive+zookeeper的实验机上

# 将hbase235/lib/下的jar包拷入到hive312/lib/下
# 如果有重复,选择不覆盖
[root@hadoop conf]# cp /opt/soft/hbase235/lib/* /opt/soft/hive312/lib/# 将切换到hbase235/lib目录下
[root@hadoop conf]# cd /opt/soft/hbase235/lib/
# 将hive312/lib/guava-27.0-jre.jar复制到当前目录下
[root@hadoop lib]# cp /opt/soft/hive312/lib/guava-27.0-jre.jar ./# 切换/opt/soft/hive312/conf/目录下
[root@hadoop conf]# cd /opt/soft/hive312/conf/
# 修改 hive-site.xml
[root@hadoop conf]# vim ./hive-site.xml# 添加配置信息
<property><name>hive.zookeeper.quorum</name><value>192.168.95.150</value>
</property>
<property><name>hbase.zookeeper.quorum</name><value>192.168.95.150</value>
</property>
<property><name>hive.aux.jars.path</name><value>file:///opt/soft/hive312/lib/hive-hbase-handler-3.1.2.jar,file:///opt/soft/hive312/lib/zookeeper-3.4.6.jar,file:///opt/soft/hive312/lib/hbase-client-2.3.5.jar,file:///opt/soft/hive312/lib/hbase-common-2.3.5-tests.jar,file:///opt/soft/hive312/lib/hbase-server-2.3.5.jar,file:///opt/soft/hive312/lib/hbase-common-2.3.5.jar,file:///opt/soft/hive312/lib/hbase-protocol-2.3.5.jar,file:///opt/soft/hive312/lib/htrace-core-3.2.0-incubating.jar</value>
</property>

添加配置
在这里插入图片描述

启动服务

# 启动hadoop
[root@hadoop ~]# start-all.sh
# 启动zookeeper
[root@hadoop ~]# zkServer.sh start
# 启动hbase
[root@hadoop ~]# start-hbase.sh
# 启动hive
[root@hadoop ~]# nohup hive --service metastore &
[root@hadoop ~]# nohup hive --service metastore &

在这里插入图片描述

创建Maven工程

添加依赖

<dependency><groupId>org.apache.hbase</groupId><artifactId>hbase-client</artifactId><version>2.3.5</version></dependency><dependency><groupId>org.apache.hbase</groupId><artifactId>hbase-server</artifactId><version>2.3.5</version></dependency>

在测试类中编写初始化方法

初始化:添加hbase信息,连接数据库,hbase连接工厂

    @Beforepublic void init() throws IOException {System.out.println("执行init()方法");config = HBaseConfiguration.create();config.set(HConstants.HBASE_DIR,"hdfs://192.168.95.150:9000/hbase");config.set(HConstants.ZOOKEEPER_QUORUM,"192.168.95.150");config.set(HConstants.CLIENT_PORT_STR,"2181");conn = ConnectionFactory.createConnection(config);admin = conn.getAdmin();}

在测试类中编写关闭方法

/*
*将连接关闭
*/@Afterpublic void close() throws IOException {System.out.println("执行close()方法");if (admin!=null)admin.close();if (conn!=null)conn.close();}

在测试类中编写创建命名空间方法

/*** 创建命名空间*/@Testpublic void createNameSpace() throws IOException {NamespaceDescriptor bigdata = NamespaceDescriptor.create("bigdata").build();admin.createNamespace(bigdata);}

在测试类中编写创建表方法

/** 创建表* */@Testpublic void createTable() throws IOException {//创建表的描述类TableName tableName = TableName.valueOf("bigdata:student");HTableDescriptor desc = new HTableDescriptor(tableName);//创建列族的描述HColumnDescriptor family1 = new HColumnDescriptor("info1");HColumnDescriptor family2 = new HColumnDescriptor("info2");desc.addFamily(family1);desc.addFamily(family2);admin.createTable(desc);*/

在测试类中编写查看表结构方法

    /**查看表结构*/@Testpublic void getAllNamespace() throws IOException {List<TableDescriptor> tableDesc = admin.listTableDescriptorsByNamespace("bigdata".getBytes());System.out.println(tableDesc.toString());}

在测试类中编写插入数据方法

/*** 插入数据*/@Testpublic void insertData() throws IOException {Table table = conn.getTable(TableName.valueOf("bigdata:student"));Put put = new Put(Bytes.toBytes("student1"));put.addColumn("info1".getBytes(),"name".getBytes(),"zs".getBytes());put.addColumn("info2".getBytes(),"school".getBytes(),"njzb".getBytes());Put put2 = new Put(Bytes.toBytes("student2"));put2.addColumn("info1".getBytes(),"name".getBytes(),"zss".getBytes());put2.addColumn("info2".getBytes(),"school".getBytes(),"njzb".getBytes());Put put3 = new Put(Bytes.toBytes("student3"));put3.addColumn("info1".getBytes(),"name".getBytes(),"zsr".getBytes());put3.addColumn("info2".getBytes(),"school".getBytes(),"njzb".getBytes());List<Put> list = new ArrayList<>();list.add(put1);list.add(put2);list.add(put3);table.put(list);}

在测试类中编写查询数据方法(get)

 /** 查询数据 get 查询* */@Testpublic void queryData() throws IOException {Table table = conn.getTable(TableName.valueOf("bigdata:student"));Get get = new Get(Bytes.toBytes("student1"));Result result = table.get(get);byte[] value = result.getValue(Bytes.toBytes("info1"), Bytes.toBytes("name"));System.out.println("姓名:"+Bytes.toString(value));value = result.getValue(Bytes.toBytes("info2"), Bytes.toBytes("school"));System.out.println("学校:"+Bytes.toString(value));}

在测试类中编写扫描数据方法(scan)

/** scan 扫描数据* */@Testpublic void scanData() throws IOException {Table table = conn.getTable(TableName.valueOf("kb21:student"));Scan scan = new Scan();ResultScanner scanner = table.getScanner(scan);for (Result result : scanner) {byte[] value = result.getValue(Bytes.toBytes("info1"), Bytes.toBytes("name"));System.out.println("姓名:"+Bytes.toString(value));value = result.getValue(Bytes.toBytes("info2"), Bytes.toBytes("school"));System.out.println("学校:"+Bytes.toString(value));System.out.println(Bytes.toString(result.getRow()));}}

在测试类中编写删除表方法

    /**删除表* */@Testpublic void deleteTable() throws IOException {//先禁用admin.disableTable(TableName.valueOf("bigdata:student"));//再删除admin.deleteTable(TableName.valueOf("bigdata:student"));}

Hbase表映射成Hive表

使用DataGrip连接Hive

创建外部表

主要外部表的字段需要和Hbase中的列形成映射

create external table student(id string,name string,school string
)
stored by 'org.apache.hadoop.hive.hbase.HBaseStorageHandler' with
serdeproperties ("hbase.columns.mapping"=":key,info1:name,info2:school")
tblproperties ("hbase.table.name"="bigdata:student");

查询

select * from student

在这里插入图片描述

http://www.mmbaike.com/news/104352.html

相关文章:

  • 网站虚拟机从头做有影响吗网站策划是干什么的
  • 南昌市城乡建设委员会网站百度域名
  • 卫浴网站源码竞价推广网络推广运营
  • 湛江网站建设模板百度写一篇文章多少钱
  • 网站建设毕业设计心得网站收录查询爱站
  • 网站首页做30个关键词seo可以从哪些方面优化
  • 直播间网站开发悟空建站seo服务
  • 网站app制作教程百度发作品入口在哪里
  • 网站建设里程碑关键词推广技巧
  • 网页字体网站营销网站推荐
  • wordpress PHP滑块模板整站seo技术
  • 凡科网的网站建设怎么做深圳网络广告推广公司
  • 深圳建设银行分行网站站长之家0
  • 自动化设计网站建设运营网站
  • 柳市做网站电商网站平台搭建
  • 小视频解析网站怎么做佛山竞价账户托管
  • 网站搭建dns有用吗营销推广是什么意思
  • 网站开发雷小天国外seo网站
  • 仙桃网站制作新乡百度关键词优化外包
  • 做网站要学什么软件好三亚百度推广开户
  • 网站解析教程图片优化软件
  • 怎么做网站的在线客服百度新站关键词排名
  • 微软雅黑 b做网站要版权么关键词的选取原则
  • 北京网站制作开发公司怎么从网上找客户
  • 工信部isp申请网站seo优化sem推广
  • 云系统网站建设合同百度搜索推广流程
  • 企业解决方案平台广州网站优化公司
  • 青海西宁高端网站建设全网营销平台有哪些
  • 什么软件做网站做好北京本地网络推广平台
  • 企业网站seo模板做网站的平台