airflow 安装插件REST API以及踩过的坑

1.安装部署:
1.在airflow.cfg配置文件下面追加

[core]
plugins_folder = /home/{
    
    USER_NAME}/airflow/plugins

注:airflow目录前面是airflow所在的目录的绝对路径

2.在airflow目录下面,新建plugins目录

mkdir plugins

3.下载安装包

wget https://github.com/teamclairvoyant/airflow-rest-api-plugin/archive/master.zip

4.解压包

unzip master.zip

可以看到一个目录 airflow-rest-api-plugin-master

进到这个目录下面的

cd airflow-rest-api-plugin-master

5.可以看到,如下图
ke在这里插入图片描述

直接将plugins目录移动到airflow目录下面,或者将目录下面的rest_api_plugin.py文件和templates目录复制到第2步新建的plugins目录下面

mv rest_api_plugin.py /home/{
    
    USER_NAME}/airflow/plugins
mv templates /home/{
    
    USER_NAME}/airflow/plugins

6.在配置文件airflow.cfg后面追加如下:

[rest_api_plugin]

 # Logs global variables used in the REST API plugin when the plugin is loaded. Set to False by default to avoid too many logging messages.
 # DEFAULT: False
 log_loading = False

 # Filters out loading messages from the standard out
 # DEFAULT: True
 filter_loading_messages_in_cli_response = True

 # HTTP Header Name to be used for authenticating REST calls for the REST API Plugin
 # DEFAULT: 'rest_api_plugin_http_token'
 rest_api_plugin_http_token_header_name = rest_api_plugin_http_token

 # HTTP Token  to be used for authenticating REST calls for the REST API Plugin
 # DEFAULT: None
 # Comment this out to disable Authentication
 rest_api_plugin_expected_http_token = changeme

注:rest_api_plugin_expected_http_token可更换自定义的值

7.重启airflow webser服务

2.遇到的坑:
1.重启动时报如下的错:

Both share the same name "rest_api". Blueprints that are created

显示冲突
原因是可能是 :
插件目录查看是否有2个副本(也许以某种嵌套形式),例如:

~/airflow/plugins/rest_api_plugin.py
~/airflow/plugins/plugins/rest_api_plugin.py

情景:
将解压缩后的airflow-rest-api-plugin-master目录放到airflow目录下面,没有直接将plugins目录移动到airflow目录下面,而是选择cp复制也会出现这一问题
结论:
不要让两个plugins目录都在airflow目录下面,从airflow移除或者删除无用的即可
2.解压zip压缩包的时候显示,没有找到unzip命令,下载安装下就好了

yum install -y zip unzip

猜你喜欢

转载自blog.csdn.net/weixin_43202081/article/details/108260961