flink1.16 系统集成了 sql gateway 功能

# flink1.16 系统集成了 sql gateway 功能,其中包括两种方式,1. rest 2.hiveserver2

# 测试 read write. hive iceberg 都可以

# 一 、 启动集群,standlone 和yarn session 方式 ,一般都使用 yarn session

# 使用jdk11,不过测试使用jdk1.8的也可行

# 默认使用 flink-conf.yaml 中配置的 8081 端口通信,可以修改

# 使用的jar 都放在 lib 下,单独添加好像加不进去 --jar

export JAVA_HOME=/home/devuser/jdk-11

yarn application -kill application_1675063912055_540438

/opt/flink-1.16.0/bin/yarn-session.sh -s 5 -jm 2048 -tm 8192 -nm session-t6-63 -qu root.REALTIME -d


 

# 二、 启动 sql gateway

# https://nightlies.apache.org/flink/flink-docs-release-1.16/docs/dev/table/sql-gateway/overview/

# 测试使用 start-foreground ,可以动态看到格式化的日志打印情况,正常启动使用 start

# 需要添加 jar

# flink-connector-hive_2.12-1.16.0.jar

# flink-sql-connector-hive-2.3.9_2.12-1.16.0.jar

# hive-exec-2.1.1-cdh6.0.1.jar

# flink-shaded-hadoop-2-uber-2.7.5-10.0.jar

# 1. rest 方式

/opt/flink-1.16.0/bin/sql-gateway.sh \

start-foreground \

-Dsql-gateway.endpoint.rest.address=localhost \

-Dsql-gateway.session.check-interval=10min

# 2. hiveserver2 方式

# https://nightlies.apache.org/flink/flink-docs-release-1.16/zh/docs/dev/table/hive-compatibility/hiveserver2/

/opt/flink-1.16.0/bin/sql-gateway.sh start-foreground \

-Dsql-gateway.session.check-interval=10min \

-Dsql-gateway.endpoint.type=hiveserver2 \

-Dsql-gateway.endpoint.hiveserver2.catalog.hive-conf-dir=/opt/conf \

-Dsql-gateway.endpoint.hiveserver2.catalog.default-database=test003 \

-Dsql-gateway.endpoint.hiveserver2.catalog.name=hive \

-Dsql-gateway.endpoint.hiveserver2.module.name=hive


 

# 三、使用 sql gateway

1. 创建 session

curl --request POST http://localhost:8083/v1/sessions

2. 通过 session 执行 sql

curl --request POST http://localhost:8083/v1/sessions/983c9253-d292-43e1-827e-56615679ea3f/statements/ --data '{"statement": "select * from tmp.bb;"}'

statement:

CREATE CATALOG my_hive WITH ('type' = 'hive','default-database' = 'test003','hive-conf-dir' = '/opt/conf');

CREATE CATALOG my_hive WITH ('type' = 'hive','default-database' = 'test003','hive-conf-dir' = '/opt/conf');

CREATE CATALOG my_iceberg WITH ('type' = 'iceberg','catalog-type'='hive','uri'='thrift://10.8.49.114:9083,thrift://10.8.49.115:9083','clients'='5','property-version'='1','hive-conf-dir' = '/opt/conf');

USE CATALOG my_hive;

USE CATALOG my_iceberg;

select * from my_hive.tmp.bb;

3. 查询结果

curl --request GET http://localhost:8083/v1/sessions/983c9253-d292-43e1-827e-56615679ea3f/operations/c3e0b2e0-34e4-4d39-a132-301073fcec50/result/0

返回结果很有意思

"resultType": "PAYLOAD", 是有效的,

"resultType": "EOS", nextResultUri 为空了

首次执行 都是以 /result/0 查询,下面会返回 nextResultUri 地址,当前session 下一次结果查询的地址, 这个地方很有意思

通过 status = FINISHED 判断任务执行完成情况

curl --request GET http://localhost:8083/v1/sessions/983c9253-d292-43e1-827e-56615679ea3f/operations/c3e0b2e0-34e4-4d39-a132-301073fcec50/status


 

4. beeline 的方式操作

./beeline

!connect jdbc:hive2://localhost:10000/test003;auth=noSasl


 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值