flink安装以及sql连接hive

官网下载flink

根据官方文档进行安装

flink运行wordCount

代码在https://ci.apache.org/projects/flink/flink-docs-release-1.10/getting-started/tutorials/local_setup.html 官方教程

    public static void main(String[] args) throws Exception {

        // the port to connect to
        int port;
        try {
            final ParameterTool params = ParameterTool.fromArgs(args);
            port = params.getInt("port");
        } catch (Exception e) {
            System.err.println("No port specified. Please run 'SocketWindowWordCount --port '");
            port = 19090;
            //注释return,让其没有port的时候默认19090;
//            return;
        }

windows版本

打开cmd 输入命令 nc -l -p 19000

linux版本

输入 nc -l 19000
注:先运行nc监听,再运行java程序。

flink连接hive

1.修改配置文件/flink-1.9.2/conf/sql-client-defaults.yaml

需要复制修改,不可在原基础上改

catalogs:
# catalogs 名称
  - name: myhive
# catalog连接类型
    type: hive
# hive 安装路径下conf目录路径
    hive-conf-dir: /usr/local/hive-1.2.1/conf
# hive 版本号
    hive-version: 1.2.1
    property-version: 1
# use catalog 后 默认连接的数据库名
    default-database: hj

flink连接hive官方参考文档
flinkjar包下载

https://repo.maven.apache.org/maven2/org/apache/flink/flink-shaded-hadoop-2-uber/2.8.3-9.0/

  1. Jar包准备
    在{flink-home}/lib目录下放入以下jar包:
    hive-2.1.0-bin/lib/hive-exec-2.1.0.jar
    {flink-compile-home}/flink-connectors/flink-connector-hive/target/flink-connector-hive_2.11-1.11-SNAPSHOT.jar
    {flink-shaded-9.0-compile-home}/…/flink-shaded-hadoop-2-uber-3.0.0-cdh6.1.0-9.0.jar

版本要正确

参考博客
以下为依赖列表
flink安装以及sql连接hive_第1张图片效果
flink安装以及sql连接hive_第2张图片

你可能感兴趣的:(flink安装以及sql连接hive)