-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathairflow_installation_guide.txt
More file actions
executable file
·97 lines (84 loc) · 3.97 KB
/
Copy pathairflow_installation_guide.txt
File metadata and controls
executable file
·97 lines (84 loc) · 3.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
Airflow Installation Process
Install Postgres
- "sudo apt update && sudo apt-get install postgresql-14" (14 is version number)
- "sudo -u postgres psql"
-
Create Airflow database;
- "CREATE DATABASE airflow_db;"
- "CREATE USER airflow_user WITH PASSWORD 'choose_your_password';"
- "GRANT ALL PRIVILEGES ON DATABASE airflow_db TO airflow_user;"
Create Linux user and grant sudo privileges
- sudo adduser lamisplus
- sudo usermod -aG sudo lamisplus
- cd /home/lamisplus
Install Airflow on Linux Server
- "sudo apt update && sudo apt install python3 && sudo apt install python3-pip && sudo apt-get install pkg-config && sudo apt-get install libmysqlclient-dev"
- "sudo apt-get update && sudo apt-get install -y libkrb5-dev && sudo apt-get install libpq-dev && sudo apt-get install libldap2-dev libsasl2-dev"
- "pip install python-ldap"
- create airflow directory with "mkdir airflow"
- Change ownership of the directory with "sudo chown -R lamisplus:lamisplus /home/lamisplus/airflow"
- navigate into airflow directory with "cd airflow"
- create virtual environment with "pip install virtualenv && python3 -m venv airflow_env && source airflow_env/bin/activate"
- Activate virtual environment with "source airflow_env/bin/activate"
- Run "pip install apache-airflow==2.10.5 && pip install pandas && pip install numpy && pip install psycopg2-binary" (do this in the virtual environment)
- Confirm successful installation with "airflow version"
- Initialize Airflow with "airflow_env/bin/airflow db migrate"
- If initialization is successful, open airflow.cfg and update with "nano airflow.cfg"
# Set the metadata database connection string
sql_alchemy_conn = postgresql+psycopg2://airflow_user:D3ng1ne3r@localhost/airflow_db
# HIDE Example DAGs;
load_examples = False
- Create Airflow credentials with the following
airflow users create \
--username admin \
--firstname Admin \
--lastname Lamisplus \
--role Admin \
--email admin@localhost \
--password choose_your_password
- Test Whether Airflow is running
- Start Airflow webserver and scheduler with "airflow webserver --port 8351 && airflow scheduler"
- navigate to "http://external_IP:8351"
CREATE AIRFLOW WEBSERVER AND SCHEDULER AS SYSTEMCTL SERVICES
- cd into systemctl services folder with "cd /etc/systemctl/system"
- create airflow-webserver.service file with "nano airflow-webserver.service", fill it with the info below and save with CTRL+X and hit Y
[Unit]
Description=Airflow Webserver daemon
After=network.target postgresql.service
Wants=postgresql.service
StartLimitIntervalSec=300
StartLimitBurst=5
[Service]
User=lamisplus
Group=lamisplus
Type=simple
ExecStart=/home/lamisplus/airflow_env/bin/python /home/lamisplus/airflow_env/bin/airflow webserver --port 8351
Restart=on-failure
RestartSec=5s
PrivateTmp=true
[Install]
WantedBy=multi-user.target
- create airflow-scheduler.webservice file with "nano airflow-scheduler.service", fill it with the info below and save with CTRL+X and hit Y
[Unit]
Description=Airflow Scheduler daemon
After=network.target postgresql.service
Wants=postgresql.service
StartLimitIntervalSec=300
StartLimitBurst=5
[Service]
User=lamisplus
Group=lamisplus
Type=simple
ExecStart=/home/lamisplus/airflow_env/bin/python /home/lamisplus/airflow_env/bin/airflow scheduler
Restart=on-failure
RestartSec=5s
PrivateTmp=true
[Install]
WantedBy=multi-user.target
- To start both services, run "sudo systemctl daemon-reload && sudo systemctl start airflow-webserver && sudo systemctl start airflow-scheduler && sudo systemctl enable airflow-webserver && sudo systemctl enable airflow-scheduler"
- Confirm if both services are running with "sudo systemctl status airflow-webserver" and "sudo systemctl status airflow-scheduler"
Monitor Airflow Logs
sudo journalctl -u airflow-webserver.service --since "1 hour ago" | tail -n 20
sudo journalctl -u airflow-webserver
Accessing the Web UI:
Once the webserver is running, you can access the Airflow Web UI by navigating to http://external_IP:8351 in a web browser.