2016-04-24 54 views
5

我尝试配置的Airbnb气流这样使用CeleryExecutor工作:配置气流与CeleryExecutor

我在airflow.cfg改变了executerSequentialExecutorCeleryExecutor

# The executor class that airflow should use. Choices include 
# SequentialExecutor, LocalExecutor, CeleryExecutor 
executor = CeleryExecutor 

,但我得到出现以下错误:

airflow.configuration.AirflowConfigException: error: cannot use sqlite with the CeleryExecutor 

请注意,sql_alchemy_conn是这样配置的:

sql_alchemy_conn = sqlite:////root/airflow/airflow.db 

我看着气流的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'))) 

从这个validate方法,该sql_alchemy_conn不能包含sqlite看起来。

您是否知道如何配置没有sqllite的CeleryExecutor?请注意,我根据需要下载了rabitMQ与CeleryExecuter一起工作。

回答

13

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

airflow.cfgsql_alchemy_conn必须改变,以遵循SQLAlchemy的连接字符串结构(见SqlAlchemy document

例如,

sql_alchemy_conn = postgresql+psycopg2://airflow:[email protected]:5432/airflow 
+0

我可以知道如何添加mysql连接,而不是postgresql – abhijeetmote

+0

@abhijeetmote msql连接字符串为sqlalchemy可以像'mysql:// username:password @ hostname:port/database_name' – nehiljain

1

要想为mysql 配置气流首先安装mysql this might help或者它只是谷歌

  • goto airflow installation director usu盟友的/ home //气流
  • 编辑airflow.cfg
  • 定位

    sql_alchemy_conn =源码:////家/ VIPUL /通风/气流。DB

,并在它前面加上#所以它看起来像

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

,如果您有默认的SQLite

  • 下面添加

    sql_alchemy_conn = mysql的这一行: //:@ localhost:3306/

  • 文件保存

  • 运行命令

    气流initdb的

,做!

1

正如其他答案所述,除了SQLite之外,还需要使用其他数据库。此外,您需要安装rabbitmq,并对其进行适当配置,然后更改airflow.cfg中的每个文件以获取正确的rabbitmq信息。有关这方面的优秀教程,请参阅A Guide On How To Build An Airflow Server/Cluster