概览
创建 Managed Service for Apache Spark 集群时,系统会在集群上安装 Apache Hive 应用及其组件(包括 Hive metastore),并且会在位于集群主服务器上的 hive-site.xml 文件中设置默认密码。
建议您指定自己的 Hive metastore 密码,以实现以下目标:
作为最佳实践安全措施,通过提供您自己的密码来确保您可以控制对本地 Hive metastore 的访问权限
指定用于控制对外部 Hive metastore(与不同集群之间共享的外部数据库搭配使用)的访问权限的已知密码。
设置 Hive metastore 密码
运行以下 Google Cloud CLI Managed Service for Apache Spark clusters create 命令,以创建 Managed Service for Apache Spark 集群并指定 Hive metastore 密码。
gcloud dataproc clusters create cluster-name --properties="hive:javax.jdo.option.ConnectionPassword=HIVE_METASTORE_PASSWORD"
注意:
- 如需在 Cloud Key Management Service 中创建密钥,请参阅创建密钥。
- Hive metastore 密码仅存储在集群主节点上,而非工作器节点上。
如需详细了解如何保护 Managed Service for Apache Spark 集群,请参阅 Managed Service for Apache Spark 安全最佳实践。
不支持的场景
无论您使用的是默认的 Hive metastore 密码还是用户提供的 Hive metastore 密码,Managed Service for Apache Spark 都不支持以下 Hive metastore 场景:
您在以集群模式运行的 Spark 驱动程序中使用嵌入式 metastore 客户端,因此工作器节点需要 Hive 密码。由于连接不是通过在 Managed Service for Apache Spark 主节点上运行的
HiveMetaStore进程建立的,因此此场景可能会导致 metastore 数据库出现连接问题。停用 Hive metastore 和
hive-server2,以使用您自己的 MySQL 数据库。在此场景中,spark.hadoop.javax.jdo.option.ConnectionURL=jdbc:mysql://CLUSTER_NAME-m/metastore属性不起作用。