转自:[https://blog.csdn.net/u013595419/article/details/79140654](https://blog.csdn.net/u013595419/article/details/79140654) 有修改。 # 一、正文 ## Services 目录结构 ```bash [root@manager SAMPLESRV]# pwd /var/lib/ambari-server/resources/stacks/HDP/3.1/services/SAMPLESRV [root@manager SAMPLESRV]# tree . ├── configuration │ └── scrapy-config.xml ├── metainfo.xml ├── package │ └── scripts │ ├── master.py │ ├── sample_client.py │ └── slave.py └── quicklinks └── quicklinks.json ``` ## metainfo.xml 中添加configuration-dependencies属性 ```xml scrapy-config true ``` ## scrapy-config.xml ```xml scrapy.bot.name sina Scrapy bot's name scrapy.spider.modules sina.spiders sina's spider modules scrapy.robotstxt.obey False Whether oderby robots protocol ``` 为了能够让新添加的配置文件生效,在Ambari Web页面中删除掉现有的 SAMPLESRV,重新添加 SAMPLESRV 这个Service,安装完成后便可以看到配置中的配置选项了。 ![img](../../../../../ff_internal_upload/img/2020/image-20201114155357981.png) # 二、问题与解决方法 ## 2.1 can't start with home(s) directory(ies) 类型变量,如果参数值以 /home 或者 /homes 开头,Ambari识别为非法路径。 解决方法: ```js [root@manager SAMPLESRV]# vim /usr/lib/ambari-server/web/javascripts/app.js isAllowedDir: function isAllowedDir(value) { var dirs = value.replace(/,/g, ' ').trim().split(new RegExp("\\s+", "g")); for (var i = 0; i < dirs.length; i++) { if (dirs[i].startsWith('/home') || dirs[i].startsWith('/homes')) { return false; } } return true; }, ``` 修改以上函数,直接返回true即可,当然也可以根据自己实际需求修改。 对应到源代码应该修改: > ambari/ambari-web/public-static/javascripts/app.js # 三、参考 - [AMBARI-Enhanced Configs](https://cwiki.apache.org/confluence/display/AMBARI/Enhanced+Configs) - [Configuration support in Ambari](https://cwiki.apache.org/confluence/display/AMBARI/Configuration+support+in+Ambari) - [为Ambari自定义Service添加配置项](https://blog.csdn.net/u013595419/article/details/79140654) - [Ambari集成组件的方法](https://www.jianshu.com/p/96271bccb6bc)