hadoop - 从 Hive 到 Druid 交互时出错
问题描述
我正在尝试从 Hive 创建一个 Druid 数据源,并且我正在使用表 Hive。
首先,我创建了一个数据库 Hive:database_hive
然后,我在这个数据库中创建了一个表。
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
;
此查询返回一个错误:
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 用来存储所有元数据的关系数据库。可以derby
在 Druid 端设置,但是 Derby 就像 SQLite,所以不能被 Hive 访问。因此,Hive 不允许derby
作为hive.druid.metadata.db.type
属性的有效参数。唯一允许的是mysql
和postgresql
。
因此,要解决此问题,您需要:
- 确保您的 Druid 集群使用 MySQL 或 PSQL 进行元数据存储
- 设置
hive.druid.metadata.db.type
为正确的数据库类型 - 设置
hive.druid.metadata.uri
为正确的数据库 url
推荐阅读
- java - 处理函数什么都不做,只是冻结程序
- java - 重构进行 DB 调用的 java 代码的最佳方法
- python - Gnuradio:1 个样本的 FFT 图
- javascript - 如何使用 nextjs 更新状态?
- snowflake-cloud-data-platform - 如何在 Snowflake 的仪表板中指定自由文本输入
- flutter - 使用 REST API (Flutter) 添加和删除标签
- javascript - 如果元素在另一个数组中,则过滤数组
- kubernetes - 使用 Rancher UI 安装 Longhorn 时出现“OutOfCpu”错误
- python - 如何从 QTableWidget 读取 QCheckbox 状态
- c++ - 使用 Emscripten 构建时出现链接器错误