【问题标题】:Error Mounting ADLS on DBFS for Databricks (Error: NullPointerException)在 DBFS 上为 Databricks 安装 ADLS 时出错(错误:NullPointerException)
【发布时间】:2021-05-10 16:49:35
【问题描述】:

我正在尝试在 Databricks 中安装 Azure Data Lake Gen 2,但出现以下错误。

java.lang.NullPointerException: authEndpoint

我使用的代码如下所示

configs = {
  "fs.azure.account.auth.type": "OAuth",
  "fs.azure.account.auth.provider.type": "org.apache.hadoop.fs.azurebfs.ClientCredsTokenProvider",
  "fs.azure.account.auth2.client.id": "<client-id>",
  "fs.azure.account.auth2.client.secret": dbutils.secrets.get(scope = "scope1", key = "kvsecretfordbricks"),
  "dfs.adls.oauth2.refresh.url": "https://login.microsoftonline.com/<tenant-id>/oauth2/token"}

dbutils.fs.mount(
    source = "abfss://starter1@newresourcegroupadcadls.dfs.core.windows.net/",
    mount_point = "/mnt/demo",
  extra_configs = configs)

下面给出了完整的错误

----------------------------------- ---------------------------- ExecutionError Traceback(最近调用 最后)在 9 来源 =“abfss://starter1@newresourcegroupadcadls.dfs.core.windows.net/”, 10 mount_point = "/mnt/demo", ---> 11 个额外配置 = 配置)

/local_disk0/tmp/1612619970782-0/dbutils.py f_with_exception_handling(*args, **kwargs) 312 exc.上下文 = 无 313 exc.原因 = 无 --> 314 提高 exc 第315章 316

ExecutionError:调用 o271.mount 时出错。 : java.lang.NullPointerException:authEndpoint 在 shaded.databricks.v20180920_b33d810.com.google.common.base.Preconditions.checkNotNull(Preconditions.java:204) 在 shaded.databricks.v20180920_b33d810.org.apache.hadoop.fs.azurebfs.oauth2.AzureADAuthenticator.getTokenUsingClientCreds(AzureADAuthenticator.java:84) 在 com.databricks.backend.daemon.dbutils.DBUtilsCore.verifyAzureOAuth(DBUtilsCore.scala:477) 在 com.databricks.backend.daemon.dbutils.DBUtilsCore.verifyAzureFileSystem(DBUtilsCore.scala:488) 在 com.databricks.backend.daemon.dbutils.DBUtilsCore.mount(DBUtilsCore.scala:446) 在 sun.reflect.GeneratedMethodAccessor292.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 在 java.lang.reflect.Method.invoke(Method.java:498) 在 py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:244) 在 py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:380) 在 py4j.Gateway.invoke(Gateway.java:295) 在 py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132) 在 py4j.commands.CallCommand.execute(CallCommand.java:79) 在 py4j.GatewayConnection.run(GatewayConnection.java:251) 在 java.lang.Thread.run(Thread.java:748)

任何帮助将不胜感激

当我跑步时

dbutils.fs.unmount("/mnt")

没有以“/mnt”开头的挂载点

--

更新

dfs.adls.oauth2.refresh.url 更新为fs.azure.account.oauth2.client.endpoint 后的附加错误消息

ExecutionError Traceback(最近调用 最后)在 9 来源 =“abfss://starter1@newresourcegroupadcadls.dfs.core.windows.net/”, 10 mount_point = "/mnt/demo", ---> 11 个额外配置 = 配置)

/local_disk0/tmp/1612858508533-0/dbutils.py 在 f_with_exception_handling(*args, **kwargs) 312 exc.上下文 = 无 313 exc.原因 = 无 --> 314 提高 exc 第315章 316

ExecutionError:调用 o275.mount 时出错。 : java.lang.NullPointerException:clientId 在 shaded.databricks.v20180920_b33d810.com.google.common.base.Preconditions.checkNotNull(Preconditions.java:204) 在 shaded.databricks.v20180920_b33d810.org.apache.hadoop.fs.azurebfs.oauth2.AzureADAuthenticator.getTokenUsingClientCreds(AzureADAuthenticator.java:85) 在 com.databricks.backend.daemon.dbutils.DBUtilsCore.verifyAzureOAuth(DBUtilsCore.scala:477) 在 com.databricks.backend.daemon.dbutils.DBUtilsCore.verifyAzureFileSystem(DBUtilsCore.scala:488) 在 com.databricks.backend.daemon.dbutils.DBUtilsCore.mount(DBUtilsCore.scala:446) 在 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 在 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 在 java.lang.reflect.Method.invoke(Method.java:498) 在 py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:244) 在 py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:380) 在 py4j.Gateway.invoke(Gateway.java:295) 在 py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132) 在 py4j.commands.CallCommand.execute(CallCommand.java:79) 在 py4j.GatewayConnection.run(GatewayConnection.java:251) 在 java.lang.Thread.run(Thread.java:748)

【问题讨论】:

    标签: azure azure-active-directory databricks azure-data-lake


    【解决方案1】:

    如果要将 Azure Data Lake Storage Gen2 帐户挂载到 DBFS,请将 dfs.adls.oauth2.refresh.url 更新为 fs.azure.account.oauth2.client.endpoint。更多详情请参考official documenthere

    例如

    1. 创建一个 Azure Data Lake Storage Gen2 帐户。
    az login
    az storage account create \
        --name <account-name> \
        --resource-group <group name> \
        --location westus \
        --sku Standard_RAGRS \
        --kind StorageV2 \
        --enable-hierarchical-namespace true
    
    1. 创建服务主体并将 Storage Blob Data Contributor 分配给 Data Lake Storage Gen2 存储帐户范围内的 sp
    az login
    
    az ad sp create-for-rbac -n "MyApp" --role "Storage Blob Data Contributor" \
        --scopes /subscriptions/<subscription>/resourceGroups/<resource-group>/providers/Microsoft.Storage/storageAccounts/<storage-account>
    
    1. 在 Azure Databricks 中创建 Spark 集群

    2. 在 Azure databricks(python) 中装载 Azure 数据湖 gen2

    configs = {"fs.azure.account.auth.type": "OAuth",
               "fs.azure.account.oauth.provider.type": "org.apache.hadoop.fs.azurebfs.oauth2.ClientCredsTokenProvider",
               "fs.azure.account.oauth2.client.id": "<application-id>",
               "fs.azure.account.oauth2.client.secret": dbutils.secrets.get(scope="<scope-name>",key="<service-credential-key-name>"),
               "fs.azure.account.oauth2.client.endpoint": "https://login.microsoftonline.com/<directory-id>/oauth2/token"}
    
    # Optionally, you can add <directory-name> to the source URI of your mount point.
    dbutils.fs.mount(
      source = "abfss://<file-system-name>@<storage-account-name>.dfs.core.windows.net/",
      mount_point = "/mnt/demo",
      extra_configs = configs)
    

    1. 检查
    dbutils.fs.ls("/mnt/demo")
    

    【讨论】:

    • 谢谢。将dfs.adls.oauth2.refresh.url 更新为fs.azure.account.oauth2.client.endpoint 现在收到错误消息“java.lang.NullPointerException”客户端ID 绝对正确,有什么想法吗?
    • @user15037183 能否提供完整的错误信息?
    • ExecutionError:调用 o275.mount 时出错。 : java.lang.NullPointerException: clientId 在 shaded.databricks.v20180920_b33d810.com.google.common.base.Preconditions.checkNotNull(Preconditions.java:204)
    • 因为完整的错误信息很长 - 我已经在原帖中包含了上面(见底部,更新部分)
    • @user15037183 根据报错,好像是client id不对吧?你能检查一下吗?
    猜你喜欢
    • 1970-01-01
    • 2020-05-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-02-09
    • 1970-01-01
    • 2016-12-25
    • 2020-12-07
    相关资源
    最近更新 更多