在Apache Airflow中实现Postgres Sql [英] Implementing Postgres Sql in Apache Airflow

查看:719
本文介绍了在Apache Airflow中实现Postgres Sql的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Ubuntu 18.04.3版服务器上实现了Apache-Airflow.设置它时,我使用了sql lite通用数据库,并且使用了顺序执行程序.我这样做只是为了适应系统.现在,我正在尝试使用Local Executor,并且需要将我的数据库从sqlite过渡到推荐的postgres sql.

I have Apache-Airflow implemented on an Ubuntu version 18.04.3 server. When I set it up, I used the sql lite generic database, and this uses the sequential executor. I did this just to play around and get used to the system. Now I'm trying to use the Local Executor, and will need to transition my database from sqlite to the recommended postgres sql.

有人知道如何进行这种转换吗?我发现的所有教程都需要从一开始就使用postgres sql设置Airflow.我知道有很多运动部件,而且我担心会弄乱我目前正在运行的部件.非常感谢任何知道如何执行此操作或可以将我指向何处的人.谢谢!

Does anybody know how to make this transition? All of the tutorials I've found entail setting up Airflow with postgres sql from the beginning. I know there are a ton of moving parts and I'm scared of messsing up what I currently have running. Anybody who knows how to do this or can point me at where to look is much appreciated. Thanks!

推荐答案

只需使用以下命令完成@lalligood答案:

Just completing @lalligood answers with some commands:

airflow.cfg文件中查找sql_alchemy_conn并将其更新以指向您的PostgreSQL serv:

In airflow.cfg file look for sql_alchemy_conn and update it to point to your PostgreSQL serv:

sql_alchemy_conn = postgresql+psycopg2://user:pass@hostadress:port/database

例如:

sql_alchemy_conn = postgresql+psycopg2://airflow:airflow@localhost:5432/airflow

如上一行所示,您需要一个用户airflow和一个也称为airflow的数据库,因此您需要创建该数据库:

As indicated in the above line you need a user airflow and a database also called airflow, therefore you need to create that:

打开psql命令行并键入以下命令,以创建名为airflow的用户和数据库,并将对数据库airflow的所有特权授予用户airflow:

Open your psql command line and type the following commands to create a user and database called airflow and give all privileges over database airflow to user airflow:

CREATE USER airflow;
CREATE DATABASE airflow;
GRANT ALL PRIVILEGES ON DATABASE airflow TO airflow;

现在您可以使用postgres初始化气流应用程序了:

Now you are ready to init the airflow application using postgres:

airflow initdb

如果一切正常,请再次访问psql命令行,使用\c airflow命令输入气流数据库,然后键入\dt命令以列出该数据库的所有表.您应该会看到气流表的列表,当前为23.

If everything was right, access the psql command line again, enter in airflow database with \c airflow command and type \dt command to list all tables of that database. You should see a list of airflow tables, currently it is 23.

这篇关于在Apache Airflow中实现Postgres Sql的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆