参考:
Centos7 上安装airflow以及postgres数据库作为airflow的指定数据库_apache airflow 源码包安装并指定postgresql-CSDN博客
airflow2.1.2离线安装部署--anaconda3+postgresql_airflow 离线安装-CSDN博客
Index of /pub/repos/yum/12/redhat/rhel-8-x86_64/ (postgresql.org)
从官网下载对应版本的rpm包并安装:
postgresql12-server-12.3-1PGDG.rhel8.x86_64
postgresql12-12.3-1PGDG.rhel8.x86_64
postgresql12-libs-12.3-1PGDG.rhel8.x86_64
postgresql12-contrib-12.3-1PGDG.rhel8.x86_64
rpm -ivh postgresql12-libs-12.3-1PGDG.rhel8.x86_64.rpm
rpm -ivh postgresql12-12.3-1PGDG.rhel8.x86_64.rpm
rpm -ivh postgresql12-server-12.3-1PGDG.rhel8.x86_64.rpm
rpm -ivh postgresql12-contrib-12.3-1PGDG.rhel8.x86_64.rpm
/usr/pgsql-12/bin/postgresql-12-setup initdb
systemctl enable postgresql-12.service
systemctl start postgresql-12.service
ps aux | grep postgres
这里正常postgres已经能启动,并且可以用postgres账号登录。因为后续用airflow连接报错,所以先修改文件:
vim /var/lib/pgsql/12/data/pg_hba.conf
将host几行对应的method改成md5
然后重启pg,创建airflow账号,赋权,创建airflow数据库:
systemctl restart postgresql-12.service
sudo su - postgres
psql
postgres=# create user airflow_user password 'xxxxx';
postgres-# ALTER ROLE airflow_user SUPERUSER;
postgres-# create database airflow_db;
postgres-# \q
进入airflow文件夹,初始化db:
airflow db init
修改生成的airflow.cfg文件:
sql_alchemy_conn = postgresql+psycopg2://airflow_user:xxxxx@localhost/airflow_db
再初始化,新建账号并启动服务:
airflow db init
airflow users create \
--username admin \
--firstname drg \
--lastname all_assist \
--role Admin \
--email diandaolongqi@ffxiv.com
airflow webserver --port 8080 -D
airflow scheduler -D