Support Questions

Find answers, ask questions, and share your expertise

how to add properties by REST API

avatar

we have ambari cluster version 2.6.1 with HDP version - 2.6.4

I want to add by API those properties

Ambari dasboard.--> YARN --> Configs-->Advanced-->Customer yarn-site --> Click on "Add Property"


yarn.nodemanager.localizer.cache.target-size-mb = 10240

yarn.nodemanager.localizer.cache.cleanup.interval-ms = 300000

so both parameters will be in Customer yarn-site

please advice how to do this task with REST API?

Michael-Bronson
1 ACCEPTED SOLUTION

avatar

Hi @Michael Bronson ,

I see you want to perform this operation via REST API , I see the rest api method is very tough at you need to fetch the whole configs first, add your own configs and use PUT method to save it.

I would suggest you use config.py method.

for ex: below commands worked for me. Please note i use admin/admin and my cluster name is asnaik ,

[root@anaik1 ~]# /var/lib/ambari-server/resources/scripts/configs.py --user=admin --password=admin --port=8080 --action=set --host=anaik1 --cluster=asnaik --config-type=yarn-site --key=yarn.nodemanager.localizer.cache.target-size-mb --value=10240 
[root@anaik1 ~]# /var/lib/ambari-server/resources/scripts/configs.py --user=admin --password=admin --port=8080 --action=set --host=anaik1 --cluster=asnaik --config-type=yarn-site --key=yarn.nodemanager.localizer.cache.cleanup.interval-ms --value=300000

Please mark the thread as resolved if this answers your query.

Let me know if you need the harder method. can help you with that too. but requires two REST API calls and some shell scripting.

View solution in original post

3 REPLIES 3

avatar

Hi @Michael Bronson ,

I see you want to perform this operation via REST API , I see the rest api method is very tough at you need to fetch the whole configs first, add your own configs and use PUT method to save it.

I would suggest you use config.py method.

for ex: below commands worked for me. Please note i use admin/admin and my cluster name is asnaik ,

[root@anaik1 ~]# /var/lib/ambari-server/resources/scripts/configs.py --user=admin --password=admin --port=8080 --action=set --host=anaik1 --cluster=asnaik --config-type=yarn-site --key=yarn.nodemanager.localizer.cache.target-size-mb --value=10240 
[root@anaik1 ~]# /var/lib/ambari-server/resources/scripts/configs.py --user=admin --password=admin --port=8080 --action=set --host=anaik1 --cluster=asnaik --config-type=yarn-site --key=yarn.nodemanager.localizer.cache.cleanup.interval-ms --value=300000

Please mark the thread as resolved if this answers your query.

Let me know if you need the harder method. can help you with that too. but requires two REST API calls and some shell scripting.

avatar

@Akhil thank you so much its works very cool ,

Another question regarding the configs.py

lets say we want to add anew line as YARN_TEST=TEST in yarn-env template ( under

Advanced yarn-env )

YARN_TEST=TEST
   
Michael-Bronson

avatar

Hi @Michael Bronson,

sorry i missed the comment as you didnt tag me by name.

you can follow the same method with --action=set .

you can refer to this Good document by apache : https://cwiki.apache.org/confluence/display/AMBARI/Modify+configurations#Modifyconfigurations-Editco...

Please Mark answer as resolved if this helped you 🙂