<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: How can i write a script to automate stop of all ambari server in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-can-i-write-a-script-to-automate-stop-of-all-ambari/m-p/142116#M48205</link>
    <description>&lt;P&gt;in your ssh command  ssh ambari2@$host, you have ambari2 and in your question you say you installed as ambari, so just wanted to confirm ambari2 is correct.&lt;/P&gt;&lt;P&gt;so if you are able to ssh correctly, you have two issue, &lt;/P&gt;&lt;P&gt;i think ambari-agent will run as root, so you need to do a sudo.&lt;/P&gt;&lt;P&gt;so u have to pass -t to you ssh command. ssh -t ambari2@host (alternately you can disable requiretty in /etc/sudoers ).&lt;/P&gt;&lt;P&gt; So in /etc/sudoers of each remote machine, you have to enable ambari to be able to run command without password. &lt;/P&gt;&lt;P&gt;like this&lt;/P&gt;&lt;P&gt;ambari2 ALL=(ALL)       NOPASSWD: ALL&lt;/P&gt;</description>
    <pubDate>Wed, 07 Dec 2016 23:05:44 GMT</pubDate>
    <dc:creator>knarayanan</dc:creator>
    <dc:date>2016-12-07T23:05:44Z</dc:date>
    <item>
      <title>How can i write a script to automate stop of all ambari server</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-can-i-write-a-script-to-automate-stop-of-all-ambari/m-p/142109#M48198</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I work actualy with HDP 2.5 and my cluster have 25 nodes. I try to automate all my script in partuclar a script to start and stop all ambari agent. &lt;/P&gt;&lt;P&gt;My cluster are not install with root but with username ambari. &lt;/P&gt;&lt;P&gt;i try ssh with this command &lt;/P&gt;&lt;PRE&gt;hosts=$(curl -s -u admin:admin -H 'X-Requested-By:ambari' -i -k -X GET ${AMBARI_HSTNAME}:8080/api/v1/clusters/muclusterName/hosts | grep '"host_name"' | cut -d'"' -f4)
print $hosts

for host in $hosts
do
     ssh ambari2@$host "systemctl stop ambari-agent.service"
     print DONE for $host ...............................
done&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="10155-ambariagent-error.png" style="width: 600px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/21701iC55ACC08B4DE13F0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="10155-ambariagent-error.png" alt="10155-ambariagent-error.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;PRE&gt;But i got this error below.

Please can you help me? 
Thanks&lt;/PRE&gt;</description>
      <pubDate>Mon, 19 Aug 2019 08:12:08 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-can-i-write-a-script-to-automate-stop-of-all-ambari/m-p/142109#M48198</guid>
      <dc:creator>amoussoubaruch1</dc:creator>
      <dc:date>2019-08-19T08:12:08Z</dc:date>
    </item>
    <item>
      <title>Re: How can i write a script to automate stop of all ambari server</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-can-i-write-a-script-to-automate-stop-of-all-ambari/m-p/142110#M48199</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/13812/amoussoubaruch1.html" nodeid="13812"&gt;@Baruch AMOUSSOU DJANGBAN&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Assuming ambari2 user can stop  the services, &lt;/P&gt;&lt;P&gt;Why don't you try using &lt;/P&gt;&lt;PRE&gt;ambari-agent stop&lt;/PRE&gt;&lt;P&gt; instead of &lt;/P&gt;&lt;PRE&gt;systemctl stop ambari-agent.service	
&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Dec 2016 22:41:53 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-can-i-write-a-script-to-automate-stop-of-all-ambari/m-p/142110#M48199</guid>
      <dc:creator>yjagadeesan</dc:creator>
      <dc:date>2016-12-07T22:41:53Z</dc:date>
    </item>
    <item>
      <title>Re: How can i write a script to automate stop of all ambari server</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-can-i-write-a-script-to-automate-stop-of-all-ambari/m-p/142111#M48200</link>
      <description>&lt;P&gt;you have ambari2 as the username, may be you need to use ambari. Also, has ambari user been setup with password less ssh to the other nodes.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2016 22:43:12 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-can-i-write-a-script-to-automate-stop-of-all-ambari/m-p/142111#M48200</guid>
      <dc:creator>knarayanan</dc:creator>
      <dc:date>2016-12-07T22:43:12Z</dc:date>
    </item>
    <item>
      <title>Re: How can i write a script to automate stop of all ambari server</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-can-i-write-a-script-to-automate-stop-of-all-ambari/m-p/142112#M48201</link>
      <description>&lt;P&gt;@&lt;A href="https://community.hortonworks.com/users/13812/amoussoubaruch1.html"&gt;Baruch AMOUSSOU DJANGBAN&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Are you running ambari-agent as "root" user or "ambari2" user?&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2016 22:43:14 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-can-i-write-a-script-to-automate-stop-of-all-ambari/m-p/142112#M48201</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2016-12-07T22:43:14Z</dc:date>
    </item>
    <item>
      <title>Re: How can i write a script to automate stop of all ambari server</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-can-i-write-a-script-to-automate-stop-of-all-ambari/m-p/142113#M48202</link>
      <description>&lt;P&gt;you have ambari2 as the username, may be you need to use ambari. Also, has ambari user been setup with password less ssh to the other nodes.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2016 22:43:17 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-can-i-write-a-script-to-automate-stop-of-all-ambari/m-p/142113#M48202</guid>
      <dc:creator>knarayanan</dc:creator>
      <dc:date>2016-12-07T22:43:17Z</dc:date>
    </item>
    <item>
      <title>Re: How can i write a script to automate stop of all ambari server</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-can-i-write-a-script-to-automate-stop-of-all-ambari/m-p/142114#M48203</link>
      <description>&lt;P&gt; &lt;A rel="user" href="https://community.cloudera.com/users/10180/knarayanan.html" nodeid="10180"&gt;@Karthik Narayanan&lt;/A&gt;   i run ambari agent with root. Ambari2 user have no privilige to do that &lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2016 22:51:07 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-can-i-write-a-script-to-automate-stop-of-all-ambari/m-p/142114#M48203</guid>
      <dc:creator>amoussoubaruch1</dc:creator>
      <dc:date>2016-12-07T22:51:07Z</dc:date>
    </item>
    <item>
      <title>Re: How can i write a script to automate stop of all ambari server</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-can-i-write-a-script-to-automate-stop-of-all-ambari/m-p/142115#M48204</link>
      <description>&lt;P&gt;no it's a mistake. It's ambari2 user not ambari&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2016 22:51:54 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-can-i-write-a-script-to-automate-stop-of-all-ambari/m-p/142115#M48204</guid>
      <dc:creator>amoussoubaruch1</dc:creator>
      <dc:date>2016-12-07T22:51:54Z</dc:date>
    </item>
    <item>
      <title>Re: How can i write a script to automate stop of all ambari server</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-can-i-write-a-script-to-automate-stop-of-all-ambari/m-p/142116#M48205</link>
      <description>&lt;P&gt;in your ssh command  ssh ambari2@$host, you have ambari2 and in your question you say you installed as ambari, so just wanted to confirm ambari2 is correct.&lt;/P&gt;&lt;P&gt;so if you are able to ssh correctly, you have two issue, &lt;/P&gt;&lt;P&gt;i think ambari-agent will run as root, so you need to do a sudo.&lt;/P&gt;&lt;P&gt;so u have to pass -t to you ssh command. ssh -t ambari2@host (alternately you can disable requiretty in /etc/sudoers ).&lt;/P&gt;&lt;P&gt; So in /etc/sudoers of each remote machine, you have to enable ambari to be able to run command without password. &lt;/P&gt;&lt;P&gt;like this&lt;/P&gt;&lt;P&gt;ambari2 ALL=(ALL)       NOPASSWD: ALL&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2016 23:05:44 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-can-i-write-a-script-to-automate-stop-of-all-ambari/m-p/142116#M48205</guid>
      <dc:creator>knarayanan</dc:creator>
      <dc:date>2016-12-07T23:05:44Z</dc:date>
    </item>
    <item>
      <title>Re: How can i write a script to automate stop of all ambari server</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-can-i-write-a-script-to-automate-stop-of-all-ambari/m-p/142117#M48206</link>
      <description>&lt;P&gt;to be clear&lt;/P&gt;&lt;P&gt;modify vi /etc/sudoers in each node to be allow ambari2 to sudo without password.&lt;/P&gt;&lt;P&gt;ambari2 ALL=(ALL)       NOPASSWD: ALL&lt;/P&gt;&lt;P&gt;then change ssh command "ssh -t ambari2@host "sudo systemctl ambari-agent restart"&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2016 23:13:58 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-can-i-write-a-script-to-automate-stop-of-all-ambari/m-p/142117#M48206</guid>
      <dc:creator>knarayanan</dc:creator>
      <dc:date>2016-12-07T23:13:58Z</dc:date>
    </item>
    <item>
      <title>Re: How can i write a script to automate stop of all ambari server</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-can-i-write-a-script-to-automate-stop-of-all-ambari/m-p/142118#M48207</link>
      <description>&lt;P&gt;@&lt;A href="https://community.hortonworks.com/users/13812/amoussoubaruch1.html"&gt;Baruch AMOUSSOU DJANGBAN&lt;/A&gt;
&lt;/P&gt;&lt;P&gt;you can do this as well.If you have installed the Cluster Shell in cluster, we can perform below simple steps to stop and start&lt;/P&gt;&lt;P&gt;-----------------------------------&lt;/P&gt;&lt;P&gt;#!/bin/sh&lt;/P&gt;&lt;P&gt;clush -g all ambari-agent restart&lt;/P&gt;&lt;P&gt;-------------------------------------------&lt;/P&gt;&lt;P&gt;Refer below link for more info about open source Cluster shell:&lt;/P&gt;&lt;P&gt; &lt;A href="https://github.com/cea-hpc/clustershell/downloads"&gt;https://github.com/cea-hpc/clustershell/downloads&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2016 23:26:18 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-can-i-write-a-script-to-automate-stop-of-all-ambari/m-p/142118#M48207</guid>
      <dc:creator>divakarreddy_a</dc:creator>
      <dc:date>2016-12-07T23:26:18Z</dc:date>
    </item>
  </channel>
</rss>

