Flink整合Hive所需要的依赖jar包
flink-sql-connector-hive-3.1.2_2.12-1.14.5.0.jar(FlinkSQL必选)
hive-exec-3.1.2.jar(必选)
flink-connector-hive_2.12-1.14.5.jar(可选,用于DataStream API)
注意:把上述jar包放入到$FLINK_HOME/lib
目录下,重启Flink集群即可。
在Flink中创建元数据库myhive
#创建Flink的元数据库
CREATE CATALOG myhive WITH (
'type'='hive',
'hive-conf-dir'='/export/server/hive/conf',
'hive-version'='3.1.2',
'hadoop-conf-dir'='/export/server/hadoop/etc/hadoop/'
);
USE CATALOG myhive;
使用
- 使用之前,需要启动服务
#启动HDFS
start-all.sh
#2.启动Hive
nohup hive --service metastore > /tmp/hive-metastore.log &
nohup hive --service hiveserver2 > /tmp/hive-hiveserver2.log &
#3.启动Flink
start-cluster.sh<