※ MySQL 5.x 버전은 여러 스케줄러를 실행할 수 없거나 제한이 있다. 자세한 내용은 스케줄러 를 참조 . MariaDB는 테스트/권장되지 않는다.
※ SQLite는 Airflow 테스트에 사용됩니다. 생산에 사용X 로컬 개발에는 최신 안정 버전의 SQLite를 사용하는 것이 좋다.
※ Python 3 지원과 관련하여 Airflow 2.0.0은 Python 3.6, 3.7 및 3.8에서 테스트되었지만 아직 Python 3.9를 지원하지 않는다.
Airflow를 설치하는 공식적인 방법은 pip도구를 사용하는 것입니다. 최근(2020년 11월) 변경 사항이 있었으므로 현재 공식적으로는 20.2.4 버전만 지원되지만 20.3.3+ 버전에서 성공할 수도 있습니다( pip20.3.0 릴리스 의 모든 초기 문제가 해결되었는지 확인해야 함) 20.3.3에서 수정됨). Airflow를 설치하려면 pip를 버전 20.2.4로 다운그레이드 하거나 Pip 20.3을 사용하는 경우 pip 설치 명령에 옵션을 추가해야 합니다.
pip install --upgrade pip==20.2.4--use-deprecated legacy-resolver
Airflow 공식 문서에 나와 있듯이 Airflow는 기본 경로를 '~/airflow' 즉, 사용자 계정 path를 선호
$ sudo mkdir ~/airflow
$ sudo vim ~/.bashrc
export AIRFLOW_HOME=~/airflow
Airflow 버전을 어떠한 것으로 설치할 것인지, Python 버전은 무엇인지 등을 셋팅하고 Airflow 설치
$ AIRFLOW_VERSION=2.5.0
$ PYTHON_VERSION="$(python --version | cut -d " " -f 2 | cut -d "." -f 1-2)"
그 후 공식 문서에 나와 있는대로 설치
$ CONSTRAINT_URL="https://raw.githubusercontent.com/apache/airflow/constraints-${AIRFLOW_VERSION}/constraints-${PYTHON_VERSION}.txt"
$ pip install "apache-airflow==${AIRFLOW_VERSION}" --constraint "${CONSTRAINT_URL}"
$ airflow db init
설치 도중 Error가 생긴 경우 아래의 트러블 슈팅 참고
※ sqlite3 버전 error
airflow.exceptions.AirflowConfigException: error: sqlite C library version too old (< 3.15.0). See https://airflow.apache.org/docs/apache-airflow/2.0.2/howto/set-up-database.rst#setting-up-a-sqlite-database
※ ld-linux.so.2 Error
/lib/ld-linux.so.2:bad ELF interpreter: 그런 파일이나 디렉터리가 없습니다.
※ pip Permission denied
ERROR: Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/usr/local/bin/pip3.8' Consider using the --user option or check the permissions.
잘 진행이 되었으면 Airflow가 설치된 경로(~/airflow)에 다음과 같은 구성으로 파일과 디렉토리가 구성됩니다.
다음으로 airflow를 관리할 사용자 계정을 만듭니다.
$ airflow users create \
--username admin \
--firstname Peter \
--lastname Parker \
--role Admin \
--email spiderman@superhero.org
$ airflow webserver --port 8080
$ airflow scheduler
Airflow 설정을 해주는 airflow.cfg 파일이 존재하는지 확인
# airflow 경로로 이동
$ cd ~/airflow
# airflow.cfg 있는지 확인
$ ls airflog.cfg
airflow.cfg
파일을 열어 load_examples
부분을 찾아 True -> False
로 수정
load_examples = False
로 변경하고 다시 Airflow Webserver 새로고침하면 Example DAGs 들이 모두 사라졌을 것이다.
만약, 새로고침을 해도 Exmaple DAGs 들이 남아있다면 airflow scheduler 를 실행했던 터미널을 열어 ctrl+c를 통해 종료 한 후, 다시 airflow scheduler 를 실행시켜보자
airflow.exceptions.AirflowConfigException: error: sqlite C library version too old (< 3.15.0). See https://airflow.apache.org/docs/apache-airflow/2.0.2/howto/set-up-database.rst#setting-up-a-sqlite-database
SQLite의 공식 웹사이트로 이동. https://sqlite.org
Source Code의 tar.gz 표시가 있는 것을 찾아 링크를 복사한다.
다음 명령어를 실행 시킨다.
# Install Depandency Program
yum -y install gcc
# Sqlite update
wget 복사한 링크 [ EX) https://www.sqlite.org/2020/sqlite-autoconf-3310100.tar.gz]
tar -xzvf sqlite-autoconf-3310100.tar.gz
cd sqlite-autoconf-3310100
./configure --prefix=/usr/local
# ./configure --prefix=$HOME/opt/sqlite
# ./configure --prefix=/usr/local
make && make install
설치 후 환결설정값에 export LD_LIBRARY_PATH="/usr/local/lib"
를 추가하면 제대로 작동이 됩니다.
$ vi /root/.bashrc
export LD_LIBRARY_PATH="/usr/local/lib"
$ /usr/bin/sqlite3
SQLite header and source version mismatch
2020-01-27 19:55:54 3bfa9cc97da10598521b342961df8f5f68c7388fa117345eeb516eaa837bb4d6
2013-05-20 00:56:22 118a3b35693b134d56ebd780123b7fd6f1497668
Python에 적용이 되었는지 확인합니다.
Python 3.7.7 (default)
>>> import _sqlite3
>>> _sqlite3.sqlite_version
'3.7.17'
Python 3.31.1 (default)
>>> import _sqlite3
>>> _sqlite3.sqlite_version
'3.31.1'
$ airflow db init
/lib/ld-linux.so.2:bad ELF interpreter: 그런 파일이나 디렉터리가 없습니다.
$ yum install ld-linux.so.2
ERROR: Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/usr/local/bin/pip3.8'
Consider using the --user option or check the permissions.