前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >airflow —安装详解 (2)

airflow —安装详解 (2)

原创
作者头像
刘远
修改2017-06-29 10:37:35
5K1
修改2017-06-29 10:37:35
举报
文章被收录于专栏:刘远的专栏刘远的专栏

安装python>=2.7

安装airflow

安装airflow :https://pythonhosted.org/airflow/installation.html

代码语言:javascript
复制
yum install libxml2-devel
yum install libxslt-devel
yum install libffi-devel

# airflow needs a home, ~/airflow is the default,
# but you can lay foundation somewhere else if you prefer
# (optional)
export AIRFLOW_HOME=~/airflow

# install from pypi using pip
pip2 install numpy
pip2 install cython
pip2 install pandas
pip2 install airflow
pip2 install airflow[hive]
pip2 install airflow[mysql]
pip2 install airflow[celery]
pip2 install airflow[rabbitmq]
pip2 install airflow[crypto]
pip2 install airflow[password]
pip2 install celery
pip2 install flower

安装DB

代码语言:javascript
复制
# initialize the database
airflow initdb

如果需要mysql,请修改全局配置文件airflow.cfg,并创建airflow库:

代码语言:javascript
复制
create database airflow default charset utf8;

在使用airflow-1.8.0版本时,如果有如下报错:

代码语言:javascript
复制
>>>> sqlalchemy.exc.ProgrammingError: (_mysql_exceptions.ProgrammingError)

>>>> (1064, "You have an error in your SQL syntax; check the manual that

>>>> corresponds to your MySQL server version for the right syntax to use

>> near

>>>> '(6) NULL' at line 1") [SQL: u'ALTER TABLE dag MODIFY last_scheduler_run

>>>> DATETIME(6) NULL']

需要变更

代码语言:javascript
复制
airflow/migrations/versions/4addfa1236f1_add_fractional_seconds_to_mysql_tables.py

mysql.DATETIME(fsp=6) 全部改为 mysql.DATETIME()或将mysql升级到5.7或以上的版本。

启动后台celery worker

如果使用了CeleryExecutor,需要启动

代码语言:javascript
复制
airflow worker -D

启动后台scheduler

代码语言:javascript
复制
airflow scheduler -D

启动webserver

代码语言:javascript
复制
# start the web server, default port is 8080
airflow webserver -p 8080 -D

启动flower

如果使用了celery

代码语言:javascript
复制
airflow flower

查看配置文件

代码语言:javascript
复制
$ cd ~/airflow
$ ls airflow.cfg  airflow.db  airflow-webserver.pid  unittests.cfg

开启用户认证

启动认证

代码语言:javascript
复制
$vim airflow.cfg

# Set to true to turn on authentication:
# http://pythonhosted.org/airflow/installation.html#web-authentication
#authenticate = False
authenticate = True
auth_backend = airflow.contrib.auth.backends.password_auth

创建用户

代码语言:javascript
复制
import airflow

from airflow import models, settings
from airflow.contrib.auth.backends.password_auth import PasswordUser
user = PasswordUser(models.User())
user.username = 'your  usrename'
user.email = 'username@email.com'
user.password = 'your password'
session = settings.Session()
session.add(user)
session.commit()
session.close()
exit()

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 安装python>=2.7
    • 安装airflow
    • 安装DB
    • 启动后台celery worker
    • 启动后台scheduler
    • 启动webserver
    • 启动flower
    • 查看配置文件
    • 开启用户认证
      • 启动认证
        • 创建用户
        相关产品与服务
        数据库
        云数据库为企业提供了完善的关系型数据库、非关系型数据库、分析型数据库和数据库生态工具。您可以通过产品选择和组合搭建,轻松实现高可靠、高可用性、高性能等数据库需求。云数据库服务也可大幅减少您的运维工作量,更专注于业务发展,让企业一站式享受数据上云及分布式架构的技术红利!
        领券
        问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
        http://www.vxiaotou.com