Skip to content
Advertisement

ambari + API syntax in order to change the parameters of the ambari services

In Ambari cluster GUI ( Version 2.5.0.3 ) , each service has the Config button

And when we click on Config button we can see the list of all relevant parameters and their values

For example YARN service have the parameter – Minimum Container Size (Memory) in MB

Of course we can change from the ambari GUI the values of the parameters …

But we want to automate the changing of the values by API commands under bash script

I searched in google to find some info about the API that change the values under parameters , but without success

I’ll appreciate to get answers about this,

Advertisement

Answer

Here are the steps to update service configurations using REST API.

  • Find your cluster name using the below the url, if you don’t know the cluster name, it requires in the below step – http://<AMBARI-SERVER>:8080/api/v1/clusters/
  • Find the property name, type from the cluster configurations json which can be accessed using the url, replace by cluster name from above step – http://<AMBARI-SERVER>:8080/api/v1/clusters/<CLUSTER_NAME>
  • Let’s say I wanted to update YARN node manager property yarn.nodemanager.resource.memory-mb, Create a json file as below –

newconfigs.json

{
  "Clusters": {
    "desired_config": {
      "type": "yarn-site",
      "tag": "version1502226523283",
      "properties": {
        "yarn.nodemanager.resource.memory-mb": "200000"
      }
    }
  }
}

tag number should be unique – just give some random number, You can update this configuration in Ambari usng the below command. Below API uses REST – PUT method.

curl -H "X-Requested-By: ambari" -X PUT -u admin:admin -d @newconfigs.json http://<AMBARI-SERVER>:8080/api/v1/clusters/<CLUSTER_NAME>

Refer below ambari official REST api documentations for more details.

https://github.com/apache/ambari/blob/trunk/ambari-server/docs/api/v1/configuration.md

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement