flink对接hive

环境准备

  • MacOS
  • flink1.11.1

集成hive

  1. 配置sql-client-hive.yaml cp $FLINK_HOME/conf/sql-client-defaults.yaml $FLINK_HOME/conf/sql-client-hive.yaml
  2. 准备hive-site.xml文件
  3. 修改配置文件
catalogs: 
  - name: myhive
    type: hive
    hive-conf-dir: /usr/local/flink-1.11.0/hive_conf
    hive-version: 1.1.1
execution:
  type: batch
  1. 拷贝jar包 wget https://repo.maven.apache.org/maven2/org/apache/flink/flink-sql-connector-hive-2.3.6_2.11/1.11.1/flink-sql-connector-hive-2.3.6_2.11-1.11.1.jar hive-exec-2.3.6.jar

  2. 启动flink start-cluster.sh

  3. 启动sql-client sql-client.sh embedded -d $FLINK_HOME/conf/sql-client-hive.yaml -l $FLINK_HOME/lib

  4. 查询结果

use catalog myhive;
show databases;
use test;
describe records;

select * from test.records;