IT Log

Airflow 설치 본문

Open Source/Apache

Airflow 설치

newly0513 2021. 3. 25. 17:17
728x90
반응형

 

전제 조건

  • Python : 3.6, 3.7, 3.8
  • Database : 
    • PostgreSQL : 9.6, 10, 11, 12, 13
    • MySQL : 5.7, 8
    • SQLite : 3.15.0 이상
  • Kubernertes : 1.16, 1.17.5, 1.18.6
       - Kubernertes 설치 URL : newly0513.tistory.com/191

 

※ MySQL 5.x 버전은 여러 스케줄러를 실행할 수 없거나 제한적임 (MariaDB 권장하지 않음)

   또한, SQLite는 주로 테스트에 사용됨


작성 글 구성환경

  • OS : Ubuntu 20.04
  • Python : 3.8.5
  • Database : PostgreSQL 12
  • Kubernertes : 1.20.5

 

1. Airflow HOME 경로 설정

export AIRFLOW_HOME=~/airflow

2. 변수 선언 및 패키지 업데이트

AIRFLOW_VERSION=2.0.1
PYTHON_VERSION="$(python3 --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"
sudo apt update

3. Airflow 설치

  • 해당 부분 진행 시 pip버전 및 종속성 이슈로 인해 표 안에 명령을 선행하고 진행
# pip 버전 이슈
/usr/bin/python3 -m pip install --upgrade pip

# 종속성 이슈
sudo apt install python3-testresources

 

※ 위 과정을 진행 중에 발생한 추가 이슈 대처 방안 

# pip install --upgrade 이슈
WARNING: The scripts pip, pip3 and pip3.8 are installed in '경로' ...
> export PATH=$PATH:경로

# sudo apt install 이슈
Waiting for cache lock: Could not get lock /var/lib/dpkg/lock-frontend. ...
> sudo rm /var/lib/dpkg/lock*

 

pip install "apache-airflow==${AIRFLOW_VERSION}" --constraint "${CONSTRAINT_URL}"

4. DB 초기화 및 User 생성

# DB 초기화
airflow db init

# User 생성 (비밀번호 입력)
airflow users create --username admin --firstname Peter --lastname Parker --role Admin --email spiderman@superhero.org

5. Web Server 및 Scheduler 시작

  • Web Server 및 Scheduler 를 데몬으로 실행 시키고자 하면 '-D' 옵션을 추가하여 실행
    → airflow webserver --port 8080 -D
    → airflow sheduler -D
# Web server
airflow webserver --port 8080

# Scheduler
airflow scheduler

참고 URL : airflow.apache.org/docs/apache-airflow/stable/installation.html

 

Installation — Airflow Documentation

 

airflow.apache.org

728x90
반응형
Comments