[英]how to set Postgres as backend database in Airflow?
I am trying to build the connection between the postgres and airflow, here is my docker-compose我正在尝试在 postgres 和 airflow 之间建立连接,这是我的 docker-compose
version: '3'
services:
postgres:
image: postgres
environment:
- POSTGRES_USER=airflow
- POSTGRES_PASSWORD=airflow
- POSTGRES_DB=airflow
webserver:
image: apache/airflow:1.10.13-python3.6
command: bash -c "airflow initdb; airflow webserver; airflow scheduler;"
environment:
- AIRFLOW_DATABASE_USERNAME=airflow
- AIRFLOW_DATABASE_PASSWORD=airflow
- AIRFLOW_DATABASE_NAME=airflow
volumes:
- ../airflow/dag:/opt/airflow/dags
ports:
- 8080:8080
After setting the postgres configuration setting it's still taking the SQLite as backend database.设置 postgres 配置设置后,它仍然将 SQLite 作为后端数据库。 Logs as follow
日志如下
ravi@ravi:~/Documents/airflow$ docker-compose up airflow_webserver
Starting airflow_airflow_webserver_1 ...
Starting airflow_airflow_webserver_1 ... done
Attaching to airflow_airflow_webserver_1
airflow_webserver_1 | DB: sqlite:////opt/airflow/airflow.db
airflow_webserver_1 | [2020-12-06 12:53:22,911] {db.py:378} INFO - Creating tables
airflow_webserver_1 | INFO [alembic.runtime.migration] Context impl SQLiteImpl.
airflow_webserver_1 | INFO [alembic.runtime.migration] Will assume non-transactional DDL.
airflow_webserver_1 | Done.
After adding the following two environments variable the airflow is now taking the backend database as Postgres
:添加以下两个环境变量后, airflow 现在将后端数据库作为
Postgres
:
AIRFLOW__CORE__SQL_ALCHEMY_CONN=postgresql+psycopg2://airflow:airflow@postgres/airflow
AIRFLOW__CORE__EXECUTOR=LocalExecutor
Thank you @elad谢谢@elad
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.