<?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: I have on cluster setup in hortonworks having ambari 2.1 and HDP 2.3. I have to create an automated Script for creating HDFS directories and Quota Setup. Anyone is having any kind of script related to this or any kind of suggestions, kindly post here. in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/I-have-on-cluster-setup-in-hortonworks-having-ambari-2-1-and/m-p/109608#M38278</link>
    <description>&lt;P&gt;Thanks for your help, Everything is working fine now. I just needed one more modification in this script, i wanted to take myFile.txt from command line, like suppose everytime i dont want to change the content of myFile.txt, instead i want to use different file, so i can do by command line. please suggest how to do that.&lt;/P&gt;</description>
    <pubDate>Thu, 25 Aug 2016 14:44:36 GMT</pubDate>
    <dc:creator>Yukti</dc:creator>
    <dc:date>2016-08-25T14:44:36Z</dc:date>
    <item>
      <title>I have on cluster setup in hortonworks having ambari 2.1 and HDP 2.3. I have to create an automated Script for creating HDFS directories and Quota Setup. Anyone is having any kind of script related to this or any kind of suggestions, kindly post here.</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/I-have-on-cluster-setup-in-hortonworks-having-ambari-2-1-and/m-p/109601#M38271</link>
      <description />
      <pubDate>Thu, 18 Aug 2016 17:53:27 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/I-have-on-cluster-setup-in-hortonworks-having-ambari-2-1-and/m-p/109601#M38271</guid>
      <dc:creator>Yukti</dc:creator>
      <dc:date>2016-08-18T17:53:27Z</dc:date>
    </item>
    <item>
      <title>Re: I have on cluster setup in hortonworks having ambari 2.1 and HDP 2.3. I have to create an automated Script for creating HDFS directories and Quota Setup. Anyone is having any kind of script related to this or any kind of suggestions, kindly post here.</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/I-have-on-cluster-setup-in-hortonworks-having-ambari-2-1-and/m-p/109602#M38272</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/12568/yukagr19.html" nodeid="12568"&gt;@Yukti  Agrawal&lt;/A&gt;&lt;/P&gt;&lt;P&gt;You have the core of what you need to do this via a shell script.  To do what you are looking for, you you just need to add some more logic.  Why not prompt for the directory path, the owner/group, then the quota?  You can always check the input for  a special value like "-done-" to let the script know you are done.&lt;/P&gt;&lt;PRE&gt;while [ "$directory" != "-done-" ]
do
  echo "To exit, enter -done- or press ^C"
  read -p "Enter a directory : " directory
  echo $directory

  read -p "Enter permissions (ie: 755) : " permissions
  echo $permissions

  read -p "Enter ownership (ie: user:group) : " ownership
  echo $ownership

  read -p "Enter quota (ie: 1024m) : " quota
  echo $quota

echo "
  hdfs dfs -mkdir $directory
  hdfs dfs -chown $ownership $directory
  hdfs dfs -chmod $permissions $directory
  hdfs dfsadmin -setSpaceQuota $quota $directory"
done

&lt;/PRE&gt;&lt;P&gt;You would still have to enter the info for each directory, which may not be ideal.  An alternative would be read the input from a text file.  The text file could be something like this (tab delimited):&lt;/P&gt;&lt;PRE&gt;/user/testuser1	testuser1:testgroup	775	1024M
/user/testuser2	testuser2:testgroup	775	1024M
&lt;/PRE&gt;&lt;P&gt;Then all you need to do is load the file (say we call it myFile.txt) in and parse each line and execute the commands based on the values.&lt;/P&gt;&lt;PRE&gt;while IFS=$'\t' read -r -a myOptions
do
 echo "directory: ${myOptions[0]}"
 echo "ownership: ${myOptions[1]}"
 echo "permissions: ${myOptions[2]}"
 echo "quota: ${myOptions[3]}"
done &amp;lt; myFile.txt&lt;/PRE&gt;</description>
      <pubDate>Fri, 19 Aug 2016 19:55:38 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/I-have-on-cluster-setup-in-hortonworks-having-ambari-2-1-and/m-p/109602#M38272</guid>
      <dc:creator>myoung</dc:creator>
      <dc:date>2016-08-19T19:55:38Z</dc:date>
    </item>
    <item>
      <title>Re: I have on cluster setup in hortonworks having ambari 2.1 and HDP 2.3. I have to create an automated Script for creating HDFS directories and Quota Setup. Anyone is having any kind of script related to this or any kind of suggestions, kindly post here.</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/I-have-on-cluster-setup-in-hortonworks-having-ambari-2-1-and/m-p/109603#M38273</link>
      <description>&lt;P&gt;Thank you so much &lt;A rel="user" href="https://community.cloudera.com/users/2695/myoung.html" nodeid="2695"&gt;@Michael Young&lt;/A&gt;...
I have created the script...now i want something like...whenever i will run that script it should login as super user which is hdfs in my case and then execute my script. can you please suggest how can i implement this functionality.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Aug 2016 17:06:01 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/I-have-on-cluster-setup-in-hortonworks-having-ambari-2-1-and/m-p/109603#M38273</guid>
      <dc:creator>Yukti</dc:creator>
      <dc:date>2016-08-23T17:06:01Z</dc:date>
    </item>
    <item>
      <title>Re: I have on cluster setup in hortonworks having ambari 2.1 and HDP 2.3. I have to create an automated Script for creating HDFS directories and Quota Setup. Anyone is having any kind of script related to this or any kind of suggestions, kindly post here.</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/I-have-on-cluster-setup-in-hortonworks-having-ambari-2-1-and/m-p/109604#M38274</link>
      <description>&lt;P&gt;#!/bin/bash &lt;/P&gt;&lt;P&gt;sudo su hdfs &amp;lt;&amp;lt; EOF&lt;/P&gt;&lt;P&gt;while IFS=$'\t' read -r -a myOptions&lt;/P&gt;&lt;P&gt;do&lt;/P&gt;&lt;P&gt;echo "directory: ${myOptions[0]}"&lt;/P&gt;&lt;P&gt;echo "ownership: ${myOptions[1]}"&lt;/P&gt;&lt;P&gt;echo "permissions: ${myOptions[2]}"&lt;/P&gt;&lt;P&gt;echo "quota: ${myOptions[3]}"&lt;/P&gt;&lt;P&gt;hdfs dfs -mkdir ${myOptions[0]}&lt;/P&gt;&lt;P&gt;
  hdfs dfs -chown ${myOptions[1]} ${myOptions[0]}&lt;/P&gt;&lt;P&gt;
  hdfs dfs -chmod ${myOptions[2]} ${myOptions[0]}&lt;/P&gt;&lt;P&gt;
  hdfs dfsadmin -setSpaceQuota ${myOptions[3]} ${myOptions[0]}&lt;/P&gt;&lt;P&gt;done&amp;lt; myFile.txt&lt;/P&gt;&lt;P&gt;EOF&lt;/P&gt;&lt;P&gt;I have used the above script..but this is actually giving an error &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;bash: line 15: myFile.txt: Permission denied&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Please suggest &lt;A rel="user" href="https://community.cloudera.com/users/2695/myoung.html" nodeid="2695"&gt;@Michael Young&lt;/A&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Aug 2016 18:53:33 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/I-have-on-cluster-setup-in-hortonworks-having-ambari-2-1-and/m-p/109604#M38274</guid>
      <dc:creator>Yukti</dc:creator>
      <dc:date>2016-08-23T18:53:33Z</dc:date>
    </item>
    <item>
      <title>Re: I have on cluster setup in hortonworks having ambari 2.1 and HDP 2.3. I have to create an automated Script for creating HDFS directories and Quota Setup. Anyone is having any kind of script related to this or any kind of suggestions, kindly post here.</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/I-have-on-cluster-setup-in-hortonworks-having-ambari-2-1-and/m-p/109605#M38275</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/12568/yukagr19.html" nodeid="12568"&gt;@Yukti  Agrawal&lt;/A&gt; &lt;/P&gt;&lt;P&gt;Where is myFile.txt located?  What are the file permissions for that file?  It is most likely that the hdfs user does not have read access to the file, or does not have access to the directory where the file is located.&lt;/P&gt;&lt;P&gt;Alternatives would be to run the entire script as the hdfs user from outside the script.  With both of these methods, the permissions I mentioned above will also need to be fixed. You have a couple of options:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;su - hdfs -c &amp;lt;your script name&amp;gt;&lt;/LI&gt;&lt;LI&gt;sudo -u hdfs &amp;lt;your script name&amp;gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Many systems will have sudo available, however you have to be configured with access to run commands via sudo.  If you don't have access to sudo, then option number 1 will work for you.  However, you have to know the hdfs user password.&lt;/P&gt;&lt;P&gt;If you feel my answer was helpful, don't forget to accept the answer.  This helps other people find solutions.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Aug 2016 20:45:45 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/I-have-on-cluster-setup-in-hortonworks-having-ambari-2-1-and/m-p/109605#M38275</guid>
      <dc:creator>myoung</dc:creator>
      <dc:date>2016-08-23T20:45:45Z</dc:date>
    </item>
    <item>
      <title>Re: I have on cluster setup in hortonworks having ambari 2.1 and HDP 2.3. I have to create an automated Script for creating HDFS directories and Quota Setup. Anyone is having any kind of script related to this or any kind of suggestions, kindly post here.</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/I-have-on-cluster-setup-in-hortonworks-having-ambari-2-1-and/m-p/109606#M38276</link>
      <description>&lt;P&gt;Unfortunately i dont have sudo access as well as the hdfs password.
someone suggested me to do as follows:&lt;/P&gt;&lt;P&gt;#!/bin/bash&lt;/P&gt;&lt;P&gt;while IFS=$'\t' read -r -a myOptions&lt;/P&gt;&lt;P&gt;do&lt;/P&gt;&lt;P&gt;echo "directory: ${myOptions[0]}"&lt;/P&gt;&lt;P&gt;echo "ownership: ${myOptions[1]}"&lt;/P&gt;&lt;P&gt;echo "permissions: ${myOptions[2]}"&lt;/P&gt;&lt;P&gt;echo "quota: ${myOptions[3]}"&lt;/P&gt;&lt;P&gt;sudo su hdfs -c "hdfs dfs -mkdir ${myOptions[0]}"&lt;/P&gt;&lt;P&gt;sudo su hdfs -c "hdfs dfs -chown ${myOptions[1]} ${myOptions[0]}"&lt;/P&gt;&lt;P&gt;sudo su hdfs -c "hdfs dfs -chmod ${myOptions[2]} ${myOptions[0]}"&lt;/P&gt;&lt;P&gt;sudo su hdfs -c "hdfs dfsadmin -setSpaceQuota ${myOptions[3]} ${myOptions[0]}"&lt;/P&gt;&lt;P&gt;done&amp;lt; myFile.txt&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;myFile.txt&lt;/STRONG&gt;

/usr/t1 hive:hive       776     1T &lt;/P&gt;&lt;P&gt;/usr/t2 hdfs:hdfs       775     100G&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;But its also giving error as follows:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;sh create_and_set_quota_alternative.sh&lt;/P&gt;&lt;P&gt;directory: /usr/t1 &lt;/P&gt;&lt;P&gt;ownership: hive:hive&lt;/P&gt;&lt;P&gt;permissions: 776 &lt;/P&gt;&lt;P&gt;quota: 1T&lt;/P&gt;&lt;P&gt;
Error: JAVA_HOME is not set and could not be found. &lt;/P&gt;&lt;P&gt;Error: JAVA_HOME is not set and could not be found.&lt;/P&gt;&lt;P&gt;
Error: JAVA_HOME is not set and could not be found.&lt;/P&gt;&lt;P&gt;
Error: JAVA_HOME is not set and could not be found.&lt;/P&gt;&lt;P&gt;
directory: /usr/t2&lt;/P&gt;&lt;P&gt;
ownership: hdfs:hdfs &lt;/P&gt;&lt;P&gt;permissions: 775 &lt;/P&gt;&lt;P&gt;quota: 100G &lt;/P&gt;&lt;P&gt;Error: JAVA_HOME is not set and could not be found. &lt;/P&gt;&lt;P&gt;Error: JAVA_HOME is not set and could not be found.&lt;/P&gt;&lt;P&gt;
Error: JAVA_HOME is not set and could not be found. &lt;/P&gt;&lt;P&gt;Error: JAVA_HOME is not set and could not be found.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Aug 2016 10:05:32 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/I-have-on-cluster-setup-in-hortonworks-having-ambari-2-1-and/m-p/109606#M38276</guid>
      <dc:creator>Yukti</dc:creator>
      <dc:date>2016-08-24T10:05:32Z</dc:date>
    </item>
    <item>
      <title>Re: I have on cluster setup in hortonworks having ambari 2.1 and HDP 2.3. I have to create an automated Script for creating HDFS directories and Quota Setup. Anyone is having any kind of script related to this or any kind of suggestions, kindly post here.</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/I-have-on-cluster-setup-in-hortonworks-having-ambari-2-1-and/m-p/109607#M38277</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/12568/yukagr19.html" nodeid="12568"&gt;@Yukti  Agrawal&lt;/A&gt; &lt;/P&gt;&lt;P&gt;When you use sudo, you should use the "-" option to get the user environment settings, etc.&lt;/P&gt;&lt;PRE&gt;sudo su - hdfs -c "hdfs dfs -mkdir ${myOptions[0]}
&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 Aug 2016 02:52:31 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/I-have-on-cluster-setup-in-hortonworks-having-ambari-2-1-and/m-p/109607#M38277</guid>
      <dc:creator>myoung</dc:creator>
      <dc:date>2016-08-25T02:52:31Z</dc:date>
    </item>
    <item>
      <title>Re: I have on cluster setup in hortonworks having ambari 2.1 and HDP 2.3. I have to create an automated Script for creating HDFS directories and Quota Setup. Anyone is having any kind of script related to this or any kind of suggestions, kindly post here.</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/I-have-on-cluster-setup-in-hortonworks-having-ambari-2-1-and/m-p/109608#M38278</link>
      <description>&lt;P&gt;Thanks for your help, Everything is working fine now. I just needed one more modification in this script, i wanted to take myFile.txt from command line, like suppose everytime i dont want to change the content of myFile.txt, instead i want to use different file, so i can do by command line. please suggest how to do that.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Aug 2016 14:44:36 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/I-have-on-cluster-setup-in-hortonworks-having-ambari-2-1-and/m-p/109608#M38278</guid>
      <dc:creator>Yukti</dc:creator>
      <dc:date>2016-08-25T14:44:36Z</dc:date>
    </item>
    <item>
      <title>Re: I have on cluster setup in hortonworks having ambari 2.1 and HDP 2.3. I have to create an automated Script for creating HDFS directories and Quota Setup. Anyone is having any kind of script related to this or any kind of suggestions, kindly post here.</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/I-have-on-cluster-setup-in-hortonworks-having-ambari-2-1-and/m-p/109609#M38279</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/12568/yukagr19.html" nodeid="12568"&gt;@Yukti  Agrawal&lt;/A&gt; &lt;/P&gt;&lt;P&gt;If you want to get a parameter in a bash script, you use&lt;/P&gt;&lt;PRE&gt;$1 - first parameter
$2 - second parameter&lt;/PRE&gt;&lt;P&gt;So in the script you would have something like this:&lt;/P&gt;&lt;PRE&gt;myFile=$1
&lt;/PRE&gt;&lt;P&gt;Anywhere you had "myFile.txt", you can replace with "$myFile".  Naturally you would want to do some error checking make sure the file exists.  There are a number of ways to do that.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Aug 2016 21:03:12 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/I-have-on-cluster-setup-in-hortonworks-having-ambari-2-1-and/m-p/109609#M38279</guid>
      <dc:creator>myoung</dc:creator>
      <dc:date>2016-08-25T21:03:12Z</dc:date>
    </item>
  </channel>
</rss>

