install airflow

The official website is very simple:

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

requires attention:

1. The database is sqlite3 by default, and Python will report an error (because I changed Python3):

ModuleNotFoundError: No module named '_sqlite3'

General workaround:

yum install sqlite-devel

 

Recompile Python:

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

make && make install

If it still gives an error:

You can re-follow 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

Then recompile 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. To add users, the official website has some steps:

Add under ~/airflow/airflow.cfg [webserver]:

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

And run the following code in the ~/airflow/ directory:

$ 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()

But when running, it usually reports an error ("AttributeError: can't set attribute")

The reason is that the version of the sqlalchemy Python package is greater than 1.2

Solution:

pip uninstall sqlalchemy

pip install 'sqlalchemy<1.2'

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325290977&siteId=291194637