运行 不同 Docker 容器中的芹菜工人的气流设置?
Airflow settings to run Celery workers in different Docker container?
我 运行 在 docker 容器中使用 Airflow。我已经为 运行 Postgres 服务器和 Rabbitmq 服务器创建了一个单独的容器,使用 docker 网络连接这些容器 - 按照这个很好的 article。现在我的 Airflow docker 容器正在 运行ning 并使用 docker 网络连接到其他容器 - 到目前为止过程顺利。问题是如何将运行airflow webserver
、airflow scheduler
和airflow worker
放在同一个容器中。经过一些研究,我发现:建议 运行 一个容器中的一项服务。现在我有两个解决方案
- 运行 同一个 Airflow 容器中的多个服务——我想不出一个简单的方法来实现在 Docker.
中成为一只新蜜蜂
- 为 运行 Celery worker 和 Airflow 调度程序创建单独的容器 - 但在 airflow.cfg 文件中,与 Celery 相关的设置是:
broker_url = 'amqp://guest:guest@ksaprice_rabbitmq:8080//'
、celery_result_backend = db+postgresql://developer:user889@ksaprice_postgres:5432/airflow
。这些设置指的是已经 运行 不同容器的数据库或 rabbitmq - 它们不指 ip/url 哪个 运行s 芹菜和调度程序,我假设它是这样的,因为芹菜和气流服务器上的调度程序 运行s。
我的问题是:
- 关于第 1 点:是否有一种简单的方法可以在同一个 Airflow 容器中执行 运行
airflow webserver
、airflow scheduler
和 airflow worker
命令?
- 参考第 2 点:airflow.cfg 中是否有一种方法可以将气流调度器和气流工作器配置为 运行 在单独的 docker 容器中 - 并且 link 它们使用docker 网络?
我是 Airflow 的新蜜蜂 Docker。
花了很多时间后我找到了以下答案:
- 第一个问题:
要 运行 同一 airflow_container 上的多个服务,请执行:
docker exec -it airflow_container bash
,现在 CLI 将附加到 airflow_container,然后是 运行 airflow worker
。对 airflow scheduler
和 airflow flower
重复相同的过程。现在您将拥有三个不同的 CLI 运行在同一个 airflow_container 上连接三个服务 - 这是我发现的最简单的方法。
- 对于第二个问题:这里有选项:airflow cli像
airflow webserver --hostname=some_host --port=some_port
和airflow flower --hostname=some_host --port=some_port
到运行它们在不同的服务器上。但是对于 airflow worker
来说,在不同的服务器上没有 运行 的选项 - 可能有一些其他的方法可以在不同的服务器上 运行 worker。
1- 我确实安装了所有这些所以它可能
2- 优化方法是在一台服务器上安装 airflow(webserver) + backend-DB(Mysql),在另一台服务器上安装 queuing(RabbitMQ),在另一组服务器上安装 Celery 部分。
下面我会提到一些来自源头的东西,这有助于更好地澄清事情:
CeleryExecutor is one of the ways you can scale out the number of
workers. For this to work, you need to setup a Celery backend
(RabbitMQ, Redis, …) and change your airflow.cfg to point the executor
parameter to CeleryExecutor and provide the related Celery settings.
Here are a few imperative requirements for your workers:
airflow needs to be installed, and the CLI needs to be in the path
Airflow configuration settings should be homogeneous across the
cluster
Operators that are executed on the worker need to have their
dependencies met in that context. For example, if you use the
HiveOperator, the hive CLI needs to be installed on that box, or if
you use the MySqlOperator, the required Python library needs to be
available in the PYTHONPATH somehow
The worker needs to have access to its DAGS_FOLDER, and you need to
synchronize the filesystems by your own means. A common setup would be
to store your DAGS_FOLDER in a Git repository and sync it across
machines using Chef, Puppet, Ansible, or whatever you use to configure
machines in your environment. If all your boxes have a common mount
point, having your pipelines files shared there should work as well
来源:https://airflow.readthedocs.io/en/1.10.6/howto/executor/use-celery.html
我 运行 在 docker 容器中使用 Airflow。我已经为 运行 Postgres 服务器和 Rabbitmq 服务器创建了一个单独的容器,使用 docker 网络连接这些容器 - 按照这个很好的 article。现在我的 Airflow docker 容器正在 运行ning 并使用 docker 网络连接到其他容器 - 到目前为止过程顺利。问题是如何将运行airflow webserver
、airflow scheduler
和airflow worker
放在同一个容器中。经过一些研究,我发现:建议 运行 一个容器中的一项服务。现在我有两个解决方案
- 运行 同一个 Airflow 容器中的多个服务——我想不出一个简单的方法来实现在 Docker. 中成为一只新蜜蜂
- 为 运行 Celery worker 和 Airflow 调度程序创建单独的容器 - 但在 airflow.cfg 文件中,与 Celery 相关的设置是:
broker_url = 'amqp://guest:guest@ksaprice_rabbitmq:8080//'
、celery_result_backend = db+postgresql://developer:user889@ksaprice_postgres:5432/airflow
。这些设置指的是已经 运行 不同容器的数据库或 rabbitmq - 它们不指 ip/url 哪个 运行s 芹菜和调度程序,我假设它是这样的,因为芹菜和气流服务器上的调度程序 运行s。
我的问题是:
- 关于第 1 点:是否有一种简单的方法可以在同一个 Airflow 容器中执行 运行
airflow webserver
、airflow scheduler
和airflow worker
命令? - 参考第 2 点:airflow.cfg 中是否有一种方法可以将气流调度器和气流工作器配置为 运行 在单独的 docker 容器中 - 并且 link 它们使用docker 网络?
我是 Airflow 的新蜜蜂 Docker。
花了很多时间后我找到了以下答案:
- 第一个问题:
要 运行 同一 airflow_container 上的多个服务,请执行:
docker exec -it airflow_container bash
,现在 CLI 将附加到 airflow_container,然后是 运行airflow worker
。对airflow scheduler
和airflow flower
重复相同的过程。现在您将拥有三个不同的 CLI 运行在同一个 airflow_container 上连接三个服务 - 这是我发现的最简单的方法。 - 对于第二个问题:这里有选项:airflow cli像
airflow webserver --hostname=some_host --port=some_port
和airflow flower --hostname=some_host --port=some_port
到运行它们在不同的服务器上。但是对于airflow worker
来说,在不同的服务器上没有 运行 的选项 - 可能有一些其他的方法可以在不同的服务器上 运行 worker。
1- 我确实安装了所有这些所以它可能
2- 优化方法是在一台服务器上安装 airflow(webserver) + backend-DB(Mysql),在另一台服务器上安装 queuing(RabbitMQ),在另一组服务器上安装 Celery 部分。 下面我会提到一些来自源头的东西,这有助于更好地澄清事情:
CeleryExecutor is one of the ways you can scale out the number of workers. For this to work, you need to setup a Celery backend (RabbitMQ, Redis, …) and change your airflow.cfg to point the executor parameter to CeleryExecutor and provide the related Celery settings.
Here are a few imperative requirements for your workers:
airflow needs to be installed, and the CLI needs to be in the path
Airflow configuration settings should be homogeneous across the cluster
Operators that are executed on the worker need to have their dependencies met in that context. For example, if you use the HiveOperator, the hive CLI needs to be installed on that box, or if you use the MySqlOperator, the required Python library needs to be available in the PYTHONPATH somehow
The worker needs to have access to its DAGS_FOLDER, and you need to synchronize the filesystems by your own means. A common setup would be to store your DAGS_FOLDER in a Git repository and sync it across machines using Chef, Puppet, Ansible, or whatever you use to configure machines in your environment. If all your boxes have a common mount point, having your pipelines files shared there should work as well
来源:https://airflow.readthedocs.io/en/1.10.6/howto/executor/use-celery.html