TOPIC

磷光与烟火逆流

一个敲代码的程序猿

Linux(rethat)安装airflow(踩坑记录)

参考博客

https://www.cnblogs.com/lyhtbc/p/airflow-spark-schedule.html
汉化
https://blog.csdn.net/zwahut/article/details/90602476?utm_medium=distribute.pc_aggpage_search_result.none-task-blog-2
官方文档
https://airflow.apache.org/docs/apache-airflow/stable/start/local.html

安装:

系统 rethat6.5
python3.6.8 推荐3.7+
airflow 2.2.3

创建环境:

python3 -m venv airflow
source airflow/bin/activate

最好升级下pip
pip3 install --upgrade pip

开始安装:

# 指定airflow 配置相关文件目录
export AIRFLOW_HOME=~/airflow

# 安装apache-airflow
pip3 install apache-airflow

# 修改配置用于连接mysql
vim $AIRFLOW_HOME/airflow.cfg
# sql_alchemy_conn = mysql://username:password@host:3306/database
sql_alchemy_conn = mysql://airflow:password@localhost:3306/airflow

# 连接mysql,创建database 和 user 
# 创建airflow user
create user 'airflow'@'%' identified by 'password';
grant all privileges on airflow.* to 'airflow'@'%';
flush privileges;
# 或者是 set global explicit_defaults_for_timestamp = 1;
set explicit_defaults_for_timestamp = 1;  
# 切换 airflow 用户 创建 airflow database
create database airflow CHARACTER SET = utf8mb4;
# 注意mysql 版本 mysql5.1 就不支持 utf8mb4 建议5.6 及以上


# 初始化airflow数据库
airflow db init  # 这里可能会出现 need global explicit_defaults_for_timestamp on (1) 使用注释的那一句 set global  explicit_defaults_for_timestamp 
# 创建airflow 用户
airflow users create \
    --username admin \
    --password admin \
    --firstname Peter \
    --lastname Parker \
    --role Admin \
    --email xxxxxxx.com

# 启动 airflow
airflow webserver --port 8080
这里会报错 nomodel named MySQLdb 
rethat6.5 python3解决方案:
    `pip install mysqlclient==1.4.4`
    直接安装新版本编译出错
ubuntu python3:
    `sudo apt-get install python3-mysqldb`

# 启动scheduler
airflow scheduler

简单安装完成快去登录吧
localhost:8080

使用Celery 的坑

如果

设置 executor = CeleryExecutor 之后 启动 worker
airflow celery worker
报错 no model named psycopg2
pip install psycopg2 gcc报错
pip install psycopg2-binary gcc报错
需要升级 postgresql >=9.1
升级postgresql相关
参考:
CSDN

airflow webserver -D
airflow scheduler -D
airflow celery worker -D
airflow celery flower -D

进一步详细的请参考官方文档(上文第三个链接)和博客 (上文第一个链接)

功能说明解释:
http://t.zoukankan.com/braveym-p-11428952.html
https://www.cnblogs.com/cord/p/9450910.html

posted @ 2021-12-28 19:43  Jacobyang  阅读(385)  评论(0编辑  收藏  举报