当前配置情况:
Python 2.7.5
Mysql 5.7.31
pip 20.1.1
airflow 1.10.11
1、默认自带python2环境,自行安装pip
sudo yum -y install epel-release
sudo yum -y install python-pip1
2、进行pip的更新,否则很多安装会报错
sudo pip install --upgrade pip
sudo pip install --upgrade setuptools
3、安装开发库
sudo yum install python-devel
sudo yum install libevent-devel
sudo yum install mysql-devel
4、安装centos7下的mysql
执行yum源更新命令
sudo yum clean all
sudo yum makecache
sudo yum -y update (需要比较长的时间)
5、初始化配置mysql,可以设定允许root远程登录
关闭防火墙
sudo firewall-cmd --zone=public --add-port=3306/tcp --permanent
sudo firewall-cmd --reload
6、配置Mysql默认编码为UTF-8
修改/etc/my.cnf配置文件,在[mysqld]下添加编码配置
character_set_server=utf8
init_connect='SET NAMES utf8'
编辑保存完 重启mysql服务: service mysqld restart
7、安装AirFlow
给airflow设置环境变量
sudo vim /etc/profile
#airflow
export AIRFLOW_HOME=/opt/modules/airflow
export SLUGIFY_USES_TEXT_UNIDECODE=yes
刷新环境变量
安装airflow
sudo pip install apache-airflow
遇到问题:
ERROR: Cannot uninstall 'enum34',It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial install
A:
sudo pip install six --user -U
sudo pip install ipython --user -U
sudo pip install --ignore-installed dnspython
sudo yum install python-devel
sudo yum install openldap-devel
sudo pip install --ignore-installed python-ldap
sudo pip install --ignore-installed enum34
ERROR:Cannot uninstall 'requests',It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
A:
sudo pip install --ignore-installed requests
8、 设置mysql数据库连接
sudo pip install apache-airflow[mysql]
error:
Error: Package: 1:mariadb-devel-5.5.65-1.el7.x86_64 (base) Requires: libmysq
解决方法:
cd /etc/yum.repos.d/
rpm -ivh http://repo.mysql.com/mysql57-community-release-el7-8.noarch.rpm
yum install mysql-devel
创建airflow用户,创建airflow数据库并给出所有权限给此用户(注意在设置密码的时候还是前面讲的问题,不能太简单,否则不能通过)
修改airflow配置文件,指向数据库mysql
airflow.cfg 文件通常在~/airflow目录下
executor = LocalExecutor
sql_alchemy_conn = mysql://airflow:[email protected]/airflow
对应字段解释如下: dialect+driver://username:password@host:port/database
修改mysql的配置文件
vim /etc/my.cnf
添加这一句
explicit_defaults_for_timestamp=1
重启mysql
9、初始化airflow并启动web服务
初始化数据库
airflow initdb
启动 airflow webserver
airflow webserver
airflow scheduler
airflow worker
文档参考; https://www.cnblogs.com/braveym/p/11378851.html
入门指南: https://blog.csdn.net/qazplm12_3/article/details/53065654