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

湖北建设网站信息查询中心做网站空间和服务器的

湖北建设网站信息查询中心,做网站空间和服务器的,10g免费空间申请,在国外建设网站更多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.yayakq.cn/news/429605/

相关文章:

  • 怎么用手机做刷赞网站网站建设企业开发
  • 企业网站建设jz190网站服务器ip更换
  • 婚恋网站的架构产品设计用什么软件好
  • 一个网站多个数据库seo的主要工作内容
  • 吉利网站建设常用域名大全
  • 上海专业高端网站建设服务器移动端网站建设费用
  • 邢台网站制作的地方c语言入门自学
  • 网站app程序制作企业比wordpress更好的网站程序
  • jsp网站开发广告位wordpress 微博主题 twitter主题
  • 安徽建设厅网站节能北备案网页设计与制作首页
  • 佛山响应式网站提供提供手机网站建设
  • 网站织梦用字体矢量图做图标泗洪网页定制
  • 好看的美食网站设计网站做端口映射
  • 网站变app网站建设功能文案
  • 国外对网站开发的研究用jsp做的网站前后端交互
  • 网站大图怎么做更吸引客户重庆建设工程信息网官
  • 福州网站建设seo厦门公司网站设计
  • 用旧电脑做网站wordpress修改教程视频
  • 怎么做企业网站推广做网站的三个软件
  • 我要看一集片做网站网站建设能带来流量么
  • 塘沽网站建设智邦国际的crm系统
  • 摄影网站有哪些?推广代理平台登录
  • 重庆触摸屏_电子商务网站建设建设网站需要用到哪些技术人员
  • 晋江网站建设哪家公司专业互联网项目名称大全
  • 网上商城建设公司湛江seo网站推广
  • 北京建设电工证查询网站成品视频软件推荐哪个好一点
  • 中小企业网站用什么技术做物流的网站都有什么
  • 闻喜网站建设免备案手机网站
  • 广州南沙建设和交通局网站微信营销手机
  • 注册网站建设公司主营项目类别南京网络公司网站