使用Systemd在EC2 Centos上运行Airflow Web服务器:权限被拒绝

问题描述 投票:-1回答:1

我在EC2 CentOS中将Airflowsystemd一起使用来管理启动气流过程的守护程序(即:Web服务器,工作程序和调度程序)。当我运行sudo systemctl start airflow-webserver

: ec2-user : TTY=pts/0 ; PWD=/ ; USER=root ; COMMAND=/bin/systemctl enable airflow-webserver
Oct 30 01:27:37 ip-171-32-6-92.us-east-2.compute.internal sudo[11680]: ec2-user : TTY=pts/0 ; PWD=/ ; USER=root ; COMMAND=/bin/systemctl start airflow-webserver
Oct 30 01:27:37 ip-171-32-6-92.us-east-2.compute.internal systemd[11684]: Failed at step EXEC spawning /home/ec2-user/.local/bin/airflow: Permission denied
Oct 30 01:27:37 ip-171-32-6-92.us-east-2.compute.internal systemd[1]: airflow-webserver.service: main process exited, code=exited, status=203/EXEC
Oct 30 01:27:37 ip-171-32-6-92.us-east-2.compute.internal systemd[1]: Unit airflow-webserver.service entered failed state.
Oct 30 01:27:37 ip-171-32-6-92.us-east-2.compute.internal systemd[1]: airflow-webserver.service failed

airflow-webserver.service

[Unit]
Description=Airflow webserver daemon
After=network.target postgresql.service mysql.service redis.service rabbitmq-server.service
Wants=postgresql.service mysql.service redis.service rabbitmq-server.service

[Service]
EnvironmentFile=/etc/sysconfig/airflow
User=airflow
Group=airflow
Type=simple
ExecStart=/home/ec2-user/.local/bin/airflow webserver --pid /run/airflow/webserver.pid
RestartSec=5s
PrivateTmp=true

[Install]
WantedBy=multi-user.target

存在气流组和用户:

$ less /etc/group
# airflow:x:1001:ec2-user
$less etc/psswd
# ec2-user:x:1000:1000:EC2 Default User:/home/ec2-user:/bin/bash
# tss:x:59:59:Account used by the trousers package to sandbox the tcsd # daemon:/dev/null:/sbin/nologin
# airflow:x:1001:1001::/home/airflow:/bin/bash

THIS没有帮助。

UPDATE

[创建了airflow用户并在usr/local/bin下安装了气流,然后将ExecStart更改为usr/local/bin/airflow webserver --pid /run/airflow/webserver.pid之后,我得以通过初始权限被拒绝。但是现在我得到这个错误:

Oct 31 18:44:12 ip-172-31-6-92.us-east-2.compute.internal airflow[31430]: PermissionError: [Errno 13] Permission denied: '${AIRFLOW_HOME}'
Oct 31 18:44:12 ip-172-31-6-92.us-east-2.compute.internal airflow[31430]: During handling of the above exception, another exception occurred:
Oct 31 18:44:12 ip-172-31-6-92.us-east-2.compute.internal airflow[31430]: Traceback (most recent call last):
Oct 31 18:44:12 ip-172-31-6-92.us-east-2.compute.internal airflow[31430]: File "/usr/local/bin/airflow", line 25, in <module>
Oct 31 18:44:12 ip-172-31-6-92.us-east-2.compute.internal airflow[31430]: from airflow.configuration import conf
Oct 31 18:44:12 ip-172-31-6-92.us-east-2.compute.internal airflow[31430]: File "/usr/local/lib/python3.7/site-packages/airflow/__init__.py", line 31, in <module>
Oct 31 18:44:12 ip-172-31-6-92.us-east-2.compute.internal airflow[31430]: from airflow.utils.log.logging_mixin import LoggingMixin
Oct 31 18:44:12 ip-172-31-6-92.us-east-2.compute.internal airflow[31430]: File "/usr/local/lib/python3.7/site-packages/airflow/utils/__init__.py", line 24, in <module>
Oct 31 18:44:12 ip-172-31-6-92.us-east-2.compute.internal airflow[31430]: from .decorators import apply_defaults as _apply_defaults
Oct 31 18:44:12 ip-172-31-6-92.us-east-2.compute.internal airflow[31430]: File "/usr/local/lib/python3.7/site-packages/airflow/utils/decorators.py", line 34, in <module>
Oct 31 18:44:12 ip-172-31-6-92.us-east-2.compute.internal airflow[31430]: from airflow import settings
Oct 31 18:44:12 ip-172-31-6-92.us-east-2.compute.internal airflow[31430]: File "/usr/local/lib/python3.7/site-packages/airflow/settings.py", line 36, in <module>
Oct 31 18:44:12 ip-172-31-6-92.us-east-2.compute.internal airflow[31430]: from airflow.configuration import conf, AIRFLOW_HOME, WEBSERVER_CONFIG  # NOQA F401
Oct 31 18:44:12 ip-172-31-6-92.us-east-2.compute.internal airflow[31430]: File "/usr/local/lib/python3.7/site-packages/airflow/configuration.py", line 523, in <module>
Oct 31 18:44:12 ip-172-31-6-92.us-east-2.compute.internal airflow[31430]: mkdir_p(AIRFLOW_HOME)
Oct 31 18:44:12 ip-172-31-6-92.us-east-2.compute.internal airflow[31430]: File "/usr/local/lib/python3.7/site-packages/airflow/configuration.py", line 505, in mkdir_p
Oct 31 18:44:12 ip-172-31-6-92.us-east-2.compute.internal airflow[31430]: 'Error creating {}: {}'.format(path, exc.strerror))
Oct 31 18:44:12 ip-172-31-6-92.us-east-2.compute.internal airflow[31430]: airflow.exceptions.AirflowConfigException: Error creating ${AIRFLOW_HOME}: Permission denied
amazon-ec2 airflow systemd
1个回答
2
投票

这是因为您试图以airflow用户身份运行,但是airflow二进制文件的路径在/home/ec2-user/.local/bin/airflow中,该路径是ec2-user的HOME目录。

将气流安装在airflow用户有权访问的目录中。

© www.soinside.com 2019 - 2024. All rights reserved.