Airflow 默认情况下,连接太多

Airflow 默认情况下,连接太多,airflow,Airflow,我打开了气流,检查了连接,发现后面的连接太多了。 任何关于如何杀死那些我不使用的东西的想法,或者我想知道运行它的最低控制id 建筑 LocalExecutor(与任何其他代理不同) Postgres作为metadb 但是,它列出了17个连接 这是连接列表 这是气流.cfg [core] # Thee home folder for airflow, default is ~/airflow airflow_home = /usr/src/app # The folder where yo

我打开了气流,检查了连接,发现后面的连接太多了。 任何关于如何杀死那些我不使用的东西的想法,或者我想知道运行它的最低控制id

建筑

  • LocalExecutor(与任何其他代理不同)
  • Postgres作为metadb
但是,它列出了17个连接

这是连接列表

这是
气流.cfg

[core]
# Thee home folder for airflow, default is ~/airflow
airflow_home = /usr/src/app

# The folder where your airflow pipelines live, most likely a
# subfolder in a code repository
dags_folder = /usr/src/app/dags

# The folder where airflow should store its log files. This location
base_log_folder = /usr/src/app/logs

# Airflow can store logs remotely in AWS S3 or Google Cloud Storage. Users
# must supply a remote location URL (starting with either 's3://...' or
# 'gs://...') and an Airflow connection id that provides access to the storage
# location.
remote_base_log_folder =
remote_log_conn_id =
# Use server-side encryption for logs stored in S3
encrypt_s3_logs = False
# deprecated option for remote log storage, use remote_base_log_folder instead!
# s3_log_folder =

# The executor class that airflow should use. Choices include
# SequentialExecutor, LocalExecutor, CeleryExecutor
executor = LocalExecutor

# The SqlAlchemy connection string to the metadata database.
# SqlAlchemy supports many different database engine, more information
# their website
sql_alchemy_conn = postgresql+psycopg2://airflow:airflow@db/airflow

# The SqlAlchemy pool size is the maximum number of database connections
# in the pool.
sql_alchemy_pool_size = 5

# The SqlAlchemy pool recycle is the number of seconds a connection
# can be idle in the pool before it is invalidated. This config does
# not apply to sqlite.
sql_alchemy_pool_recycle = 3600

# The amount of parallelism as a setting to the executor. This defines
# the max number of task instances that should run simultaneously
# on this airflow installation
parallelism = 32

# The number of task instances allowed to run concurrently by the scheduler
dag_concurrency = 16

# Are DAGs paused by default at creation
dags_are_paused_at_creation = True

# When not using pools, tasks are run in the "default pool",
# whose size is guided by this config element
non_pooled_task_slot_count = 128

# The maximum number of active DAG runs per DAG
max_active_runs_per_dag = 16

# Whether to load the examples that ship with Airflow. It's good to
# get started, but you probably want to set this to False in a production
# environment
load_examples = False

# Where your Airflow plugins are stored
plugins_folder = /usr/src/app/plugins

# Secret key to save connection passwords in the db
fernet_key = cryptography_not_found_storing_passwords_in_plain_text

# Whether to disable pickling dags
donot_pickle = False

# How long before timing out a python file import while filling the DagBag
dagbag_import_timeout = 30


[operators]
# The default owner assigned to each new operator, unless
# provided explicitly or passed via `default_args`
default_owner = Airflow


[webserver]
# The base url of your website as airflow cannot guess what domain or
# cname you are using. This is used in automated emails that
# airflow sends to point links to the right web server
base_url = http://localhost:8080

# The ip specified when starting the web server
web_server_host = 0.0.0.0

# The port on which to run the web server
web_server_port = 8080

# The time the gunicorn webserver waits before timing out on a worker
web_server_worker_timeout = 120

# Secret key used to run your flask app
secret_key = temporary_key

# Number of workers to run the Gunicorn web server
workers = 4

# The worker class gunicorn should use. Choices include
# sync (default), eventlet, gevent
worker_class = sync

# Expose the configuration file in the web server
expose_config = true

# Set to true to turn on authentication:
# http://pythonhosted.org/airflow/installation.html#web-authentication
authenticate = False

# Filter the list of dags by owner name (requires authentication to be enabled)
filter_by_owner = False

[email]
email_backend = airflow.utils.email.send_email_smtp

[smtp]
# If you want airflow to send emails on retries, failure, and you want to use
# the airflow.utils.email.send_email_smtp function, you have to configure an smtp
# server here
smtp_host = localhost
smtp_starttls = True
smtp_ssl = False
smtp_user = airflow
smtp_port = 25
smtp_password = airflow
smtp_mail_from = airflow@airflow.com

[celery]
# This section only applies if you are using the CeleryExecutor in
# [core] section above

# The app name that will be used by celery
celery_app_name = airflow.executors.celery_executor

# The concurrency that will be used when starting workers with the
# "airflow worker" command. This defines the number of task instances that
# a worker will take, so size up your workers based on the resources on
# your worker box and the nature of your tasks
celeryd_concurrency = 16

# When you start an airflow worker, airflow starts a tiny web server
# subprocess to serve the workers local log files to the airflow main
# web server, who then builds pages and sends them to users. This defines
# the port on which the logs are served. It needs to be unused, and open
# visible from the main web server to connect into the workers.
worker_log_server_port = 8793

# The Celery broker URL. Celery supports RabbitMQ, Redis and experimentally
# a sqlalchemy database. Refer to the Celery documentation for more
# information.
broker_url = sqla+mysql://airflow:airflow@localhost:3306/airflow

# Another key Celery setting
celery_result_backend = db+mysql://airflow:airflow@localhost:3306/airflow

# Celery Flower is a sweet UI for Celery. Airflow has a shortcut to start
# it `airflow flower`. This defines the port that Celery Flower runs on
flower_port = 5555

# Default queue that tasks get assigned to and that worker listen on.
default_queue = default

[scheduler]
# Task instances listen for external kill signal (when you clear tasks
# from the CLI or the UI), this defines the frequency at which they should
# listen (in seconds).
job_heartbeat_sec = 5

# The scheduler constantly tries to trigger new tasks (look at the
# scheduler section in the docs for more information). This defines
# how often the scheduler should run (in seconds).
scheduler_heartbeat_sec = 5

# Statsd (https://github.com/etsy/statsd) integration settings
# statsd_on =  False
# statsd_host =  localhost
# statsd_port =  8125
# statsd_prefix = airflow

# The scheduler can run multiple threads in parallel to schedule dags.
# This defines how many threads will run. However airflow will never
# use more threads than the amount of cpu cores available.
max_threads = 2

[mesos]
# Mesos master address which MesosExecutor will connect to.
master = localhost:5050

# The framework name which Airflow scheduler will register itself as on mesos
framework_name = Airflow

# Number of cpu cores required for running one task instance using
# 'airflow run <dag_id> <task_id> <execution_date> --local -p <pickle_id>'
# command on a mesos slave
task_cpu = 1

# Memory in MB required for running one task instance using
# 'airflow run <dag_id> <task_id> <execution_date> --local -p <pickle_id>'
# command on a mesos slave
task_memory = 256

# Enable framework checkpointing for mesos
# See http://mesos.apache.org/documentation/latest/slave-recovery/
checkpoint = False

# Failover timeout in milliseconds.
# When checkpointing is enabled and this option is set, Mesos waits
# until the configured timeout for
# the MesosExecutor framework to re-register after a failover. Mesos
# shuts down running tasks if the
# MesosExecutor framework fails to re-register within this timeframe.
# failover_timeout = 604800

# Enable framework authentication for mesos
# See http://mesos.apache.org/documentation/latest/configuration/
authenticate = False

# Mesos credentials, if authentication is enabled
# default_principal = admin
# default_secret = admin
[core]
#气流的主文件夹,默认为~/airflow
气流_home=/usr/src/app
#气流管道所在的文件夹,很可能是
#代码存储库中的子文件夹
dags_文件夹=/usr/src/app/dags
#气流应存储其日志文件的文件夹。这个位置
基本日志文件夹=/usr/src/app/logs
#Airflow可以在AWS S3或Google云存储中远程存储日志。使用者
#必须提供远程位置URL(以's3://…'开头)或
#“gs://…”和一个气流连接id,该id提供对存储的访问
#地点。
远程\u基本\u日志\u文件夹=
远程日志连接id=
#对存储在S3中的日志使用服务器端加密
加密\u s3\u日志=False
#不推荐使用远程日志存储选项,请改用远程\u基本\u日志\u文件夹!
#s3\u日志\u文件夹=
#气流应使用的执行器类。选择包括
#顺序执行器,本地执行器,芹菜执行器
executor=LocalExecutor
#指向元数据数据库的SqlAlchemy连接字符串。
#SqlAlchemy支持许多不同的数据库引擎,更多信息
#他们的网站
sql\u alchemy\u conn=postgresql+psycopg2://气流:airflow@db/气流
#SqlAlchemy池大小是数据库连接的最大数量
#在游泳池里。
sql\u炼金术\u池大小=5
#SqlAlchemy池循环是连接的秒数
#可以在无效之前在池中处于空闲状态。此配置不支持
#不适用于sqlite。
sql\u炼金术\u池\u回收=3600
#作为执行器设置的并行量。这就定义了
#应同时运行的最大任务实例数
#在这个气流装置上
平行度=32
#计划程序允许并发运行的任务实例数
dag_并发=16
#默认情况下,DAG是否在创建时暂停
DAG在创建时暂停=True
#不使用池时,任务在“默认池”中运行,
#其大小由此配置元素引导
非池任务插槽计数=128
#每个DAG的最大活动DAG运行数
每个dag的最大活动运行次数=16
#是否加载附带气流的示例。很高兴见到你
#开始吧,但您可能希望在生产中将其设置为False
#环境
加载示例=False
#气流插件的存储位置
plugins\u folder=/usr/src/app/plugins
#在数据库中保存连接密码的密钥
fernet\u key=cryptography\u not\u found\u\u将密码存储在纯文本中
#是否禁用酸洗DAG
donot_pickle=错误
#填充数据包时,python文件导入超时需要多长时间
dagbag\u导入\u超时=30
[操作员]
#分配给每个新操作员的默认所有者,除非
#通过“默认参数”显式提供或传递`
默认所有者=气流
[网络服务器]
#您的网站的基本url无法猜测是哪个域或
#您正在使用的cname。这在自动电子邮件中使用
#气流将指向点的链接发送到正确的web服务器
基本url=http://localhost:8080
#启动web服务器时指定的ip
web_服务器_主机=0.0.0.0
#运行web服务器的端口
web_服务器_端口=8080
#gunicorn Web服务器在工作进程超时之前等待的时间
web\u服务器\u工作者\u超时=120
#用于运行flask应用程序的密钥
秘密密钥=临时密钥
#运行Gunicorn web服务器的工作进程数
工人=4
#工人类gunicorn应该使用。选择包括
#同步(默认)、eventlet、gevent
worker\u class=sync
#在web服务器中公开配置文件
expose_config=true
#设置为true以启用身份验证:
# http://pythonhosted.org/airflow/installation.html#web-认证
验证=错误
#按所有者名称筛选DAG列表(需要启用身份验证)
按所有者筛选\u=False
[电邮]
email\u backend=afflow.utils.email.send\u email\u smtp
[smtp]
#如果您希望在重试、失败时发送电子邮件,并且希望使用
#在airflow.utils.email.send_email_smtp功能中,您必须配置smtp
#这里是服务器
smtp_host=localhost
smtp_starttls=True
smtp_ssl=False
smtp_用户=空气流量
smtp_端口=25
smtp_密码=0
smtp_邮件_发件人=airflow@airflow.com
[芹菜]
#本节仅适用于在中使用CeleryExecutor的情况
#上文[核心]部分
#芹菜将使用的应用程序名称
芹菜\应用\名称=气流。执行器。芹菜\执行器
#在启动具有
#“气流工作者”命令。这定义了
#一个工人将承担一定的费用,因此,请根据网站上的资源评估您的工人
#您的工作区和任务的性质
celeryd_并发=16
#当您启动airflow worker时,airflow将启动一个小型web服务器
#将工人本地日志文件提供给气流总管的子流程
#web服务器,然后构建页面并将其发送给用户。这就定义了
#提供日志的端口。它需要不使用,并打开
#从主web服务器可见,以连接到workers。
工作者日志服务器端口=8793
#芹菜经纪人网址。芹菜支持RabbitMQ、Redis和
#一个sqlalchemy数据库。有关更多信息,请参阅芹菜文档
#信息。
代理url=sqla+mysql://airflow:airflow@本地主机:3306/台
#另一个关键的芹菜设置
芹菜\u结果\u后端=db+mysql://airflow:airflow@本地主机:3306/台
#芹菜花是芹菜的一种甜UI。气流有一个启动快捷方式
#它是“气流花”。这定义了芹菜花运行的端口
花港=5555
#默认队列
#!/bin/bash
declare -a DEFAULT_CONNS=(
    "cassandra_default"
    "azure_cosmos_default"
    "azure_data_lake_default"
    "segment_default"
    "qubole_default"
    "databricks_default"
    "emr_default"
    "sqoop_default"
    "redis_default"
    "druid_ingest_default"
    "druid_broker_default"
    "spark_default"
    "aws_default"
    "fs_default"
    "sftp_default"
    "ssh_default"
    "webhdfs_default"
    "wasb_default"
    "vertica_default"
    "mssql_default"
    "http_default"
    "sqlite_default"
    "postgres_default"
    "mysql_default"
    "mongo_default"
    "metastore_default"
    "hiveserver2_default"
    "hive_cli_default"
    "google_cloud_default"
    "presto_default"
    "bigquery_default"
    "beeline_default"
)

for CONN in "${DEFAULT_CONNS[@]}"
do
    airflow connections --delete --conn_id $CONN
done
airflow connections -l | awk -F"'" '{if ($2) print$2}' | xargs -I {} airflow connections -d --conn_id {}