简体   繁体   English

我的Hive客户端停止使用Cosmos实例

[英]My Hive client stopped working with Cosmos instance

I have a Hive client (written in Java) that worked just fine with the Global Instance of Cosmos at FIWARE Lab. 我有一个Hive客户端(用Java编写),可以与FIWARE Lab的Cosmos全局实例完美配合。 However, it is not working anymore, it seems the client cannot connect (it times out). 但是,它不再起作用,似乎客户端无法连接(超时)。

Has anything changed on the server-side? 服务器端发生了什么变化?

This is because the Global Instance of Cosmos at FIWARE Lab has been upgraded and now HiveServer2 is being run on the server side of Hive. 这是因为FIWARE Lab的Cosmos全局实例已升级,并且HiveServer2现在正在Hive的服务器端运行。 Thus, everything in your code is still valid except for the following: 因此,除以下内容外,代码中的所有内容仍然有效:

  • Load org.apache.hive.jdbc.HiveDriver instead of org.apache.hadoop.hive.jdbc.HiveDriver . 加载org.apache.hive.jdbc.HiveDriver而不是org.apache.hadoop.hive.jdbc.HiveDriver
  • Change the JDBC connection schema from jdbc:hive to jdbc:hive2 将JDBC连接模式从jdbc:hive更改为jdbc:hive2
  • Change your Hive dependencies to 0.13.0 version. 将您的Hive依赖项更改为0.13.0版本。

I mean, the code should finally have the following aspect: 我的意思是,代码最终应该具有以下方面:

try {
    // dynamically load the Hive JDBC driver
    Class.forName("org.apache.hive.jdbc.HiveDriver");
} catch (ClassNotFoundException e) {
    System.out.println(e.getMessage());
    return null;
} // try catch

try {
    // return a connection based on the Hive JDBC driver
    return DriverManager.getConnection("jdbc:hive2://" + hiveServer + ":" + hivePort,
            hadoopUser, hadoopPassword);
} catch (SQLException e) {
    System.out.println(e.getMessage());
    return null;
} // try catch

Regarding the dependencies, if using for instance Maven, your pom.xml should contain something like: 关于依赖关系,如果使用例如Maven,则pom.xml应包含以下内容:

...
<dependencies>
  ...
  <dependency>
    <groupId>org.apache.hive</groupId>
    <artifactId>hive-exec</artifactId>
    <version>0.13.0</version>
  </dependency>
  <dependency>
    <groupId>org.apache.hive</groupId>
    <artifactId>hive-jdbc</artifactId>
    <version>0.13.0</version>
  </dependency>
  ...
</dependencies>
...

Finally, if using a JSON-like format, you will need to add the JSON serde. 最后,如果使用类似JSON的格式,则需要添加JSON serde。 From the Hive CLI this is pretty simple: 在Hive CLI中,这非常简单:

hive> add JAR /usr/local/apache-hive-0.13.0-bin/lib/json-serde-1.3.1-SNAPSHOT-jar-with-dependencies.jar;

From you Hive client, just execute an update sentence with the above command. 从您的Hive客户端,只需使用以上命令执行更新语句即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM