說明:
Airflow 的安裝需要依賴 Python3.0 及以上版本,Python3.0的安裝教程見:(https://blog.csdn.net/CZ_yjsy_data/article/details/100776239)
在線安裝步驟:
安裝最新穩定版本的Airflow最簡單的方法是使用pip:
一:airflow needs a home, ~/airflow is the default ,but you can lay foundation somewhere else if you prefer export AIRFLOW_HOME=~/airflow 二:install from pypi using pip pip3 install apache-airflow 三:initialize the database airflow initdb 四:start the web server, default port is 8080 airflow webserver -p 8080 五:start the scheduler airflow scheduler visit localhost:8080 in the browser and enable the example dag in the home page
pip3 install apache-airflow 執行完如下所示:
根據自己的需求安裝Airflow 額外功能,如gcp或postgres:
執行: pip3 install apache-airflow[postgres,gcp]
若想安裝所有的額外包,執行:
pip install apache-airflow[all]
執行完上述步驟後即可訪問頁面,如下圖:
這裏安裝完成所用的數據庫爲:SQLite, 官網建議使用 MySQL or Postgres
這裏我們介紹如何使用MySQL 數據庫
在MySQL 中創建 AIRFLOW 的數據庫,並賦予 airflowdb 用戶訪問該數據庫的權限:
create database airflowdb;
grant all PRIVILEGES on airflowdb.* to airflow@'localhost' identified by 'pwd';
cd 到 $AIRFLOW_HOME 目錄下,
vim airflow.cfg, 修改如圖的地方
在 my.cnf 文件後面追加: explicit_defaults_for_timestamp = 1
sudo vim /etc/my.cnf
重啓MySQL 服務:systemctl restart mysqld
重新初始化 airflow 數據庫
airflow initdb
airflow webserver -p 8080
airflow scheduler
啓動完成即可訪問頁面
參考:http://airflow.apache.org/installation.html