从 Hive 到 Druid 交互时出错

Error when interacting from Hive to Druid

我正在尝试从 Hive 创建 Druid 数据源,我正在使用 table Hive。

首先,我创建了一个数据库Hive:database_hive然后,我在这个数据库中创建了一个table。

CREATE TABLE database_hive.hive_table (
    timemachine int,
    userId String,
    lang String,
    location String,
    name String,
    network String,
    posted String,
    sentiment String,
    text String,
);

第二次,我尝试使用 hive_table 在 Druid 上创建一个新的数据源。

SET hive.druid.broker.address.default = 10.1.123.30:8082; --fake ip for example
SET hive.druid.metadata.username = druid;
SET hive.druid.metadata.password = druidpassword;
SET hive.druid.metadata.db.type = derby;
SET hive.druid.metadata.uri = jdbc:mysql://10.1.123.30:3306/druid?createDatabaseIfNoExist=true;

CREATE TABLE druid_table
STORED BY 'org.apache.hadoop.hive.druid.DruidStorageHandler'
TBLPROPERTIES (
    "druid.segment.granularity" = "MONTH",
    "druid.query.granularity" = "DAY")
    AS
    SELECT
    cast(timemachine as timestamp) as `__time`,   
    cast(userId as string) userId,
    cast(lang as string) lang,
    cast(location as string) location,
    cast(name as string) name,
    cast(network as string) network,
    cast(posted as string) posted,
    cast(sentiment as string) sentiment,
    cast(text as string) text
    FROM hive_table
;

这个查询return我出错了:

Error: Error while processing statement: FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. org.skife.jdbi.v2.exceptions.UnableToObtainConnectionException: java.sql.SQLException: Cannot create JDBC driver of class 'org.apache.derby.jdbc.ClientDriver' for connect URL 'jdbc:mysql://10.1.123.30:3306/druid?createDatabaseIfNoExist=true' (state=08S01,code=1)

在我的 Hive 存储库中,我 mysql-connector-java.jar 所以我不明白问题出在哪里。我尝试了一些我在其他主题上阅读的建议,但没有找到解决方案。 有人有建议吗?

感谢帮助!

问题出在您的 Druid 元数据数据库配置中。 Hive 需要访问 Druid 用来存储所有元数据的关系数据库。在Druid端可以设置为derby,但是Derby就像SQLite一样,Hive无法访问。因此,Hive 不允许 derby 作为 hive.druid.metadata.db.type 属性 的有效参数。唯一允许的是 mysqlpostgresql.

因此,要解决此问题,您需要:

  • 确保您的 Druid 集群使用 MySQL 或 PSQL 进行元数据存储
  • hive.druid.metadata.db.type 设置为正确的数据库类型
  • 设置hive.druid.metadata.uri以更正数据库url