当有任务正在运行时,Airflow 会弹出一个通知,说调度程序似乎没有运行,并且一直显示直到任务完成:
The scheduler does not appear to be running. Last heartbeat was received 5 minutes ago.
The DAGs list may not update, and new tasks will not be scheduled.
Run Code Online (Sandbox Code Playgroud)
实际上,调度程序进程正在运行,因为我已经检查了该进程。任务完成后,通知消失,一切恢复正常。
我的任务有点重,可能要运行几个小时。
Joh*_*ist 15
一个快速解决方案可能是单独运行气流调度程序。也许不是最好的解决方案,但它确实对我有用。为此,请在终端中运行以下命令:
airflow scheduler
Run Code Online (Sandbox Code Playgroud)
Jar*_*iuk 14
我认为这是 Sequential Executor 所期望的。Sequential Executor 一次只运行一件事,所以它不能同时运行心跳和任务。
为什么需要使用 Sequential Executor / Sqlite?切换到其他 DB/Executor 的建议非常有意义。
我遇到过同样的问题。我通过更新airflow.cfg
文件 >sql_alchemy_conn =postgresql+psycopg2://airflow@localhost:5432/airflow
和executor = LocalExecutor
此链接可能有助于如何在本地进行设置 https://medium.com/@taufiq_ibrahim/apache-airflow-installation-on-ubuntu-ddc087482c14
我遇到了类似的问题,并且已经尝试解决此问题有一段时间了。
我设法通过在airflow.cfg中设置这个值来修复它:
scheduler_health_check_threshold = 240
PS:根据 Airflow Slack 社区最近的一次对话,这可能是由于数据库端的争用而发生的。因此,建议的另一个解决方法是scale up
数据库。就我而言,这不是一个可行的解决方案。
编辑:这是最后使用 Airflow 版本 2.3.3 进行的测试
你已经开始了airflow webserver
,你还没有开始你的airflow scheduler
. 在后台运行气流调度程序
airflow scheduler > /console/scheduler_log.log &
Run Code Online (Sandbox Code Playgroud)
我在使用 sqlite 时遇到了同样的问题。Airflow 日志中有一条特殊消息:ERROR - Cannot use more than 1 thread when using sqlite. Setting max_threads to 1
。如果仅使用 1 个线程,则调度程序在执行 dag 时将不可用。
所以如果使用sqlite,请尝试切换到另一个数据库。如果不这样做,请max_threads
检查airflow.cfg
.