Iceberg从入门到精通系列之七:Flink SQL创建Catalog

一、语法说明

create catalog <catalog_name> with (
 'type'='iceberg',
 `<config_key>`=`<config_value>`
);
  • type:必须是iceberg
  • catalog-type:内置了hive和hadoop两种catalog,也可以使用catalog-impl来自定义catalog。
  • catalog-impl:自定义catalog实现的全限定类名。如果未设置catalog-type,则必须设置。
  • property-version:描述属性版本的版本号。此属性可用于向后兼容,以防属性格式更改。当前属性版本为1.
  • cache-enabled:是否启用目录缓存,默认值为true。
  • cache.expiration-interval-ms:本地缓存catalog条目的时间(以毫秒为单位)。负值,如-1表示没有时间限制,不允许设为0,默认值为-1。

二、flink集成hive jar包

下载jar包:

三、放到指定目录

cp flink-sql-connector-hive-3.1.2_2.11.jar /module/flink-1.17.1/lib/

四、启动hive metastore服务

hive --service metastore

五、创建hive catalog

重启flink 集群,重新进入sql-client

CREATE CATALOG hive_catalog WITH (
	'type'='iceberg',
	'catalog-type'='hive',
	'url'='thrift://hadoop1:9083',
	'clients'='5',
	'property-version'='1',
	'warehouse'='hdfs://hadoop1:8020/warehouse/iceberg-hive'
);

use catalog hive_ccatalog;
  • url:Hive metastore的thrift url
  • clients:Hive metastore客户端池大小,默认为2
  • warehouse:数仓目录
  • hive-conf-dir:包含hive-site.xml配置文件的目录路径,hive-site.xml中hive.metastore.warehouse.dir的值会被warehouse覆盖
  • hadoop-conf-dir:包含core-site.xml和hdfs-site.xml配置文件的目录路径

六、查看catalog

show catalogs;


show current catalog; 

七、Hadoop Catalog

Iceberg还支持HDFS中基于目录的catalog,可以使用‘catalog-type’='hadoop’配置

create catalog hadoop_catalog with(
'type'='iceberg',
'catalog-type'='hadoop',
'warehouse'='hdfs://hadoop1:8020/warehouse/iceberg-hadoop',
'property-version'='1'
);

use catalog hadoop_catalog;
  • warehouse:存放元数据文件和书籍文件的HDFS目录。

八、创建sql-client初始化文件

vim sql-client-init.sql

CREATE CATALOG hive_catalog WITH (
	'type'='iceberg',
	'catalog-type'='hive',
	'url'='thrift://hadoop1:9083',
	'clients'='5',
	'property-version'='1',
	'warehouse'='hdfs://hadoop1:8020/warehouse/iceberg-hive'
);

create catalog hadoop_catalog with(
'type'='iceberg',
'catalog-type'='hadoop',
'warehouse'='hdfs://hadoop1:8020/warehouse/iceberg-hadoop',
'property-version'='1'
);

use catalog hive_ccatalog;

九、启动flink sql指定初始化文件

bin/sql-client.sh -i conf/sql-client-init.sql

猜你喜欢

转载自blog.csdn.net/zhengzaifeidelushang/article/details/131471570