【问题标题】:Azure Databricks external Hive MetastoreAzure Databricks 外部 Hive 元存储
【发布时间】:2021-02-08 19:07:25
【问题描述】:

我查看了有关 Azure Databricks 外部 Hive Metastore(Azure SQL 数据库)使用情况的 [文档][1]。

我能够下载 jar 并将它们放入 /dbfs/hive_metastore_jar

我的下一步是使用初始化文件运行集群:

# Hive-specific configuration options.
# spark.hadoop prefix is added to make sure these Hive specific options propagate to the metastore client.
# JDBC connect string for a JDBC metastore
spark.hadoop.javax.jdo.option.ConnectionURL jdbc:sqlserver://<host>.database.windows.net:1433;database=<database> #should I add more parameters?

# Username to use against metastore database
spark.hadoop.javax.jdo.option.ConnectionUserName admin

# Password to use against metastore database
spark.hadoop.javax.jdo.option.ConnectionPassword p@ssword

# Driver class name for a JDBC metastore
spark.hadoop.javax.jdo.option.ConnectionDriverName com.microsoft.sqlserver.jdbc.SQLServerDriver

# Spark specific configuration options
spark.sql.hive.metastore.version 2.7.3 #I am not sure about this
# Skip this one if <hive-version> is 0.13.x.
spark.sql.hive.metastore.jars /dbfs/hive_metastore_jar 

我已将 ini 文件上传到 DBMS 并启动集群。无法读取ini。有问题.. [1]:https://docs.microsoft.com/en-us/azure/databricks/data/metastores/external-hive-metastore

【问题讨论】:

  • 请发布错误跟踪。很可能是与 SQL 服务器的连接问题。用%sh nc -vz &lt;host&gt;.database.windows.net 1433检查它
  • 谢谢你,亚历克斯。防火墙没问题。我发布了详细的问题和解决方案。

标签: databricks azure-databricks


【解决方案1】:

我现在解决了这个问题。我遇到的问题:

  1. 我没有将 Hive jar 复制到本地集群。这很重要,我无法参考 DBMS,应该将 spark.sql.hive.metastore.jars 参考 Hive 的本地副本。使用 INI 脚本,我可以复制它们。
  2. 连接良好。我也使用了Azure template with Vnet,它更可取。然后,我使用数据块允许来自我的 Vnet 的 Azure SQL 流量。
  3. 最后一期 - 我必须在启动 databricks 之前创建 Hive 架构,然后使用 Hive 版本 1.2 从 Git 复制并运行 DDL 我将它部署到 Azure SQL 数据库中,然后我就可以开始了。

有一个有用的笔记本,其中包含download jars 的步骤。它正在将 jars 下载到 tmp 然后我们应该将其复制到自己的文件夹中。最后,在集群创建中,我们应该参考具有所有参数的 INI 脚本。它具有将jar从DBFS复制到集群本地文件系统的步骤。

// This example is for an init script named `external-metastore_hive121.sh`.
dbutils.fs.put(
    "dbfs:/databricks/scripts/external-metastore_hive121.sh",
    """#!/bin/sh
      |# A temporary workaround to make sure /dbfs is available.
      |sleep 10
      |# Copy metastore jars from DBFS to the local FileSystem of every node.
      |cp -r /dbfs/metastore_jars/hive-v1_2/* /databricks/hive_1_2_1_metastore_jars
      |# Loads environment variables to determine the correct JDBC driver to use.
      |source /etc/environment
      |# Quoting the label (i.e. EOF) with single quotes to disable variable interpolation.
      |cat << 'EOF' > /databricks/driver/conf/00-custom-spark.conf
      |[driver] {
      |    # Hive specific configuration options.
      |    # spark.hadoop prefix is added to make sure these Hive specific options will propagate to the metastore client.
      |    # JDBC connect string for a JDBC metastore
      |    "spark.hadoop.javax.jdo.option.ConnectionURL" = "jdbc:sqlserver://host--name.database.windows.net:1433;database=tcdatabricksmetastore_dev;encrypt=true;trustServerCertificate=false;hostNameInCertificate=*.database.windows.net"
      |
      |    # Username to use against metastore database
      |    "spark.hadoop.javax.jdo.option.ConnectionUserName" = "admin"
      |
      |    # Password to use against metastore database
      |    "spark.hadoop.javax.jdo.option.ConnectionPassword" = "P@ssword"
      |
      |    # Driver class name for a JDBC metastore
      |    "spark.hadoop.javax.jdo.option.ConnectionDriverName" = "com.microsoft.sqlserver.jdbc.SQLServerDriver"
      |
      |    # Spark specific configuration options
      |    "spark.sql.hive.metastore.version" = "1.2.1"
      |    # Skip this one if ${hive-version} is 0.13.x.
      |    "spark.sql.hive.metastore.jars" = "/databricks/hive_1_2_1_metastore_jars/*"
      |}
      |EOF
      |""".stripMargin,
    overwrite = true)

该命令将在 DBFS 中创建一个文件,我们将使用它作为集群创建的参考。

根据文档,我们应该使用config:

datanucleus.autoCreateSchema true
datanucleus.fixedDatastore false 

为了创建 Hive DDL。它对我不起作用,这就是我使用 git 并自己创建架构和表的原因。

您可以使用命令测试所有功能:

%sql show databases

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-04
    • 1970-01-01
    • 1970-01-01
    • 2021-12-24
    • 2021-05-21
    相关资源
    最近更新 更多