美文网首页数客联盟
通过Ambari Rest API获取hadoop组件配置

通过Ambari Rest API获取hadoop组件配置

作者: guoqian123 | 来源:发表于2017-07-05 16:16 被阅读51次

    Ambari UI上可以很方便地查看及修改hadoop组件的配置.在Java代码中通过client访问,往往需要通过设置环境变量导入相关的配置, 如果能通过Ambari Rest API来获取组件配置,就可以免去手动配置的麻烦.

    由于ambari对配置进行了版本管理,所以获取hadoop组件配置需要两个步骤

    1. 先取得当前配置的version tag
    curl -k -s -u admin:admin "http://localhost:8080/api/v1/clusters/<clustername>?fields=Clusters/desired_configs"
    
    1. 然后用version tag来读取配置信息(如hdfs-site),目前不知如何取到单项配置的内容.只能对返回的json进行处理拿到需要的单项配置.
    curl -k -s -u admin:admin "http://localhost:8080/api/v1/clusters/<clustername>/configurations?type=hdfs-site&tag=version1496912618783"
    

    此外, ambari提供了shell脚本来获取、修改配置, 脚本内部实际上是调用了rest api,因此也可以从脚本中学习rest api的使用方法.

    /var/lib/ambari-server/resources/scripts/configs.sh
    

    参考:

    how to fetch & update configurations using the Ambari API

    相关文章

      网友评论

        本文标题:通过Ambari Rest API获取hadoop组件配置

        本文链接:https://www.haomeiwen.com/subject/aoeqhxtx.html