ubuntu安装airflow 2.6.3

发布时间 2023-10-26 09:40:28作者: 有鹏自远方来
用的是docker容器安装-系统是ubuntu 因为centos的python环境特恶心
容器里先换apt源-这里自己找百度吧
apt install python3-pip
python3 -m pip install --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simple
安装指定版本
pip3 install apache-airflow==2.6.3 -i https://pypi.tuna.tsinghua.edu.cn/simple
一般情况不会有报错
如果缺少依赖就安装相应依赖就行,我用ubuntu没有遇到这种问题,centos就是各种问题
安装完成后运行输出命令airflow
输出没有报错
Usage: airflow [-h] GROUP_OR_COMMAND ...
Positional Arguments:
GROUP_OR_COMMAND
Groups: celery Celery components config View configuration connections Manage connections dags Manage DAGs db Database operations jobs Manage jobs kubernetes Tools to help run the KubernetesExecutor pools Manage pools providers Display providers roles Manage roles tasks Manage tasks users Manage users variables Manage variables Commands: cheat-sheet Display cheat sheet dag-processor Start a standalone Dag Processor instance info Show information about current Airflow and environment kerberos Start a kerberos ticket renewer plugins Dump information about loaded plugins rotate-fernet-key Rotate encrypted connection credentials and variables scheduler Start a scheduler instance standalone Run an all-in-one copy of Airflow sync-perm Update permissions for existing roles and optionally DAGs triggerer Start a triggerer instance version Show the version webserver Start a Airflow webserver instance
Optional Arguments:
-h, --help show this help message and exit
 
就是正常的
然后初始化airflow(我用的是mysql的外部数据库,需修改配置文件)
vim airflow.cfg
sql_alchemy_conn = mysql+pymysql://root:xxx@xxx/airflow ##这个airflow确保是空库===========pymysql这个插件根据自己喜好选择 我用的是pymysql而已
开始初始化
airflow db init
一般第一次执行 都没有啥报错 如果有提示没有pymysql 模块 就直接安装一个
继续初始化
然后启动webserver
airflow webserver -D
如果提示:No user yet created, use flask fab command to do it.
就新建一个user
airflow users create --username admin --firstname admin --lastname admin --role Admin --email xxx@xxxx.com
如果啥都不提示 但是8080端口又没有监听
查看日志err日志文件
一般都是pid已存在,直接删除 重新启动就行
使用方面
如果觉得单线路执行很慢
就要去修改执行器配置
executor = LocalExecutor
速度起飞但是很耗资源
还有就是分布式执行器,这个我就不在这里说了