
To efficiently manage and schedule workflows, you can install Airflow on Ubuntu, an open-source platform known as Apache Airflow. It is a scalable, flexible, and robust solution for authoring, scheduling, and monitoring ETL (Extract, Transform, and Load) data pipelines.
Airflow uses standard Python code to manage workflow tasks, and workflows are Directed Acyclic Graphs (DAGs) scheduled to run automatically at different intervals. DAG intervals are defined using the crontab syntax.
DAGS, are created using Python code and scheduled to run automatically at specified intervals using the Airflow scheduler. This article explains how to deploy Apache Airflow on a Ubuntu 20.04 server.
Before you begin:
Install the Python package manager, and virtual environment.
Create a new project directory.
Change to the directory.
Create a new virtual environment.
Activate the virtual environment.
Your terminal prompt should change as below:
Using pip, install Airflow.
Initialize a new SQLite database to create the Airflow meta-store that Airflow needs to run.
Output:
Create the administrative user and password used to access Airflow.
Using nohup, start the Airflow scheduler to run in the background. Airflow appends the output of running the scheduler to the scheduler.log file.
The Scheduler command starts the Airflow scheduler, queues, and runs the workflows defined in the DAG code.
Start the Airflow web server on port 8080.
Create a new Airflow Nginx configuration file.
Using a text editor such as Nano, edit the file.
Add the following configurations to the file.
Replace app-online.example.com with your actual domain name.
Save and close the file.
Test the Nginx configuration for configuration errors.
Restart Nginx to load changes.
To allow access to Apache Airflow through the Nginx reverse proxy, open the necessary HTTP and HTTPS firewall ports as described below.
By default, Uncomplicated Firewall (UFW) is active on Vultr Ubuntu servers. Verify that the firewall is running.
Allow HTTP access on port 80.
Allow HTTPS on port 443.
Restart the firewall to load changes.
For more firewall configuration options, learn how to configure UFW on Ubuntu.
To secure your server, serve Apache Airflow requests over HTTPS by installing an SSL certificate to encrypt traffic between the application and the users over the Internet as described below.
Install the Certbot Let's Encrypt Client.
Activate the Certbot command.
Generate an SSL Certificate for your domain as set in the Nginx configuration file.
Replace app-online.example.com with your domain name, and hello@example.com with your actual email.
When successful, verify that Certbot auto renews your certificate on expiry.
Restart Nginx to load changes.
For more Certbot configuration options, visit the Install Let's Encrypt SSL on Ubuntu page.
In a web browser such as Chrome. Visit your configured domain to access the Airflow web interface.
Log in using the administrative username and password you created earlier.
Airflow provides sample DAGs that offer a great way to learn Airflow. To run the first DAG on your Airflow instance, follow the steps below.
In your web browser, access the Airflow UI dashboard. in your web browser.
When logged in, find the list of default/starter DAGs on the dashboard.
Click any DAG to open the detail page. For example: dataset_consumes_1.
In the upper left corner, toggle the switch button to ON to activate the DAG.
Find and click the play button, then select trigger DAG from the drop down to run the DAG.
You have activated and run your first DAG. Using the DAG, you can start customizing and building workflows to utilize Airflow's powerful features and components.
Airflow is a widely used tool in the data engineering ecosystem, employed by many companies to manage their data pipelines. It is well-suited for ETL (Extract, Transform, Load) processes and other related data engineering tasks. As a versatile and essential addition to any data engineering toolkit, it is highly valuable for data engineers and data scientists. In this article, you deployed Airflow on an Ubuntu server, for more information and configuration options, visit the official Airflow documentation.
0 Comments
Be the first to comment and share your perspective with the community.