【问题标题】:AWS Glue Python Shell Job Connect Timeout ErrorAWS Glue Python Shell 作业连接超时错误
【发布时间】:2020-06-16 23:05:17
【问题描述】:

尝试运行 AWS Glue Python Shell 作业,但出现连接超时错误

错误图片:https://i.stack.imgur.com/MHpHg.png

脚本:https://i.stack.imgur.com/KQxkj.png

【问题讨论】:

  • 图片中有相关信息。如果他们离线,问题的上下文将会丢失。此外,其他人不会搜索相同的问题。

标签: amazon-web-services etl aws-glue


【解决方案1】:

您似乎没有将 secretsmanager 端点添加到您的 VPC。由于流量不会离开AWS network,因此您的 Glue 作业的 VPC 内将无法访问 Internet。因此,如果您想连接到 secretsmanager,则需要将其添加到您的 VPC。

请参阅 this 了解如何将其添加到您的 VPC 和 this 以确保您已正确配置安全组。

【讨论】:

  • 太棒了!现在工作。另外,感谢 Prabhakar 的解释!
  • @Atul 我收到了类似的错误,但端点 URL 不同。端点 URL:“glue.eu-central-1.amazonaws.com”可能是什么原因?请帮忙
【解决方案2】:

AWS Glue Git Issue

嗨, 我们让 AWS Glue Python Shell 与所有依赖项一起工作,如下所示。 Glue 具有 awscli 依赖项以及 boto3

带有互联网的 AWS Glue Python Shell

在 Glue 作业执行期间将 awscli 和 boto3 whl 文件添加到 Python 库路径。这个选项很慢,因为它必须下载和安装依赖项。

  1. 下载以下 whl 文件
  1. 将文件上传到给定 python 库路径中的 s3 存储桶
  2. 在 Python 库路径中添加 s3 whl 文件路径。给出整个 whl 文件 s3 引用的路径,用 逗号 分隔

没有互联网连接的 AWS Glue Python Shell

参考AWS Wrangler Glue dependency build

  1. 我们对 awscliboto3 whl 文件执行了上述步骤
  2. 以下是为最新版本编译的最新 requirements.txt
colorama==0.4.3
docutils==0.15.2
rsa==4.5.0
s3transfer==0.3.3
PyYAML==5.3.1
botocore==1.19.23
pyasn1==0.4.8
jmespath==0.10.0
urllib3==1.26.2
python_dateutil==2.8.1
six==1.15.0
  1. 将依赖项下载到 libs 文件夹
pip download -r requirements.txt -d libs
  1. 将原来的主 whl 文件也移动到 lib 目录中
  1. 打包为 zip 文件
cd libs zip ../boto3-depends.zip *
  1. boto3-depends.zip 上传到 s3 并将路径添加到 Glue 作业 参考文件路径 注意:它是引用文件路径,而不是Python 库路径

  2. 用于安装最新的 awcli 和 boto3 并加载到 AWS Python Glue Shell 的占位符代码。

import os.path
import subprocess
import sys

# borrowed from https://stackoverflow.com/questions/48596627/how-to-import-referenced-files-in-etl-scripts
def get_referenced_filepath(file_name, matchFunc=os.path.isfile):
for dir_name in sys.path:
candidate = os.path.join(dir_name, file_name)
if matchFunc(candidate):
return candidate
raise Exception("Can't find file: ".format(file_name))

zip_file = get_referenced_filepath("awswrangler-depends.zip")

subprocess.run()

# Can't install --user, or without "-t ." because of permissions issues on the filesystem
subprocess.run(, shell=True)

#Additonal code as part of AWS Thread https://forums.aws.amazon.com/thread.jspa?messageID=954344
sys.path.insert(0, '/glue/lib/installation')
keys =
for k in keys:
if 'boto' in k:
del sys.modules[k]

import boto3
print('boto3 version')
print(boto3.__version__)
  1. 检查代码是否与最新的 AWS CLI API 一起使用

谢谢 萨拉特

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-23
    • 2022-01-09
    • 2020-05-11
    • 1970-01-01
    • 1970-01-01
    • 2019-02-21
    相关资源
    最近更新 更多