apache-spark - 创建 Google Dataproc 集群并连接到外部远程 Hive 元存储
问题描述
我正在尝试创建一个 dataproc 集群并指向一个远程 Hive 元存储,以便从该集群访问 Hive 表。我正在使用以下创建集群命令来创建一个连接到远程 Hive 元存储的 Dataproc 2.0 集群:
创建集群命令:
gcloud dataproc clusters create wl1-cluster-1 \
--region us-east1 \
--subnet projects/shared-vpc-admin/regions/us-east1/subnetworks/dev-us-east1-01 \
--enable-component-gateway \
--no-address \
--scopes 'https://www.googleapis.com/auth/cloud-platform' \
--master-machine-type n1-standard-32 \
--master-boot-disk-size 1000 \
--num-workers 10 \
--worker-machine-type n1-standard-32 \
--worker-boot-disk-size 1000 \
--image-version 2.0-debian10 \
--properties 'spark:spark.sql.hive.metastore.version=2.3.0,spark:spark.sql.hive.metastore.jars=maven,hive:hive.metastore.schema.verification=false,hive:javax.jdo.option.ConnectionURL=jdbc:mysql://test-mysql.gcp-dev.glb.us.mycompany.net:3306/metastore,hive:javax.jdo.option.ConnectionUserName=metastore,hive:javax.jdo.option.ConnectionPassword=XXXX' \
--project sample_gcp_project
但它在步骤激活组件配置单元元存储期间失败。
错误信息:
<13>Sep 10 05:47:06 google-dataproc-startup[1734]: <13>Sep 10 05:47:06 activate-component-hive-metastore[3064]: nc: connect to wl1-cluster-1-m port 9083 (tcp) failed: Connection refused
<13>Sep 10 05:47:07 google-dataproc-startup[1734]: <13>Sep 10 05:47:07 activate-component-hive-metastore[3064]: nc: connect to wl1-cluster-1-m port 9083 (tcp) failed: Connection refused
<13>Sep 10 05:47:07 google-dataproc-startup[1734]: <13>Sep 10 05:47:07 activate-component-hive-metastore[3064]: 'nc -v -z -w 1 wl1-cluster-1-m 9083' attempt 23 failed! Sleeping 1s.
几个问题:
- 这是在创建集群时连接到远程配置单元元存储的正确且唯一的方法吗?
- 我可以从从该集群提交的 Spark 作业访问配置单元元存储,而不是配置连接到远程配置单元元存储的集群。你能指出我正确的方向吗?
- 有没有其他方法可以解决这个问题?
解决方案
默认情况下,有一个 Metastore 服务在 Dataproc 集群的(第一个)主节点上运行,默认端口为 9083,Hive Server2 配置为使用它。在/etc/hive/conf/hive-site.xml
中,您会发现:
<property>
<name>hive.metastore.uris</name>
<value>thrift://<master-hostname>:9083</value>
</property>
如果您需要集群的 HiveServer2:
要使用另一个集群的 Metastore,请设置
--properties hive:hive.metastore.uris=thrift://<another-cluster-master-hostname>:9083
.或要使用托管 Dataproc Metastore 服务,请按照以下说明操作,例如:
gcloud dataproc clusters create example-cluster \
--dataproc-metastore=projects/PROJECT_ID/locations/LOCATION/services/example-service \
--region=LOCATION
集群/Metastore 需要在同一个 VPC 网络中,才能通过内部 IP(或主机名)相互通信。
集群中的 Spark 会自动配置为使用 Hive 配置hive.metastore.uris
来查找 Metastore,您不需要在 Spark 代码中进行任何其他配置。
推荐阅读
- java - 如何将日期时间字符串转换为“yyyy-MM-dd'T'HH:mm:ss.SSSSSSSSSZ”
- javascript - 使用反应和时刻的计时器
- orm - 使用django查询某个操作的q时出现意外情况
- opengl - 用什么着色器来计算关于图元的东西?
- java - 在“何时”块中运行 Platform.runLater() 的 Spock 计时问题
- html - Angular 2+ 中的 NgStyle 不考虑输入参数中的 0(零)
- c - 我是一名学生,当我包含像 stdio.h 这样的库时,我无法在 C (visual studio) 中运行程序
- node.js - 我安装了 ESM,现在我想删除它
- sql - Liquibase 在 SQL 之前生成 /(斜杠)
- python - 编写在 Python 中执行相同操作的函数和方法的正确方法