"db init" 使用 postgres for Airflow
"db init" with postgres for Airflow
我在将 Postgres 数据库链接到 Airflow 时参考了 this doc and this article。
特别是,我将这一行添加到文件 airflow.cfg
:
sql_alchemy_conn = postgresql+psycopg2://airflowadmin:airflowadmin@localhost/airflowdb
其中 airflowadmin
是 postgres 用户和密码的用户名和密码,airflowdb
是创建的 postgres 数据库,airflowadmin
拥有所有权限。
现在,当我用 airflow db init
初始化数据库时,我仍然看到 sqlite
是链接数据库。完整输出:
DB: sqlite:////home/userxxxx/airflow/airflow.db
[2021-09-07 12:43:53,827] {db.py:702} INFO - Creating tables
INFO [alembic.runtime.migration] Context impl SQLiteImpl.
INFO [alembic.runtime.migration] Will assume non-transactional DDL.
WARNI [airflow.models.crypto] empty cryptography key - values will not be stored encrypted.
WARNI [unusual_prefix_xxxxxxxxxxxxxxxxxxxxxxxxx_example_kubernetes_executor_config] Could not import DAGs in example_kubernetes_executor_config.py: No module named 'kubernetes'
WARNI [unusual_prefix_xxxxxxxxxxxxxxxxxxxxxxxxxxxxx_example_kubernetes_executor_config] Install kubernetes dependencies with: pip install apache-airflow['cncf.kubernetes']
Initialization done
我错过了什么?
确保您正在更改的 airflow.cfg
文件与 Airflow 实际加载的文件相同。从 CLI 运行:
airflow info
在 路径信息 部分下搜索,并将其与您正在修改的 airflow.cfg
文件的文件夹路径进行比较。
气流信息:
ache Airflow
version | 2.1.2
executor | SequentialExecutor
task_logging_handler | airflow.utils.log.file_task_handler.FileTaskHandler
sql_alchemy_conn | sqlite:////home/vagrant/airflow/airflow.db
dags_folder | /home/vagrant/airflow/dags
plugins_folder | /home/vagrant/airflow/plugins
base_log_folder | /home/vagrant/airflow/logs
remote_base_log_folder |
System info
OS
...
...
Paths info
airflow_home | /home/vagrant/airflow
...
在local installation过程中没有定义时,airflow_home
的默认值是AIRFLOW_HOME=~/airflow
,所以我想这可能是你问题的原因。
我在将 Postgres 数据库链接到 Airflow 时参考了 this doc and this article。
特别是,我将这一行添加到文件 airflow.cfg
:
sql_alchemy_conn = postgresql+psycopg2://airflowadmin:airflowadmin@localhost/airflowdb
其中 airflowadmin
是 postgres 用户和密码的用户名和密码,airflowdb
是创建的 postgres 数据库,airflowadmin
拥有所有权限。
现在,当我用 airflow db init
初始化数据库时,我仍然看到 sqlite
是链接数据库。完整输出:
DB: sqlite:////home/userxxxx/airflow/airflow.db
[2021-09-07 12:43:53,827] {db.py:702} INFO - Creating tables
INFO [alembic.runtime.migration] Context impl SQLiteImpl.
INFO [alembic.runtime.migration] Will assume non-transactional DDL.
WARNI [airflow.models.crypto] empty cryptography key - values will not be stored encrypted.
WARNI [unusual_prefix_xxxxxxxxxxxxxxxxxxxxxxxxx_example_kubernetes_executor_config] Could not import DAGs in example_kubernetes_executor_config.py: No module named 'kubernetes'
WARNI [unusual_prefix_xxxxxxxxxxxxxxxxxxxxxxxxxxxxx_example_kubernetes_executor_config] Install kubernetes dependencies with: pip install apache-airflow['cncf.kubernetes']
Initialization done
我错过了什么?
确保您正在更改的 airflow.cfg
文件与 Airflow 实际加载的文件相同。从 CLI 运行:
airflow info
在 路径信息 部分下搜索,并将其与您正在修改的 airflow.cfg
文件的文件夹路径进行比较。
气流信息:
ache Airflow
version | 2.1.2
executor | SequentialExecutor
task_logging_handler | airflow.utils.log.file_task_handler.FileTaskHandler
sql_alchemy_conn | sqlite:////home/vagrant/airflow/airflow.db
dags_folder | /home/vagrant/airflow/dags
plugins_folder | /home/vagrant/airflow/plugins
base_log_folder | /home/vagrant/airflow/logs
remote_base_log_folder |
System info
OS
...
...
Paths info
airflow_home | /home/vagrant/airflow
...
在local installation过程中没有定义时,airflow_home
的默认值是AIRFLOW_HOME=~/airflow
,所以我想这可能是你问题的原因。