LetsDevOps: How to Install Apache Airflow & Create your First DAG.
- Sumit Raj

- Aug 26, 2024
- 1 min read
Introduction
In this blog we learn how to install apache airflow on windows laptop and create our first DAG (Directed Acyclic Graph).
Prerequisite
Install Docker desktop
Insatllation Steps:
Step 1: Download the docker compose file from Airflow
Step 2: Create a folder "apache-airflow"and save the above content in the docker-compose.yaml file
Step 3: Create .env file and save below
AIRFLOW_UID=50000Step 4: Initialaize the database
docker compose up airflow-initThe account created has the login airflow and the password airflow
Step 5: Run the Airflow
docker compose upStep 6: try to browse http://localhost:8080/
user: airflow
: airflow
Create First DAG
Step 1: Sample DAG Code : https://airflow.apache.org/docs/apache-airflow/stable/index.html#workflows-as-code
Step 2: Copy the content and create myfirst_dag.py file
from datetime import datetimefrom airflow import DAGfrom airflow.decorators import taskfrom airflow.operators.bash import BashOperator# A DAG represents a workflow, a collection of taskswith DAG(dag_id="myfirst_dag", start_date=datetime(2022, 1, 1), schedule="0 0 * * *") as dag: # Tasks are represented as operators hello = BashOperator(task_id="hello", bash_command="echo hello") @task() def airflow(): print("airflow") # Set dependencies between tasks hello >> airflow()Step 3: Store the file at dags folder where we installed the airflow.
Step 4: Make sure the py file stored in the below location.
Step 5: Check after couple of minutes. your dag will be picked up and display at the portal.
Search like below
Step 6: You can enable the DAG now.
















Ücretsiz rastgele yetişkin chat gabile chat cinsel chat kesintisiz arkadaşlık yeni kişilerle tanışma imkanı sağlar.
Ücretsiz rastgele yetişkin sohbet cinsel sohbet gabile sohbet sorunsuz yeni kişilerle tanışma imkanı sağlar.