Apache Airflow 无法通过 FTP/SFTP 建立到远程主机的连接
Apache Airflow unable to establish connect to remote host via FTP/SFTP
我是 Apache Airflow 的新手,到目前为止,我已经能够解决遇到的问题。
我现在碰壁了。我需要通过 sftp 将文件传输到远程服务器。我没有运气这样做。到目前为止,我已经通过各自的挂钩获得 S3 和 Postgres/Redshift 连接,以在各种 DAG 中工作。我已经能够在本地 FTP 服务器上使用 FTPHook 并成功测试,但无法弄清楚如何使用 SFTP 连接到远程主机。
我可以使用 FileZilla 通过 SFTP 连接到远程主机,所以我知道我的凭据是正确的。
通过 Google 搜索,我找到了 SFTPOperator, but am not able to figure out how to use it. I have also found FTPSHook,但我仍然无法使用它。
我的 Airflow 日志中不断收到错误 nodename nor servname provided, or not known
或一般 Operation timed out
。
有人能指出我正确的方向吗?我应该使用带 SSH 的 FTPSHook 还是 FTP Airflow Conn Type?还是我需要使用 SFTPOperator?我也对应该如何在我的 Airflow 连接中设置凭据感到困惑。我是使用 SSH 配置文件还是 FTP?
如果我能提供更多可能有用的信息,请告诉我。
干杯!
SFTPOperator
正在使用 ssh_hook
底层打开 sftp 传输通道,作为文件传输的基础。您可以自己配置 ssh_hook
或通过 ssh_conn_id
.
提供连接 ID
op = SFTPOperator(
task_id="test_sftp",
ssh_conn_id="my_ssh_connection",
local_filepath="",
remote_filepath="",
operation=SFTPOperation.PUT,
dag=dag
)
我是 Apache Airflow 的新手,到目前为止,我已经能够解决遇到的问题。
我现在碰壁了。我需要通过 sftp 将文件传输到远程服务器。我没有运气这样做。到目前为止,我已经通过各自的挂钩获得 S3 和 Postgres/Redshift 连接,以在各种 DAG 中工作。我已经能够在本地 FTP 服务器上使用 FTPHook 并成功测试,但无法弄清楚如何使用 SFTP 连接到远程主机。
我可以使用 FileZilla 通过 SFTP 连接到远程主机,所以我知道我的凭据是正确的。
通过 Google 搜索,我找到了 SFTPOperator, but am not able to figure out how to use it. I have also found FTPSHook,但我仍然无法使用它。
我的 Airflow 日志中不断收到错误 nodename nor servname provided, or not known
或一般 Operation timed out
。
有人能指出我正确的方向吗?我应该使用带 SSH 的 FTPSHook 还是 FTP Airflow Conn Type?还是我需要使用 SFTPOperator?我也对应该如何在我的 Airflow 连接中设置凭据感到困惑。我是使用 SSH 配置文件还是 FTP?
如果我能提供更多可能有用的信息,请告诉我。
干杯!
SFTPOperator
正在使用 ssh_hook
底层打开 sftp 传输通道,作为文件传输的基础。您可以自己配置 ssh_hook
或通过 ssh_conn_id
.
op = SFTPOperator(
task_id="test_sftp",
ssh_conn_id="my_ssh_connection",
local_filepath="",
remote_filepath="",
operation=SFTPOperation.PUT,
dag=dag
)