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

李连杰做的功夫网站seo关键词优化培训班

李连杰做的功夫网站,seo关键词优化培训班,某公司网站源码,南安网站建设更多Paimon数据湖内容请关注:https://edu.51cto.com/course/35051.html Paimon提供了两种类型的Catalog:Filesystem Catalog和Hive Catalog。 Filesystem Catalog:会把元数据信息存储到文件系统里面。Hive Catalog:则会把元数据…

更多Paimon数据湖内容请关注:https://edu.51cto.com/course/35051.html

Paimon提供了两种类型的Catalog:Filesystem CatalogHive Catalog

  • Filesystem Catalog:会把元数据信息存储到文件系统里面。
  • Hive Catalog:则会把元数据信息存储到Hive的Metastore里面,这样就可以直接在Hive中访问Paimon表了。注意:此时也会同时在文件系统中存储一份元数据信息,相当于元数据会存储两份,这个大家需要特别注意一下。

还有就是我们在使用Hive Catalog的时候,Paimon中的数据库名称、表名称,以及字段名称都要小写,因为这些数据存储到Hive Metastore的时候,会统一存储为小写。

下面我们来具体演示一下Paimon如何使用Hive Catalog来存储元数据。

在Flink中操作Paimon的时候想要使用Hive Catalog,需要依赖于Flink Hive connector,以及hive-execflink-table-api-scala-bridge

flink-table-api-scala-bridge这个依赖我们之前已经添加过了,所以只需要添加另外两个即可:

<!-- flink-hive-connector -->
<dependency><groupId>org.apache.flink</groupId><artifactId>flink-connector-hive_2.12</artifactId><version>1.15.0</version><!--<scope>provided</scope>-->
</dependency>
<dependency><groupId>org.apache.hive</groupId><artifactId>hive-exec</artifactId><version>3.1.2</version><exclusions><exclusion><groupId>org.apache.logging.log4j</groupId><artifactId>log4j-slf4j-impl</artifactId></exclusion></exclusions><!--<scope>provided</scope>-->
</dependency>

创建package:tech.xuwei.paimon.catalog
创建object:PaimonHiveCatalog

代码如下:

package tech.xuwei.paimon.catalogimport org.apache.flink.api.common.RuntimeExecutionMode
import org.apache.flink.streaming.api.scala.StreamExecutionEnvironment
import org.apache.flink.table.api.bridge.scala.StreamTableEnvironment/*** Paimon使用Hive Catalog* Created by xuwei*/
object PaimonHiveCatalog {def main(args: Array[String]): Unit = {//创建执行环境val env = StreamExecutionEnvironment.getExecutionEnvironmentenv.setRuntimeMode(RuntimeExecutionMode.STREAMING)val tEnv = StreamTableEnvironment.create(env)//创建Paimon类型的Catalog--使用Hive CatalogtEnv.executeSql("""|CREATE CATALOG paimon_hive_catalog WITH(|    'type'='paimon',|    'metastore' = 'hive',|    'uri' = 'thrift://bigdata04:9083',|    'warehouse'='hdfs://bigdata01:9000/paimon'|)|""".stripMargin)tEnv.executeSql("USE CATALOG paimon_hive_catalog")//创建Paimon表tEnv.executeSql("""|CREATE TABLE IF NOT EXISTS p_h_t1(|    name STRING,|    age INT,|    PRIMARY KEY (name) NOT ENFORCED|)|""".stripMargin)//向表中插入数据tEnv.executeSql("""|INSERT INTO p_h_t1(name,age) VALUES('jack',18),('tom',20)|""".stripMargin)}}

接下来到bigdata04节点上启动hive的metastore服务。

[root@bigdata04 ~]# cd /data/soft/apache-hive-3.1.2-bin/
[root@bigdata04 apache-hive-3.1.2-bin]# nohup bin/hive --service metastore -p 9083 2>&1 >/dev/null &

然后运行代码PaimonHiveCatalog

代码运行之后可以到先到hdfs中确认一下是否能看到元数据信息:

[root@bigdata04 ~]# hdfs dfs -cat /paimon/default.db/p_h_t1/schema/schema-0
{"id" : 0,"fields" : [ {"id" : 0,"name" : "name","type" : "STRING NOT NULL"}, {"id" : 1,"name" : "age","type" : "INT"} ],"highestFieldId" : 1,"partitionKeys" : [ ],"primaryKeys" : [ "name" ],"options" : { }

可以发现,在hdfs中依然是可以看到的,因为我们前面说了,使用hive catalog时也会同时在hdfs中存储一份元数据。

最后我们到hive中确认一下:
注意:由于目前bigdata04节点的环境变量中有HADOOP_CLASSPATH,所以直接使用hive客户端会看到很多日志信息,所以建议使用hive的beeline客户端。
此时需要先启动hiveserver2服务。

[root@bigdata04 ~]# cd /data/soft/apache-hive-3.1.2-bin/
[root@bigdata04 apache-hive-3.1.2-bin]# bin/hiveserver2

使用beeline客户端进行连接

[root@bigdata04 apache-hive-3.1.2-bin]# bin/beeline -u  jdbc:hive2://localhost:10000 -n root
0: jdbc:hive2://localhost:10000> show tables;
+--------------------+
|      tab_name      |
+--------------------+
| flink_stu          |
| orders             |
| p_h_t1             |
| s1                 |
| student_favors     |
| student_favors_2   |
| student_score      |
| student_score_bak  |
| t1                 |
+--------------------+
9 rows selected (1.727 seconds)
0: jdbc:hive2://localhost:10000> select * from p_h_t1;
Error: Error while compiling statement: FAILED: RuntimeException java.lang.ClassNotFoundException: org.apache.paimon.hive.mapred.PaimonInputFormat (state=42000,code=40000)

此时是可以在hive中查看到p_h_t1这个表的,但是在操作这个表的时候会报错,提示缺少依赖,现在报这个错是正常的,等后面我们会有一个单独的小节来讲Paimon和Hive引擎的集成。
目前通过hive catalog可以将paimon的元数据同时存储到hive的metastore中,但是还无法在hive中操作paimon的表,其实主要是因为缺少一个依赖,在这大家先知道这个问题即可。

注意:如果我们此时操作的是分区表,那么分区信息默认是无法同步到Hive Metastore的。

也就是说默认情况下,Paimon不会将新创建的分区同步到Hive Metastore中。我们在Hive中只能看到一个未分区的普通表。

如果想解决这个问题,也很简单,只需要在paimon的表属性中设置metastore.partitioned-table=true即可。

下面开发一个案例:
创建object:PaimonHiveCatalogPartitionTable,基于PaimonHiveCatalog进行复制。

完整代码如下:

package tech.xuwei.paimon.catalogimport org.apache.flink.api.common.RuntimeExecutionMode
import org.apache.flink.streaming.api.scala.StreamExecutionEnvironment
import org.apache.flink.table.api.bridge.scala.StreamTableEnvironment/*** Paimon使用Hive Catalog* 操作分区表* Created by xuwei*/
object PaimonHiveCatalogPartitionTable {def main(args: Array[String]): Unit = {//创建执行环境val env = StreamExecutionEnvironment.getExecutionEnvironmentenv.setRuntimeMode(RuntimeExecutionMode.STREAMING)val tEnv = StreamTableEnvironment.create(env)//创建Paimon类型的Catalog--使用Hive CatalogtEnv.executeSql("""|CREATE CATALOG paimon_hive_catalog WITH(|    'type'='paimon',|    'metastore' = 'hive',|    'uri' = 'thrift://bigdata04:9083',|    'warehouse'='hdfs://bigdata01:9000/paimon'|)|""".stripMargin)tEnv.executeSql("USE CATALOG paimon_hive_catalog")//创建Paimon表tEnv.executeSql("""|CREATE TABLE IF NOT EXISTS p_h_par(|    id INT,|    name STRING,|    dt STRING,|    PRIMARY KEY (id, dt) NOT ENFORCED|) PARTITIONED BY (dt) WITH(|    'metastore.partitioned-table' = 'true'|)|""".stripMargin)//向表中插入数据tEnv.executeSql("""|INSERT INTO p_h_par(id,name,dt)|VALUES(1,'jack','20230101'),(2,'tom','20230102')|""".stripMargin)}}

在idea中执行代码。

然后到hive中进行验证,可以执行show partitions p_h_par;进行验证。

或者到hive metastore里面进行确认,查看mysql中的partitions表,这个表里面存储的是分区信息,如果能看到分区信息,就说明Paimon表的分区信息同步过来了。
在这里插入图片描述

这样就说明Paimon表的分区信息同步过来了。

更多Paimon数据湖内容请关注:https://edu.51cto.com/course/35051.html

http://www.wangmingla.cn/news/80388.html

相关文章:

  • 做国学类网站合法吗无货源网店怎么开
  • 玉溪网站设计最近新闻今日头条
  • 网站推广只能使用在线手段进行口碑营销属于什么营销
  • 做网站开发哪里好福建网站建设制作
  • 山西做网站怎么做搜索引擎入口yandex
  • 怎么做移动端网站计算像素软文推荐
  • 网站建设维护是做什么会计科目软件培训机构
  • 湖州建设局网站杭州产品推广服务公司
  • 外贸网站建设推广公司前景如何seo矩阵培训
  • 网站迁移后 域名百度指数与百度搜索量
  • 汕头网站设计价格一站式网站设计
  • 成都龙泉建设局网站山东服务好的seo
  • 网站建设私活中能找关键词整站优化公司
  • 微网站可以做成域名访问高级搜索入口
  • 大渡口网站建设哪家好全网推广平台
  • 武汉做网站企业浏览器直接进入网站的注意事项
  • wordpress调用子分类seo咨询师
  • 推广型的网站怎么做网站域名解析
  • 怎么做充值网站seo流量增加软件
  • 沈阳工程建设信息网站网络营销策划目的
  • 连连跨境电商网站开发怎么制作一个网页
  • 烟台哪儿有可以做淘宝网站的爱站站长工具
  • 郑州网站排名哪家好百度app广告
  • 网站党建专栏建设方案全网营销系统是干什么的
  • 一个好的网站应该具有什么条件搜索引擎优化举例说明
  • db11t 221-2008政府网站建设与管理规范seo优化网站查询
  • 网站建设方案word软文世界官网
  • 可以做设计兼职的网站有哪些工作室留号码的广告网站
  • 在哪个网站做注册资本变更seo云优化软件
  • 有没有做公务员题的网站武汉做seo