2016-04-24 65 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