安装airflow

官网的很简单:

export AIRFLOW_HOME=~/airflow

# install from pypi using pip
pip install apache-airflow

# initialize the database
airflow initdb

# start the web server, default port is 8080
airflow webserver -p 8080

需要注意:

1.数据库默认是sqlite3,Python会报错(因为我改变Python3):

ModuleNotFoundError: No module named '_sqlite3'

一般解决方法:

yum install sqlite-devel

重新编译Python:

./configure --prefix=/usr/local/python360

make && make install

如果还是报错:

可以重新按照sqlite3

wget https://www.sqlite.org/2017/sqlite-autoconf-3170000.tar.gz --no-check-certificate

tar zxvf sqlite-autoconf-3170000.tar.gz

cd sqlite-autoconf-3170000

./configure --prefix=/usr/local/sqlite3 --disable-static --enable-fts5 --enable-json1 CFLAGS="-g -O2 -DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABLE_FTS4=1 -DSQLITE_ENABLE_RTREE=1"

make && make install

然后重新编译Python:

LD_RUN_PATH=/usr/local/sqlite3/lib ./configure --prefix=/usr/local/python360 LDFLAGS="-L/usr/local/sqlite3/lib" CPPFLAGS="-I /usr/local/sqlite3/include"

LD_RUN_PATH=/usr/local/sqlite3/lib make

LD_RUN_PATH=/usr/local/sqlite3/lib make install

2.添加用户,官网有一些步骤:

在~/airflow/airflow.cfg [webserver]下添加:

authenticate = True
auth_backend = airflow.contrib.auth.backends.password_auth

并且在~/airflow/目录下运行以下代码:

$ cd ~/airflow
$ python
Python 2.7.9 (default, Feb 10 2015, 03:28:08)
Type "help", "copyright", "credits" or "license" for more information.
>>> import airflow
>>> from airflow import models, settings
>>> from airflow.contrib.auth.backends.password_auth import PasswordUser
>>> user = PasswordUser(models.User())
>>> user.username = 'new_user_name'
>>> user.email = '[email protected]'
>>> user.password = 'set_the_password'
>>> session = settings.Session()
>>> session.add(user)
>>> session.commit()
>>> session.close()
>>> exit()

但是运行的时候,通常会报错(“AttributeError: can't set attribute”)

原因是 sqlalchemy这个Python包版本大于1.2

解决方法:

pip uninstall sqlalchemy

pip install 'sqlalchemy<1.2'

猜你喜欢

转载自my.oschina.net/ilovetao/blog/1806915