Skip to main content
 首页 » 编程设计

python之Airflow :无法连接到 ('0.0.0.0',8080)

2024年10月01日7luoye11

我在 Ubuntu 16.04 上,我已经用 pip 安装了 Airflow。下一步

airflow initdb 
[2017-07-29 12:20:23,483] {__init__.py:57} INFO - Using executor SequentialExecutor 
DB: sqlite:////home/milenko/airflow/airflow.db 
[2017-07-29 12:20:23,813] {db.py:287} INFO - Creating tables 
INFO  [alembic.runtime.migration] Context impl SQLiteImpl. 

这工作正常。但是当我尝试启动网络服务器时

airflow webserver -p 8080 
[2017-07-29 12:20:45,913] [4585] {models.py:167} INFO - Filling up the DagBag from /home/milenko/airflow/dags 
Running the Gunicorn Server with: 
Workers: 4 sync 
Host: 0.0.0.0:8080 
Timeout: 120 
Logfiles: - - 
=================================================================             
[2017-07-29 12:20:46,950] {__init__.py:57} INFO - Using executor SequentialExecutor 
[2017-07-29 12:20:47 +0200] [4590] [INFO] Starting gunicorn 19.3.0 
[2017-07-29 12:20:47 +0200] [4590] [ERROR] Connection in use: ('0.0.0.0', 8080) 
[2017-07-29 12:20:47 +0200] [4590] [ERROR] Retrying in 1 second. 
[2017-07-29 12:20:48 +0200] [4590] [ERROR] Connection in use: ('0.0.0.0', 8080) 
[2017-07-29 12:20:48 +0200] [4590] [ERROR] Retrying in 1 second. 
[2017-07-29 12:20:49 +0200] [4590] [ERROR] Connection in use: ('0.0.0.0', 8080) 
[2017-07-29 12:20:49 +0200] [4590] [ERROR] Retrying in 1 second. 
[2017-07-29 12:20:50 +0200] [4590] [ERROR] Connection in use: ('0.0.0.0', 8080) 
[2017-07-29 12:20:50 +0200] [4590] [ERROR] Retrying in 1 second. 
[2017-07-29 12:20:51 +0200] [4590] [ERROR] Connection in use: ('0.0.0.0', 8080) 
[2017-07-29 12:20:51 +0200] [4590] [ERROR] Retrying in 1 second. 
[2017-07-29 12:20:52 +0200] [4590] [ERROR] Can't connect to ('0.0.0.0', 8080) 

怎么解决?是不是Gunicorn服务器的问题? 使用 netstat 我得到了这个输出

sudo netstat -nlp | grep :80 
tcp6       0      0 :::8080                 :::*                    LISTEN      1711/java 

据我了解端口正在使用中。但是什么是 1711/java?如果我将其关闭,是否会影响其他内容? 这是我的 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 
 
# Paths to the SSL certificate and key for the web server. When both are 
# provided SSL will be enabled. This does not change the web server port. 
web_server_ssl_cert = 
web_server_ssl_key = 
 
# Number of seconds the gunicorn webserver waits before timing out on a worker 
web_server_worker_timeout = 120 
 
# Number of workers to refresh at a time. When set to 0, worker refresh is 
# disabled. When nonzero, airflow periodically refreshes webserver workers by 
# bringing up new ones and killing old ones. 
worker_refresh_batch_size = 1 
 
# Number of seconds to wait before refreshing a batch of workers. 
worker_refresh_interval = 30 
 
# 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 

请您参考如下方法:

我有同样的问题,默认端口 8080 被另一个进程使用。要解决此问题,请将端口从 8080 更改为类似 8081 的端口。

转到您的 airflow 目录并在编辑器中打开 airflow.cfg。将端口 8080 的所有实例更改为 8081。现在使用端口 8081 保存并重新运行调度程序和网络服务器。