1. 启动flink集群
bin/start-cluster.sh

2. 启动sql gateway
bin/sql-gateway.sh start -Dsql-gateway.endpoint.type=hiveserver2


3. 将flink-sql-jdbc-driver-bundle-1.18.0.jar放到apache-hive-3.1.2-bin/lib目录下


4. 到apache-hive-3.1.2-bin目录下启动beeline连接sql gateway,提示输入用户名和密码时直接按的回车
$ bin/beeline 
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in 
[jar:file:/Users/admin/dev/hadoop-3.3.4/share/hadoop/common/lib/slf4j-reload4j-1.7.36.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in 
[jar:file:/Users/admin/dev/apache-hive-3.1.2-bin/lib/log4j-slf4j-impl-2.10.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Reload4jLoggerFactory]
Beeline version 3.1.2 by Apache Hive
beeline> !connect jdbc:flink://localhost:8083
Connecting to jdbc:flink://localhost:8083
Enter username for jdbc:flink://localhost:8083: 
Enter password for jdbc:flink://localhost:8083: 
Failed to create the executor.
0: jdbc:flink://localhost:8083 (closed)> CREATE TABLE T(
. . . . . . . . . . . . . . . . . . . .>   a INT,
. . . . . . . . . . . . . . . . . . . .>   b VARCHAR(10)
. . . . . . . . . . . . . . . . . . . .> ) WITH (
. . . . . . . . . . . . . . . . . . . .>   'connector' = 'filesystem',
. . . . . . . . . . . . . . . . . . . .>   'path' = 'file:///tmp/T.csv',
. . . . . . . . . . . . . . . . . . . .>   'format' = 'csv'
. . . . . . . . . . . . . . . . . . . .> );
Failed to create the executor.
Connection is already closed.

回复