개발/Airflow
Airflow 세팅
Louisus
2021. 8. 6. 11:19
728x90
# Airflow Web 사용법
- airflow 설치 및 실행 과정 (Window)
- CentOS 8.x 버전 설치
- 파이썬 및 기타 개발 툴 설치
- yum install python3 python3-devel vim
- yum groupinstall "Development Tools"
- pip 버전 업그레이드
- pip3 install --upgrade pip==20.2.4
- airflow 설치(쉘스크립트 만들어서 실행)
- # airflow needs a home, ~/airflow is the default,
# but you can lay foundation somewhere else if you prefer
# (optional)
export AIRFLOW_HOME=~/airflow - AIRFLOW_VERSION=2.0.1
PYTHON_VERSION="$(python3 --version | cut -d " " -f 2 | cut -d "." -f 1-2)"
# For example: 3.6
CONSTRAINT_URL="https://raw.githubusercontent.com/apache/airflow/constraints-${AIRFLOW_VERSION}/constraints-${PYTHON_VERSION}.txt"
# For example: https://raw.githubusercontent.com/apache/airflow/constraints-2.0.2/constraints-3.6.txt
pip3 install "apache-airflow==${AIRFLOW_VERSION}" --constraint "${CONSTRAINT_URL}"
- # airflow needs a home, ~/airflow is the default,
- airflow 실행
- # initialize the database
airflow db init# start the web server, default port is 8080
airflow webserver --port 8080# visit localhost:8080 in the browser and use the admin account you just
# created to login. Enable the example_bash_operator dag in the home page - # start the scheduler
# open a new terminal or else run webserver with ``-D`` option to run it as a daemon
airflow scheduler - airflow users create \
--username admin \
--firstname Peter \
--lastname Parker \
--role Admin \
--email spiderman@superhero.org
- # initialize the database
- DAGs 탭에서 On/Off 버튼으로 활성화/비활성화 가능
- DAG 이름 클릭 시 Tree로 확인 할 수도 있고, Graph로 확인 할 수도 있음
- 각각의 task 클릭 클릭 시 task의 세부 사항 창이 나타남
- Instance Details - task의 세부 정보 확인 가능
- Rendered - 인수 확인 가능
- Log - 로그 확인 가능
- XCom - 리턴 값 확인 가능
- All Instances - 모든 시간대의 task 확인 가능
- Filter Upstream - 현재 task 부터 상위 task항목만 볼 수 있게 필터링
- 세부 사항의 아래쪽의 Task Actions
- 2번째 행 - Success 상태를 실행 완료되지 않은 상태로 변경
- 3번째 행 - Failed 상태로 변경
- 4번째 행 - Success 상태로 변경
- 각각의 task 클릭 클릭 시 task의 세부 사항 창이 나타남
- Task duration에서 DAG의 수행된 각 task의 수행 시간을 그래프로 볼 수 있음
- Task Tries에서 각각의 task를 수행한 횟수를 그래프로 볼 수 있음
- Grant에서 각 task의 수행 순서에 따라서 소모된 시간을 볼 수 있음
- Details에서 DAG 객체에 대한 정보 확인 가능
- Code에서 작성한 code 확인 가능
- DAG 이름 클릭 시 Tree로 확인 할 수도 있고, Graph로 확인 할 수도 있음
- Security 탭에서는 airflow 유저 목록, 로그인 통계 등을 확인 가능
- Browse 탭에서 전체 DAG 실행 목록을 수정/삭제할 수 있고, airflow에서 전체 수행한 작업 목록, 전체 task를 리스트로 확인 가능
- Admin 탭에서는 airflow에 커넥션 된 항목들, 전체 task의 return value 확인 가능