1、我使用的是miniconda3创建的python3.7.12环境
2、配置mysql5.7环境;
#安装mysql依赖
sudo yum -y install python-devel libevent-devel mysql-devel mysqlclient
pip install mysqlclient pymysql mysql
#修改mysql参数
vi /etc/my.cnf
explicit_defaults_for_timestamp=1
#创建个airflow的用户,airflow数据库
mysql -uroot -p
CREATE DATABASE IF NOT EXISTS airflow DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
create user 'airflow'@'%' identified by 'xxxxxxxx';
grant all privileges on airflow.* to airflow@localhost identified by 'xxxxxxxx';
grant all privileges on airflow.* to 'airflow'@'%' identified by 'xxxxxxxx';
flush privileges;
select user,authentication_string,host from user;
3、安装及基本配置
#安装airflow,2.2.3
pip install apache-airflow
#配置个环境变量
vi ~/.bashrc
export AIRFLOW_HOME=/home/san/airflow
source ~/.bashrc
airflow version
#修改配置文件
vi /home/san/airflow/airflow.cfg
executor = LocalExecutor
sql_alchemy_conn = mysql://airflow:xxxxxxxx@localhost:3306/airflow?charset=utf8
sql_engine_encoding = utf-8
#初始化数据库
#如果前面的两个utf8没写好,可能会出现/airflow/lib/python3.7/encodings/cp1252.py错误
airflow db init
#创建个用户
airflow users create --username san --firstname san --lastname san --role Admin --email san@sourcedata.com
#输入密码
4、启动
#启动服务
airflow webserver -D
airflow scheduler -D
#访问
http://ip:8080/
#杀进程
ps -ef|egrep 'scheduler|airflow-webserver'|grep -v grep|awk '{print $2}'|xargs kill -9