flink集成hive 启动:flink-sql 报错:
./sql-client.sh embedded
报错如下:
2021-12-18 17:49:42,129 INFO org.apache.hadoop.hive.conf.HiveConf [] - Found configuration file file:/home/hadoop/apps/hive-3.1.2/conf/hive-site.xml
Exception in thread "main" org.apache.flink.table.client.SqlClientException: Unexpected exception. This is a bug. Please consider filing an issue.
at org.apache.flink.table.client.SqlClient.main(SqlClient.java:215)
Caused by: org.apache.flink.table.client.gateway.SqlExecutionException: Could not create execution context.
at org.apache.flink.table.client.gateway.local.ExecutionContext$Builder.build(ExecutionContext.java:972)
at org.apache.flink.table.client.gateway.local.LocalExecutor.openSession(LocalExecutor.java:225)
at org.apache.flink.table.client.SqlClient.start(SqlClient.java:108)
at org.apache.flink.table.client.SqlClient.main(SqlClient.java:201)
Caused by: java.lang.IllegalArgumentException: Embedded metastore is not allowed. Make sure you have set a valid value for hive.metastore.uris
at org.apache.flink.util.Preconditions.checkArgument(Preconditions.java:138)
at org.apache.flink.table.catalog.hive.HiveCatalog.<init>(HiveCatalog.java:182)
at org.apache.flink.table.catalog.hive.HiveCatalog.<init>(HiveCatalog.java:168)
at org.apache.flink.table.catalog.hive.HiveCatalog.<init>(HiveCatalog.java:164)
at org.apache.flink.table.catalog.hive.factories.HiveCatalogFactory.createCatalog(HiveCatalogFactory.java:89)
at org.apache.flink.table.client.gateway.local.ExecutionContext.createCatalog(ExecutionContext.java:396)
at org.apache.flink.table.client.gateway.local.ExecutionContext.lambda$null$5(ExecutionContext.java:684)
at java.util.HashMap.forEach(HashMap.java:1288)
at org.apache.flink.table.client.gateway.local.ExecutionContext.lambda$initializeCatalogs$6(ExecutionContext.java:681)
at org.apache.flink.table.client.gateway.local.ExecutionContext.wrapClassLoader(ExecutionContext.java:265)
at org.apache.flink.table.client.gateway.local.ExecutionContext.initializeCatalogs(ExecutionContext.java:677)
at org.apache.flink.table.client.gateway.local.ExecutionContext.initializeTableEnvironment(ExecutionContext.java:565)
at org.apache.flink.table.client.gateway.local.ExecutionContext.<init>(ExecutionContext.java:187)
at org.apache.flink.table.client.gateway.local.ExecutionContext.<init>(ExecutionContext.java:138)
at org.apache.flink.table.client.gateway.local.ExecutionContext$Builder.build(ExecutionContext.java:961)
... 3 more
原因:
Flink 集成 Hive 时,不支持 embedded metastore 的, 需要起一个hive metastore 并在conf文件配置,在server端中,hive.metastore.uris为none,在client端中,hive.metastore.uris要配置相应的值: 如 thrift://192.168.56.101:9083
首先查配置文件,需要在hive-site.xml中添加下面的依赖
<property>
<name>hive.metastore.uris</name>
<value>thrift://192.168.56.101:9083</value>
</property>
然后启动 nohup hive --service metastore >/dev/null 2>&1 &
再启动 nohup hive --service hiveserver2 >/dev/null 2>&1 &