airflow 部署


環境 :

ubuntu 14.04 LTS

python 2.7

script:

設置環境變量:

export AIRFLOW_HOME=~/airflow

 

安裝相關依賴包:

sudo apt-get install python-dev
sudo apt-get install python-numpy
sudo pip install airflow
sudo pip install markupsafe
sudo pip install sqlalchemy
sudo pip install dateutil
sudo pip install mako
sudo pip install werkzeug
sudo pip install itsdangerous
sudo pip install wtforms
sudo pip uninstall python-daemon
sudo pip install python-daemon
sudo apt-get install python-pandas

最后兩行代碼解決這個問題:https://issues.apache.org/jira/browse/AIRFLOW-344

 

之后修改配置文件,不讓加載hive相關東東。

vi ~/airflow/airflow.cfg

第62行:

load_examples = False

 

初始化默認數據庫:

airflow initdb

 

運行web服務器

airflow webserver -p 8080

可能還需要安裝一個包

sudo pip install flask_wtf

 

效果圖:

 

運行helloworld (tutorial.py)python ~/airflow/dags/tutorial.py

如果任務看到了,但沒執行,看這里:https://airflow.incubator.apache.org/faq.html#why-isn-t-my-task-getting-scheduled

 

發現hello world一直沒有執行, 手工執行了一把,說要celeryExecutor

於是裝唄

sudo pip install 'airflow[mysql,celery]'

 celery需要celery包,默認backend用redis

sudo pip install celery
sudo pip install redis

以及重裝pandas(celery 需要 0.15.2 以上版本, apt-get install默認為0.13)

sudo pip install pandas

會有警告,最終提示成功。

 

重啟所有服務:

airflow initdb
airflow worker
airflow webserver -p 8080
airflow scheduler

 

如果順利,重新手動執行任務,將會看到以下頁面:

 

附帶核心配置文件改動處: ~/airflow/airflow.cfg

[core]
executor = CeleryExecutor
sql_alchemy_conn=mysql://airflow:airflow@localhost:3306/airflow
load_examples = False
[celery]
broker_url = redis://127.0.0.1:6379/5
celery_result_backend = redis://127.0.0.1:6379/6

ps:

1.需要安裝mysql,新建airflow數據庫,創建用戶airflow,密碼airflow

2.需要安裝redis(本例中是無密碼的)

3.如果嫌部署麻煩, 可以考慮下docker 鏡像: https://hub.docker.com/r/puckel/docker-airflow/

4. 在centos6.8上裝特別順利(運行時貌似一切都正常,就是任務一直處於running狀態---debug了一番源代碼, 發現內存要必需夠大,發現必需用非root身份運行airflow worker, 務必保證核數夠用,否則需要調低dag_concurrency, max_active_runs_per_dag,max_threads,parallelism, 否則worker出現莫名其妙的問題)

 worker 服務本身啟動celery的消費進程。

 scheduler服務啟動celery的生產者進程。

 webserver則展現web頁面,可有可無。

5. 登錄驗證, 參考這里:http://pythonhosted.org/airflow/security.html?highlight=authentication#web-authentication

先:

sudo pip install airflow[password]

6. airflow跑着跑着就掛了,一看內存還夠用(可能需要不要錢的加內存),如果你到處找不到想要的錯誤日志。那么看看AIRFLOW_HOME下面是不是莫名其妙的多了幾個 .err/.out 的文件,進去看看會有收獲。

7. executor用LocalExecutor可能相對穩定。 celeryExecutor貌似各種問題(https://www.mail-archive.com/commits@airflow.incubator.apache.org/msg03411.html)(出問題的系統:centos 6.8 Final)

也許跟系統有關。。。。

====

轉載請注明來源:http://www.cnblogs.com/Tommy-Yu/p/6230527.html

謝謝!


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM