配置Airflow以使用CeleryExecutor

Ela*_*dor 10 airflow

我尝试配置Airbnb AirFlow以使用CeleryExecutor,如下所示:

executer将airflow.cfg中的更改SequentialExecutorCeleryExecutor:

# The executor class that airflow should use. Choices include
# SequentialExecutor, LocalExecutor, CeleryExecutor
executor = CeleryExecutor
Run Code Online (Sandbox Code Playgroud)

但是我收到以下错误:

airflow.configuration.AirflowConfigException: error: cannot use sqlite with the CeleryExecutor
Run Code Online (Sandbox Code Playgroud)

请注意,sql_alchemy_conn配置如下:

sql_alchemy_conn = sqlite:////root/airflow/airflow.db
Run Code Online (Sandbox Code Playgroud)

我查看了Airflow的GIT(https://github.com/airbnb/airflow/blob/master/airflow/configuration.py)

并发现以下代码抛出此异常:

def _validate(self):
        if (
                self.get("core", "executor") != 'SequentialExecutor' and
                "sqlite" in self.get('core', 'sql_alchemy_conn')):
            raise AirflowConfigException("error: cannot use sqlite with the {}".
                format(self.get('core', 'executor')))
Run Code Online (Sandbox Code Playgroud)

从这种validate方法看来,sql_alchemy_conn不能包含sqlite.

你知道如何配置CeleryExecutor没有sqllite吗?请注意,我根据需要下载了rabitMQ以使用CeleryExecuter.

小智 18

据AirFlow称,CeleryExecutor需要其他后端而不是默认数据库SQLite.例如,您必须使用MySQLPostgreSQL.

sql_alchemy_connairflow.cfg必须改变,以遵循SQLAlchemy的连接字符串结构(见SQLAlchemy的文件)

例如,

sql_alchemy_conn = postgresql+psycopg2://airflow:airflow@127.0.0.1:5432/airflow
Run Code Online (Sandbox Code Playgroud)


小智 5

要为mysql配置Airflow,首先安装mysql 可能会有所帮助,或者只是谷歌搜索它

  • goto气流安装主管通常是/ home // airflow
  • 编辑airflow.cfg
  • 定位

    sql_alchemy_conn = sqlite:////home/vipul/airflow/airflow.db

并在它前面添加#

#sql_alchemy_conn = sqlite:////home/vipul/airflow/airflow.db 
Run Code Online (Sandbox Code Playgroud)

如果您有默认的sqlite

  • 在下面添加此行

    sql_alchemy_conn = mysql://:@localhost:3306 /

  • 保存文件

  • 运行命令

    气流initdb

并做了 !