airflow安装及配置使用mysql作为数据库

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

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值