Airflow 安装教程

ⅰ亾dé卋堺 提交于 2019-11-29 15:49:34

说明:

 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

参考:https://airflow.readthedocs.io/en/stable/faq.html#how-to-fix-exception-global-variable-explicit-defaults-for-timestamp-needs-to-be-on-1

重新初始化 airflow 数据库

airflow initdb

airflow webserver -p 8080

airflow scheduler

启动完成即可访问页面

 

参考:http://airflow.apache.org/installation.html

 

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!