无法通过 JDBC 连接到 emr-6.9.0 上的 hiveserver2

问题描述 投票:0回答:0

尝试连接到启用 SSL 的 EMR 集群时,我不断收到 无效状态 21。主节点未在 10001 上侦听(连接被拒绝),端口 10000 似乎也不起作用。尝试过各种组合。

java -Djavax.net.debug=all -Djavax.net.ssl.trustStore=keystore-thrift.jks -Djavax.net.ssltrustStorePassword=mypassword -cp dependencies.jar myclass "jdbc:hive2://mydns:10000/default?hive.execution.engine=tez;ssl=true;sslTrustStore=keystore-thrift.jks;trustStorePassword=mypassword"

错误:

Exception in thread "main" java.sql.SQLException: Could not open client transport with JDBC Uri: jdbc:hive2://mydns:10000/default?hive.execution.engine=tez&useSSL=true: Invalid status 21

Java代码:

    private static String driverName = "org.apache.hive.jdbc.HiveDriver";

    public static void main(String[] args) throws SQLException, ClassNotFoundException {

        Class.forName(driverName);
        
        Statement stmt = null;
        ResultSet res = null;

        Connection con = DriverManager.getConnection(args[0], "", "");
        stmt = con.createStatement();


        res = stmt.executeQuery("SELECT \"hi\"");
        res.next();
        System.out.println(res.getString(1));
        con.close();

    }

相关emr配置:


<property>
   <name>hive.server2.allow.user.substitution</name>
   <value>true</value>
</property>

<property>
   <name>hive.server2.enable.doAs</name>
   <value>true</value>
</property>

<property>
   <name>hive.server2.thrift.port</name>
   <value>10000</value>
</property>

<property>
   <name>hive.server2.thrift.http.port</name>
   <value>10001</value>
</property>

 <property>
  <name>hive.server2.use.SSL</name>
  <value>true</value>
</property>

<property>
  <name>hive.server2.keystore.path</name>
  <value>/usr/share/aws/emr/security/conf/keystore-thrift.jks</value>
</property>

<property>
  <name>hive.server2.keystore.password</name>
  <value>mypassword</value>
</property>



java ssl hive amazon-emr hiveserver2
© www.soinside.com 2019 - 2024. All rights reserved.