airflow和MySQL_airflow快速安装——MySQL

本文档详细介绍了如何在系统中安装和配置Airflow与MySQL,包括升级pip和setuptools,安装必要的开发库,创建数据库和用户,安装Airflow,编辑配置文件,初始化数据库,并解决安装过程中遇到的问题,如MySQL组件缺失。最后,启动Airflow的web服务器和调度器,以及防止密码明文存储的方法。
摘要由CSDN通过智能技术生成

1) 进行pip的更新,否则很多安装会报错

pip install --upgrade pip

pip install --upgrade setuptools

2) 安装开发库

yum install python3-devel

yum install libevent-devel

yum install mysql-devel

3) 创建airflow的MySQL数据库schema及用户

create database apache_airflow;

create user 'airflow'@'%' identified by '123123';

GRANT all privileges on apache_airflow.* TO 'airflow'@'%' IDENTIFIED BY '123123';

FLUSH PRIVILEGES;

set explicit_defaults_for_timestamp = 1; --这一行至关重要

4) 安装airflow

# airflow 需要 home 目录,默认是~/airflow,

# 但是如果你需要,放在其它位置也是可以的

# (可选)

export AIRFLOW_HOME = ~/airflow

# 使用 pip 从 pypi 安装

pip3 install apache-airflow

5) 编辑airflow.cfg配置文件,一般在~/airflow/airflow.cfg

#sql_alchemy_conn = sqlite:data/airflow/airflow.db

sql_alchemy_conn = mysql://airflow:123456@127.0.0.1:3306/apache_airflow

6) 初始化MySQL数据库

> airflow initdb

Traceback (most recent call last):

File "/usr/local/bin/airflow", line 25, in

from airflow.configuration import conf

File "/usr/local/lib/python3.6/site-packages/airflow/__init__.py", line 47, in

settings.initialize()

File "/usr/local/lib/python3.6/site-packages/airflow/settings.py", line 405, in initialize

configure_orm()

File "/usr/local/lib/python3.6/site-packages/airflow/settings.py", line 294, in configure_orm

engine = create_engine(SQL_ALCHEMY_CONN, connect_args=connect_args, **engine_args)

File "/usr/local/lib64/python3.6/site-packages/sqlalchemy/engine/__init__.py", line 500, in create_engine

return strategy.create(*args, **kwargs)

File "/usr/local/lib64/python3.6/site-packages/sqlalchemy/engine/strategies.py", line 87, in create

dbapi = dialect_cls.dbapi(**dbapi_args)

File "/usr/local/lib64/python3.6/site-packages/sqlalchemy/dialects/mysql/mysqldb.py", line 118, in dbapi

return __import__("MySQLdb")

ModuleNotFoundError: No module named 'MySQLdb'

说明缺少MySQL组件

> yum install -y mysql-devel

> pip3 install pymysql

> pip3 install mysql

> airflow initdb

DB: mysql://airflow:***@10.1.11.12:3306/shark_airflow

[2020-08-27 09:25:52,760] {db.py:378} INFO - Creating tables

INFO [alembic.runtime.migration] Context impl MySQLImpl.

INFO [alembic.runtime.migration] Will assume non-transactional DDL.

WARNI [airflow.models.crypto] cryptography not found - values will not be stored encrypted.

/usr/local/lib/python3.6/site-packages/airflow/models/dag.py:1342: PendingDeprecationWarning: The requested task could not be added to the DAG because a task with task_id create_tag_template_field_result is already in the DAG. Starting in Airflow 2.0, trying to overwrite a task will raise an exception.

category=PendingDeprecationWarning)

Done.

7) 启动web服务器和调度器

> airflow webserver -p 8080

> airflow scheduler

8) 防止密码明文存储

pip3 install cryptography

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值