Apache Airflow部署文件(物理機版本)
0.airflow架構
從開發的角度出發來看,使用Local Execultor的基礎 Airflow架構是一個絕佳的理解Apache Airflow架構的起點。
以下是airflow 主要元件的說明:
-
元資料庫(Metadata Database): Airflow使用 SQL 資料庫 來儲存關於 資料流水線執行相關的元資料資訊。在圖片下方,元資料庫由在Airflow當中很受歡迎的Postgres來表示。Airflow也支援MySQL作為其元資料庫。
-
Web伺服器和排程器(Web ServerandScheduler): Airflow web伺服器 和 排程器 在本臺機器中是分別的程序(在這個例子中) 且和上面所提到的元資料庫進行互動。
-
執行器(Executor)被單獨的顯示出來了,由於其通常與Airflow一同本探討,但是其並不是單獨的一個程序,它執行在 排程器之中。
-
工作節點(Worker)是不同的經常,其與圖中的其他元件進行互動。
-
airflow.cfg是被WebServer Scheduler 及 Worker元件使用的配置檔案
- DAGs 指的是 包含Python程式碼的 DAG檔案, 代表將要被Airflow執行的資料流水線。這些檔案的位置在Airflow配置檔案中指定,他們需要被Web Server ,Scheduler及 Worker元件訪問到。
1.依賴安裝配置
1.0 airflow使用者建立並設定密碼
|
1.1 python 3
centos7自帶的python版本為 2.7.5,需要安裝 python 3以支援 airflow的使用。
3.7 . 7
|
1.2 mysql
使用 mysql 作為 airflow 的元資料庫,按照步驟安裝好mysql軟體包
|
1.3 redis
使用redis作為 Celery的broker,按照下面的命令依次安裝即可
|
2.airflow安裝
2.0 airflow 基本安裝包
|
2.1 airflow operator 使用到的 軟體包
|
3.airflow配置
3.0配置 airflow.cfg檔案
|
3.1 依賴元件配置
若使用hive的話,airflow使用者需要提交任務到yarn上,需要配置相關許可權
Fair Scheduler Allocations (Deployed)
yarn.admin.acl
需要在上面兩個配置中新增 airflow 使用者
4.airflow 命令
|
5. 分散式安裝配置
經過 1-4步 即可在物理機中執行起一個 單機版本的 airflow, 若想要將 airflow 分散式安裝到多個節點,只需 在其餘節點 重複 1-3步,然後再複製 第 4 步的 airflow.cfg 檔案到 其餘節點即可。
為了方便安裝,需要配置ssh,並互相授信,以方便傳遞配置檔案。
參考文件
[0]Basic Airflow architecture
https://airflow.readthedocs.io/en/latest/start.html#basic-airflow-architecture
[1] 使用 pyenv 管理 Python 版本
https://einverne.github.io/post/2017/04/pyenv.html
[2]Linux 使用rpm方式安裝最新mysql(5.7.22)步驟以及常見問題解決
https://blog.csdn.net/hao134838/article/details/80163181
[3]redis快速安裝部署
https://blog.csdn.net/guancong3412/article/details/88683044
[4] Airflow Installation Doc
https://airflow.readthedocs.io/en/latest/installation.html
[5] Configuration Reference
https://airflow.readthedocs.io/en/latest/configurations-ref.html
[6]Using the Command Line Interface
https://airflow.readthedocs.io/en/latest/usage-cli.html
[7] MySQL 5.7中explicit_defaults_for_timestamp引數