# Set up Airflow แบบง่าย ๆ จัดการโปรเจคบนเครื่องกันแบบชิล ๆ ด้วย airflowctl

**URL:** <https://discuss.dataengineercafe.io/t/set-up-airflow-airflowctl/622>\
**Category:** Airflow\
**Tags:** airflow, airflowctl\
**Created:** [September 6, 2023, 3:25am UTC](https://discuss.dataengineercafe.io/t/set-up-airflow-airflowctl/622 "2023-09-06T03:25:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![zkan](https://yyz1.discourse-cdn.com/flex035/user_avatar/discuss.dataengineercafe.io/zkan/32/2_2.png) [@zkan](https://discuss.dataengineercafe.io/u/zkan)\
**Post date:** [September 6, 2023, 3:25am UTC](https://discuss.dataengineercafe.io/t/set-up-airflow-airflowctl/622/1 "2023-09-06T03:25:08Z")

</div>

เป็นเครื่องมือ CLI ที่ทำให้เราเซตอัพ Airflow ขึ้นมาเล่นเองบนเครื่องของเราแบบง่าย ๆ (ไม่ต้องใช้ Docker) เราสามารถที่จะสร้างโปรเจค จัดการ Version ของ Airflow และ Python รวมไปถึงเรื่องของ Connections กับ Variables ด้วยได้เลย

> **[GitHub - kaxil/airflowctl: A CLI tool to streamline getting started with...](https://github.com/kaxil/airflowctl)**
>
> A CLI tool to streamline getting started with Apache Airflow™ and managing multiple Airflow projects - GitHub - kaxil/airflowctl: A CLI tool to streamline getting started with Apache Airflow™ and m...

วิธีติดตั้งคือ เราอาจจะลง `airflowctl` ไว้แบบ System-wide Installation โดยใช้คำสั่ง

```bash
pip install airflowctl

```

เราก็จะสามารถใช้คำสั่ง `airflowctl` ได้ ซึ่งตัว CLI เค้าทำมาได้งามจริง ๆ ชอบมากกก 🤩

 ![airflowctl --help](https://canada1.discourse-cdn.com/flex035/uploads/dataengineercafe/original/1X/b1c35de5f459c9a3bcb8618cf8e228cd76f0d66c.png)

แล้วถ้าเราจะเริ่มโปรเจคใหม่ให้สั่ง

```bash
airflowctl init my_airflow_project --build-start

```

คำสั่งด้านบนจะสร้างโปรเจคให้เรามาประมาณนี้ 👇

```auto
my_airflow_project
├── .env
├── .gitignore
├── airflow.cfg
├── dags
│ └── example_dag_basic.py
├── logs
├── plugins
├── requirements.txt
├── settings.yaml
├── standalone_admin_password.txt
└── webserver_config.py

```

แล้วเราก็จะได้ Airflow รันบนเครื่องเรา พร้อมกับ example DAG มา 1 DAG 🎉

 ![Airflow UI from airflowctl](https://canada1.discourse-cdn.com/flex035/uploads/dataengineercafe/original/1X/8558e27e3978ff96fe0d268e53b10dad8880f1a5.png)

ตัว Username คือ `admin` ส่วน Password ให้ดูที่ไฟล์ `standalone_admin_password.txt` นะครับ

Executor จะเป็น `SequentialExecutor ` และฐานข้อมูลเป็น SQLite โดย Default นะครับ สามารถเปลี่ยนได้อาจจะแก้ที่ไฟล์ `airflow.cfg` หรือแก้ Environment Variable ที่ไฟล์ `.env` ก็ได้เช่นกัน (แนะนำให้แก้ที่ `.env` ดีกว่า เราจะได้ไม่ต้องมี `airflow.cfg` หลายเวอร์ชั่น)

ลองเอาไปใช้กันดูนะครับ เผื่อบางทีเราไม่อยากจะรัน Docker ขึ้นมาให้เปลือง Resource ของเครื่อง เราก็ใช้เครื่องมือตัวนี้ได้ 😃
